blob: b8e10594f5d3c8790c0b6105e0b2f174cd5fe63c [file] [log] [blame]
[email protected]3653146a2012-05-29 13:41:471// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]eca3fc92013-05-01 03:53:405#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_
6#define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_
[email protected]3653146a2012-05-29 13:41:477
[email protected]3653146a2012-05-29 13:41:478#include <string>
[email protected]79c3752d2012-07-17 12:10:089#include <vector>
[email protected]3653146a2012-05-29 13:41:4710
[email protected]dd91da82012-09-07 23:49:4911#include "base/callback_forward.h"
[email protected]57999812013-02-24 05:40:5212#include "base/files/file_path.h"
[email protected]3653146a2012-05-29 13:41:4713#include "base/memory/scoped_ptr.h"
[email protected]73f9c742012-06-15 07:37:1314#include "base/memory/weak_ptr.h"
15#include "base/observer_list.h"
[email protected]78a158b2013-04-23 06:57:4916#include "chrome/browser/chromeos/drive/file_errors.h"
[email protected]3653146a2012-05-29 13:41:4717
[email protected]01ba15f72012-06-09 00:41:0518class Profile;
19
[email protected]ddbf2052012-07-13 15:07:0220namespace base {
21
22class SequencedTaskRunner;
23
24} // namespace base
25
[email protected]d9d04df2012-10-12 07:06:3526namespace drive {
[email protected]3653146a2012-05-29 13:41:4727
[email protected]aa7365c2013-05-01 05:50:4728class FileCacheEntry;
[email protected]c960d222012-06-15 10:03:5029
[email protected]77fb1a62012-11-01 13:42:3230// Callback for GetCacheEntry.
[email protected]fae353a2012-07-11 23:30:2731// |success| indicates if the operation was successful.
32// |cache_entry| is the obtained cache entry. On failure, |cache_state| is
[email protected]02821102012-07-12 20:19:1733// set to TEST_CACHE_STATE_NONE.
[email protected]aa7365c2013-05-01 05:50:4734typedef base::Callback<void(bool success, const FileCacheEntry& cache_entry)>
[email protected]fae353a2012-07-11 23:30:2735 GetCacheEntryCallback;
36
[email protected]2f0bf592013-06-05 08:07:2337// Callback for Iterate().
38typedef base::Callback<void(const std::string& resource_id,
39 const FileCacheEntry& cache_entry)>
40 CacheIterateCallback;
41
[email protected]59c7cdec2013-05-07 04:17:1342namespace internal {
43
44class FileCacheMetadata;
45class FileCacheObserver;
46
47// Callback for GetFileFromCache.
48typedef base::Callback<void(FileError error,
49 const base::FilePath& cache_file_path)>
50 GetFileFromCacheCallback;
51
[email protected]77fb1a62012-11-01 13:42:3252// Callback for RequestInitialize.
[email protected]322e0032012-10-07 01:55:5353// |success| indicates if the operation was successful.
[email protected]78a158b2013-04-23 06:57:4954// TODO(satorux): Change this to FileError when it becomes necessary.
[email protected]322e0032012-10-07 01:55:5355typedef base::Callback<void(bool success)>
56 InitializeCacheCallback;
57
[email protected]f6fd98a2012-12-14 00:04:0258// Interface class used for getting the free disk space. Tests can inject an
59// implementation that reports fake free disk space.
60class FreeDiskSpaceGetterInterface {
61 public:
62 virtual ~FreeDiskSpaceGetterInterface() {}
[email protected]cf64404b2012-12-14 07:12:5063 virtual int64 AmountOfFreeDiskSpace() = 0;
[email protected]f6fd98a2012-12-14 00:04:0264};
65
[email protected]0d52ed52013-05-01 08:21:2166// FileCache is used to maintain cache states of FileSystem.
[email protected]6b70c7b2012-06-14 03:10:4367//
68// All non-static public member functions, unless mentioned otherwise (see
[email protected]54ba37502013-05-09 08:43:4069// GetCacheFilePath() for example), should be run with |blocking_task_runner|.
[email protected]eca3fc92013-05-01 03:53:4070class FileCache {
[email protected]3653146a2012-05-29 13:41:4771 public:
72 // Enum defining GCache subdirectory location.
[email protected]eca3fc92013-05-01 03:53:4073 // This indexes into |FileCache::cache_paths_| vector.
[email protected]3653146a2012-05-29 13:41:4774 enum CacheSubDirectoryType {
[email protected]6bb1c762013-06-03 08:36:5675 CACHE_TYPE_META = 0, // Resource metadata.
[email protected]3653146a2012-05-29 13:41:4776 CACHE_TYPE_PERSISTENT, // Files that are pinned or modified locally,
77 // not evictable, hopefully.
78 CACHE_TYPE_TMP, // Files that don't meet criteria to be in
79 // persistent dir, and hence evictable.
80 CACHE_TYPE_TMP_DOWNLOADS, // Downloaded files.
81 CACHE_TYPE_TMP_DOCUMENTS, // Temporary JSON files for hosted documents.
82 NUM_CACHE_TYPES, // This must be at the end.
83 };
84
[email protected]a321b9632012-06-14 03:29:1785 // Enum defining type of file operation e.g. copy or move, etc.
86 enum FileOperationType {
87 FILE_OPERATION_MOVE = 0,
88 FILE_OPERATION_COPY,
89 };
[email protected]32a7fc852012-06-08 17:25:5090
[email protected]17196ee2012-12-13 06:23:5191 // |cache_root_path| specifies the root directory for the cache. Sub
92 // directories will be created under the root directory.
93 //
94 // |blocking_task_runner| is used to post a task to the blocking worker
95 // pool for file operations. Must not be null.
[email protected]f6fd98a2012-12-14 00:04:0296 //
97 // |free_disk_space_getter| is used to inject a custom free disk space
98 // getter for testing. NULL must be passed for production code.
[email protected]54ba37502013-05-09 08:43:4099 //
100 // Must be called on the UI thread.
[email protected]eca3fc92013-05-01 03:53:40101 FileCache(const base::FilePath& cache_root_path,
[email protected]54ba37502013-05-09 08:43:40102 base::SequencedTaskRunner* blocking_task_runner,
103 FreeDiskSpaceGetterInterface* free_disk_space_getter);
[email protected]17196ee2012-12-13 06:23:51104
[email protected]7bb73e3d2012-09-08 17:41:29105 // Returns the sub-directory under drive cache directory for the given sub
[email protected]32a7fc852012-06-08 17:25:50106 // directory type. Example: <user_profile_dir>/GCache/v1/tmp
[email protected]6b70c7b2012-06-14 03:10:43107 //
108 // Can be called on any thread.
[email protected]650b2d52013-02-10 03:41:45109 base::FilePath GetCacheDirectoryPath(
110 CacheSubDirectoryType sub_dir_type) const;
[email protected]32a7fc852012-06-08 17:25:50111
[email protected]7bb73e3d2012-09-08 17:41:29112 // Returns true if the given path is under drive cache directory, i.e.
[email protected]01ba15f72012-06-09 00:41:05113 // <user_profile_dir>/GCache/v1
[email protected]6b70c7b2012-06-14 03:10:43114 //
115 // Can be called on any thread.
[email protected]eca3fc92013-05-01 03:53:40116 bool IsUnderFileCacheDirectory(const base::FilePath& path) const;
[email protected]01ba15f72012-06-09 00:41:05117
[email protected]73f9c742012-06-15 07:37:13118 // Adds observer.
[email protected]54ba37502013-05-09 08:43:40119 // Must be called on the UI thread.
[email protected]aa7365c2013-05-01 05:50:47120 void AddObserver(FileCacheObserver* observer);
[email protected]73f9c742012-06-15 07:37:13121
122 // Removes observer.
[email protected]54ba37502013-05-09 08:43:40123 // Must be called on the UI thread.
[email protected]aa7365c2013-05-01 05:50:47124 void RemoveObserver(FileCacheObserver* observer);
[email protected]73f9c742012-06-15 07:37:13125
[email protected]77fb1a62012-11-01 13:42:32126 // Gets the cache entry for file corresponding to |resource_id| and |md5|
[email protected]fba59542012-12-18 06:05:38127 // and runs |callback| with true and the entry found if entry exists in cache
[email protected]77fb1a62012-11-01 13:42:32128 // map. Otherwise, runs |callback| with false.
[email protected]b53e8da2013-05-29 07:47:18129 // |md5| can be empty if only matching |resource_id| is desired.
[email protected]bdd947c2012-11-06 04:35:34130 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40131 // Must be called on the UI thread.
132 void GetCacheEntryOnUIThread(const std::string& resource_id,
133 const std::string& md5,
134 const GetCacheEntryCallback& callback);
[email protected]4324fdc2012-06-29 05:32:48135
[email protected]8e38c9db2013-05-10 02:52:29136 // Gets the cache entry by the given resource ID and MD5.
137 // See also GetCacheEntryOnUIThread().
138 bool GetCacheEntry(const std::string& resource_id,
139 const std::string& md5,
140 FileCacheEntry* entry);
141
[email protected]3361a542013-05-22 17:38:27142 // Runs Iterate() with |iteration_callback| on |blocking_task_runner_| and
143 // runs |completion_callback| upon completion.
144 // Must be called on UI thread.
[email protected]54ba37502013-05-09 08:43:40145 void IterateOnUIThread(const CacheIterateCallback& iteration_callback,
146 const base::Closure& completion_callback);
[email protected]cd236432012-07-27 18:03:30147
[email protected]3361a542013-05-22 17:38:27148 // Iterates all files in the cache and calls |iteration_callback| for each
149 // file. |completion_callback| is run upon completion.
150 // TODO(hashimoto): Stop using callbacks for this method. crbug.com/242818
151 void Iterate(const CacheIterateCallback& iteration_callback);
152
[email protected]ec514362013-05-27 17:52:22153
154 // Runs FreeDiskSpaceIfNeededFor() on |blocking_task_runner_|, and calls
155 // |callback| with the result asynchronously.
156 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40157 // Must be called on the UI thread.
158 void FreeDiskSpaceIfNeededForOnUIThread(
159 int64 num_bytes,
160 const InitializeCacheCallback& callback);
[email protected]a321b9632012-06-14 03:29:17161
[email protected]ec514362013-05-27 17:52:22162 // Frees up disk space to store a file with |num_bytes| size content, while
163 // keeping kMinFreeSpace bytes on the disk, if needed.
164 // Returns true if we successfully manage to have enough space, otherwise
165 // false.
166 bool FreeDiskSpaceIfNeededFor(int64 num_bytes);
167
168 // Runs GetFile() on |blocking_task_runner_|, and calls |callback| with
169 // the result asynchronously.
[email protected]bdd947c2012-11-06 04:35:34170 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40171 // Must be called on the UI thread.
172 void GetFileOnUIThread(const std::string& resource_id,
173 const std::string& md5,
174 const GetFileFromCacheCallback& callback);
[email protected]a321b9632012-06-14 03:29:17175
[email protected]ec514362013-05-27 17:52:22176 // Checks if file corresponding to |resource_id| and |md5| exists in cache,
177 // and returns FILE_ERROR_OK with |cache_file_path| storing the path to
178 // the file.
179 // |cache_file_path| must not be null.
180 FileError GetFile(const std::string& resource_id,
181 const std::string& md5,
182 base::FilePath* cache_file_path);
183
[email protected]82c4eb92013-05-21 11:25:23184 // Runs Store() on |blocking_task_runner_|, and calls |callback| with
185 // the result asynchronously.
[email protected]2a2c4152012-11-26 11:34:50186 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40187 // Must be called on the UI thread.
188 void StoreOnUIThread(const std::string& resource_id,
189 const std::string& md5,
190 const base::FilePath& source_path,
191 FileOperationType file_operation_type,
192 const FileOperationCallback& callback);
[email protected]a321b9632012-06-14 03:29:17193
[email protected]82c4eb92013-05-21 11:25:23194 // Stores |source_path| as a cache of the remote content of the file
195 // with |resource_id| and |md5|.
196 FileError Store(const std::string& resource_Id,
197 const std::string& md5,
198 const base::FilePath& source_path,
199 FileOperationType file_operation_type);
200
[email protected]d8546c92013-05-02 05:09:59201 // Stores |source_path| to the cache and mark it as dirty, i.e., needs to be
202 // uploaded to the remove server for syncing.
203 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40204 // Must be called on the UI thread.
205 void StoreLocallyModifiedOnUIThread(const std::string& resource_id,
206 const std::string& md5,
207 const base::FilePath& source_path,
208 FileOperationType file_operation_type,
209 const FileOperationCallback& callback);
[email protected]d8546c92013-05-02 05:09:59210
[email protected]f8b1a532013-06-06 08:35:08211 // Runs Pin() on |blocking_task_runner_|, and calls |callback| with the result
212 // asynchronously.
[email protected]2a2c4152012-11-26 11:34:50213 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40214 // Must be called on the UI thread.
215 void PinOnUIThread(const std::string& resource_id,
216 const std::string& md5,
217 const FileOperationCallback& callback);
[email protected]a321b9632012-06-14 03:29:17218
[email protected]f8b1a532013-06-06 08:35:08219 // Pins the specified entry.
220 FileError Pin(const std::string& resource_id,
221 const std::string& md5);
222
[email protected]ec514362013-05-27 17:52:22223 // Runs Unpin() on |blocking_task_runner_|, and calls |callback| with the
224 // result asynchronously.
[email protected]2a2c4152012-11-26 11:34:50225 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40226 // Must be called on the UI thread.
227 void UnpinOnUIThread(const std::string& resource_id,
228 const std::string& md5,
229 const FileOperationCallback& callback);
[email protected]7986b8d2012-06-14 15:05:14230
[email protected]b53e8da2013-05-29 07:47:18231 // Unpins the specified entry.
[email protected]ec514362013-05-27 17:52:22232 FileError Unpin(const std::string& resource_id, const std::string& md5);
233
[email protected]35c1f9b2013-02-07 07:39:42234 // Sets the state of the cache entry corresponding to |resource_id| and |md5|
235 // as mounted.
[email protected]9564c1502012-11-28 12:12:16236 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40237 // Must be called on the UI thread.
238 void MarkAsMountedOnUIThread(const std::string& resource_id,
239 const std::string& md5,
240 const GetFileFromCacheCallback& callback);
[email protected]9564c1502012-11-28 12:12:16241
242 // Set the state of the cache entry corresponding to file_path as unmounted.
243 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40244 // Must be called on the UI thread.
245 void MarkAsUnmountedOnUIThread(const base::FilePath& file_path,
246 const FileOperationCallback& callback);
[email protected]a321b9632012-06-14 03:29:17247
[email protected]b568b882013-06-10 04:38:07248 // Runs MarkDirty() on |blocking_task_runner_|, and calls |callback| with the
249 // result asynchronously.
[email protected]bdd947c2012-11-06 04:35:34250 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40251 // Must be called on the UI thread.
252 void MarkDirtyOnUIThread(const std::string& resource_id,
253 const std::string& md5,
254 const FileOperationCallback& callback);
[email protected]a321b9632012-06-14 03:29:17255
[email protected]b568b882013-06-10 04:38:07256 // Marks the specified entry dirty.
257 FileError MarkDirty(const std::string& resource_id,
258 const std::string& md5);
259
[email protected]b53e8da2013-05-29 07:47:18260 // Commits changes for the specified dirty entry.
[email protected]2a2c4152012-11-26 11:34:50261 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40262 // Must be called on the UI thread.
263 void CommitDirtyOnUIThread(const std::string& resource_id,
264 const std::string& md5,
265 const FileOperationCallback& callback);
[email protected]a321b9632012-06-14 03:29:17266
[email protected]fcf8eafe02013-05-28 11:15:39267 // Clears dirty state of the specified entry.
268 FileError ClearDirty(const std::string& resource_id,
269 const std::string& md5);
[email protected]a321b9632012-06-14 03:29:17270
[email protected]3361a542013-05-22 17:38:27271 // Runs Remove() on |blocking_task_runner_| and runs |callback| with the
272 // result.
[email protected]54ba37502013-05-09 08:43:40273 // Must be called on the UI thread.
274 void RemoveOnUIThread(const std::string& resource_id,
275 const FileOperationCallback& callback);
[email protected]a321b9632012-06-14 03:29:17276
[email protected]3361a542013-05-22 17:38:27277 // Removes the specified cache entry and delete cache files if available.
278 // Synchronous version of RemoveOnUIThread().
279 FileError Remove(const std::string& resource_id);
280
[email protected]f861b392012-08-03 20:41:12281 // Does the following:
282 // - remove all the files in the cache directory.
283 // - re-create the |metadata_| instance.
[email protected]bdd947c2012-11-06 04:35:34284 // |callback| must not be null.
[email protected]54ba37502013-05-09 08:43:40285 // Must be called on the UI thread.
286 void ClearAllOnUIThread(const InitializeCacheCallback& callback);
[email protected]f861b392012-08-03 20:41:12287
[email protected]322e0032012-10-07 01:55:53288 // Utility method to call Initialize on UI thread. |callback| is called on
289 // UI thread when the initialization is complete.
290 // |callback| must not be null.
[email protected]77fb1a62012-11-01 13:42:32291 void RequestInitialize(const InitializeCacheCallback& callback);
[email protected]73f9c742012-06-15 07:37:13292
[email protected]17196ee2012-12-13 06:23:51293 // Destroys this cache. This function posts a task to the blocking task
294 // runner to safely delete the object.
[email protected]54ba37502013-05-09 08:43:40295 // Must be called on the UI thread.
[email protected]77fb1a62012-11-01 13:42:32296 void Destroy();
[email protected]73f9c742012-06-15 07:37:13297
[email protected]30d9dda2012-06-30 05:56:28298 // Returns file paths for all the cache sub directories under
299 // |cache_root_path|.
[email protected]650b2d52013-02-10 03:41:45300 static std::vector<base::FilePath> GetCachePaths(
301 const base::FilePath& cache_root_path);
[email protected]30d9dda2012-06-30 05:56:28302
303 // Creates cache directory and its sub-directories if they don't exist.
304 // TODO(glotov): take care of this when the setup and cleanup part is
305 // landed, noting that these directories need to be created for development
306 // in linux box and unittest. (http://crosbug.com/27577)
307 static bool CreateCacheDirectories(
[email protected]650b2d52013-02-10 03:41:45308 const std::vector<base::FilePath>& paths_to_create);
[email protected]30d9dda2012-06-30 05:56:28309
[email protected]fae353a2012-07-11 23:30:27310 // Returns the type of the sub directory where the cache file is stored.
311 static CacheSubDirectoryType GetSubDirectoryType(
[email protected]aa7365c2013-05-01 05:50:47312 const FileCacheEntry& cache_entry);
[email protected]fae353a2012-07-11 23:30:27313
[email protected]ca5f6da2012-06-18 12:54:59314 private:
[email protected]eca3fc92013-05-01 03:53:40315 friend class FileCacheTest;
[email protected]f8b1a532013-06-06 08:35:08316 friend class FileCacheTestOnUIThread;
[email protected]e9663392013-04-12 09:55:15317
[email protected]e9663392013-04-12 09:55:15318 // Enum defining origin of a cached file.
319 enum CachedFileOrigin {
320 CACHED_FILE_FROM_SERVER = 0,
321 CACHED_FILE_LOCALLY_MODIFIED,
322 CACHED_FILE_MOUNTED,
323 };
324
[email protected]54ba37502013-05-09 08:43:40325 ~FileCache();
[email protected]fcc92a52012-06-08 22:54:16326
[email protected]e9663392013-04-12 09:55:15327 // Returns absolute path of the file if it were cached or to be cached.
328 //
329 // Can be called on any thread.
330 base::FilePath GetCacheFilePath(const std::string& resource_id,
331 const std::string& md5,
332 CacheSubDirectoryType sub_dir_type,
333 CachedFileOrigin file_origin) const;
334
335
[email protected]fcc92a52012-06-08 22:54:16336 // Checks whether the current thread is on the right sequenced worker pool
337 // with the right sequence ID. If not, DCHECK will fail.
338 void AssertOnSequencedWorkerPool();
[email protected]3653146a2012-05-29 13:41:47339
[email protected]bdd947c2012-11-06 04:35:34340 // Initializes the cache. Returns true on success.
341 bool InitializeOnBlockingPool();
[email protected]73f9c742012-06-15 07:37:13342
[email protected]17196ee2012-12-13 06:23:51343 // Destroys the cache on the blocking pool.
[email protected]77fb1a62012-11-01 13:42:32344 void DestroyOnBlockingPool();
[email protected]73f9c742012-06-15 07:37:13345
[email protected]82c4eb92013-05-21 11:25:23346 // Used to implement Store and StoreLocallyModifiedOnUIThread.
347 // TODO(hidehiko): Merge this method with Store(), after
348 // StoreLocallyModifiedOnUIThread is removed.
349 FileError StoreInternal(const std::string& resource_id,
350 const std::string& md5,
351 const base::FilePath& source_path,
352 FileOperationType file_operation_type,
353 CachedFileOrigin origin);
[email protected]73f9c742012-06-15 07:37:13354
[email protected]54ba37502013-05-09 08:43:40355 // Used to implement MarkAsMountedOnUIThread.
[email protected]7197485b2013-05-23 15:59:34356 FileError MarkAsMounted(const std::string& resource_id,
357 const std::string& md5,
358 base::FilePath* cache_file_path);
[email protected]54ba37502013-05-09 08:43:40359
360 // Used to implement MarkAsUnmountedOnUIThread.
361 FileError MarkAsUnmounted(const base::FilePath& file_path);
362
[email protected]54ba37502013-05-09 08:43:40363 // Used to implement ClearAllOnUIThread.
364 bool ClearAll();
[email protected]f861b392012-08-03 20:41:12365
[email protected]73f9c742012-06-15 07:37:13366 // Runs callback and notifies the observers when file is pinned.
[email protected]bdd947c2012-11-06 04:35:34367 void OnPinned(const std::string& resource_id,
[email protected]73f9c742012-06-15 07:37:13368 const std::string& md5,
[email protected]2a2c4152012-11-26 11:34:50369 const FileOperationCallback& callback,
[email protected]78a158b2013-04-23 06:57:49370 FileError error);
[email protected]73f9c742012-06-15 07:37:13371
372 // Runs callback and notifies the observers when file is unpinned.
[email protected]bdd947c2012-11-06 04:35:34373 void OnUnpinned(const std::string& resource_id,
[email protected]73f9c742012-06-15 07:37:13374 const std::string& md5,
[email protected]2a2c4152012-11-26 11:34:50375 const FileOperationCallback& callback,
[email protected]78a158b2013-04-23 06:57:49376 FileError error);
[email protected]73f9c742012-06-15 07:37:13377
[email protected]d7664c22012-06-18 19:35:49378 // Runs callback and notifies the observers when file is committed.
[email protected]bdd947c2012-11-06 04:35:34379 void OnCommitDirty(const std::string& resource_id,
[email protected]2a2c4152012-11-26 11:34:50380 const FileOperationCallback& callback,
[email protected]78a158b2013-04-23 06:57:49381 FileError error);
[email protected]4324fdc2012-06-29 05:32:48382
[email protected]f6fd98a2012-12-14 00:04:02383 // Returns true if we have sufficient space to store the given number of
384 // bytes, while keeping kMinFreeSpace bytes on the disk.
[email protected]650b2d52013-02-10 03:41:45385 bool HasEnoughSpaceFor(int64 num_bytes, const base::FilePath& path);
[email protected]f6fd98a2012-12-14 00:04:02386
[email protected]01ba15f72012-06-09 00:41:05387 // The root directory of the cache (i.e. <user_profile_dir>/GCache/v1).
[email protected]650b2d52013-02-10 03:41:45388 const base::FilePath cache_root_path_;
[email protected]32a7fc852012-06-08 17:25:50389 // Paths for all subdirectories of GCache, one for each
[email protected]eca3fc92013-05-01 03:53:40390 // FileCache::CacheSubDirectoryType enum.
[email protected]650b2d52013-02-10 03:41:45391 const std::vector<base::FilePath> cache_paths_;
[email protected]ddbf2052012-07-13 15:07:02392 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
[email protected]32a7fc852012-06-08 17:25:50393
[email protected]ca5f6da2012-06-18 12:54:59394 // The cache state data. This member must be access only on the blocking pool.
[email protected]aa7365c2013-05-01 05:50:47395 scoped_ptr<FileCacheMetadata> metadata_;
[email protected]ca5f6da2012-06-18 12:54:59396
[email protected]73f9c742012-06-15 07:37:13397 // List of observers, this member must be accessed on UI thread.
[email protected]aa7365c2013-05-01 05:50:47398 ObserverList<FileCacheObserver> observers_;
[email protected]73f9c742012-06-15 07:37:13399
[email protected]f6fd98a2012-12-14 00:04:02400 FreeDiskSpaceGetterInterface* free_disk_space_getter_; // Not owned.
401
[email protected]e53ac8f2012-08-02 07:05:00402 // Note: This should remain the last member so it'll be destroyed and
403 // invalidate its weak pointers before any other members are destroyed.
[email protected]eca3fc92013-05-01 03:53:40404 base::WeakPtrFactory<FileCache> weak_ptr_factory_;
405 DISALLOW_COPY_AND_ASSIGN(FileCache);
[email protected]3653146a2012-05-29 13:41:47406};
407
[email protected]0d52ed52013-05-01 08:21:21408// The minimum free space to keep. FileSystem::GetFileByPath() returns
[email protected]7f90e77c2012-07-17 09:35:31409// GDATA_FILE_ERROR_NO_SPACE if the available space is smaller than
[email protected]a321b9632012-06-14 03:29:17410// this value.
411//
412// Copied from cryptohome/homedirs.h.
413// TODO(satorux): Share the constant.
414const int64 kMinFreeSpace = 512 * 1LL << 20;
415
[email protected]59c7cdec2013-05-07 04:17:13416} // namespace internal
[email protected]d9d04df2012-10-12 07:06:35417} // namespace drive
[email protected]3653146a2012-05-29 13:41:47418
[email protected]eca3fc92013-05-01 03:53:40419#endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_