Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 // implementation that reports fake free disk space. | 55 // implementation that reports fake free disk space. |
| 56 class FreeDiskSpaceGetterInterface { | 56 class FreeDiskSpaceGetterInterface { |
| 57 public: | 57 public: |
| 58 virtual ~FreeDiskSpaceGetterInterface() {} | 58 virtual ~FreeDiskSpaceGetterInterface() {} |
| 59 virtual int64 AmountOfFreeDiskSpace() = 0; | 59 virtual int64 AmountOfFreeDiskSpace() = 0; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // FileCache is used to maintain cache states of FileSystem. | 62 // FileCache is used to maintain cache states of FileSystem. |
| 63 // | 63 // |
| 64 // All non-static public member functions, unless mentioned otherwise (see | 64 // All non-static public member functions, unless mentioned otherwise (see |
| 65 // GetCacheFilePath() for example), should be called from the UI thread. | 65 // GetCacheFilePath() for example), should be run with |blocking_task_runner|. |
| 66 class FileCache { | 66 class FileCache { |
| 67 public: | 67 public: |
| 68 // Enum defining GCache subdirectory location. | 68 // Enum defining GCache subdirectory location. |
| 69 // This indexes into |FileCache::cache_paths_| vector. | 69 // This indexes into |FileCache::cache_paths_| vector. |
| 70 enum CacheSubDirectoryType { | 70 enum CacheSubDirectoryType { |
| 71 CACHE_TYPE_META = 0, // Downloaded feeds. | 71 CACHE_TYPE_META = 0, // Downloaded feeds. |
| 72 CACHE_TYPE_OUTGOING, // Symlinks to files in persistent or tmp dir to | 72 CACHE_TYPE_OUTGOING, // Symlinks to files in persistent or tmp dir to |
| 73 // be uploaded. | 73 // be uploaded. |
| 74 CACHE_TYPE_PERSISTENT, // Files that are pinned or modified locally, | 74 CACHE_TYPE_PERSISTENT, // Files that are pinned or modified locally, |
| 75 // not evictable, hopefully. | 75 // not evictable, hopefully. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 // |cache_root_path| specifies the root directory for the cache. Sub | 89 // |cache_root_path| specifies the root directory for the cache. Sub |
| 90 // directories will be created under the root directory. | 90 // directories will be created under the root directory. |
| 91 // | 91 // |
| 92 // |blocking_task_runner| is used to post a task to the blocking worker | 92 // |blocking_task_runner| is used to post a task to the blocking worker |
| 93 // pool for file operations. Must not be null. | 93 // pool for file operations. Must not be null. |
| 94 // | 94 // |
| 95 // |free_disk_space_getter| is used to inject a custom free disk space | 95 // |free_disk_space_getter| is used to inject a custom free disk space |
| 96 // getter for testing. NULL must be passed for production code. | 96 // getter for testing. NULL must be passed for production code. |
| 97 // | |
| 98 // Must be called on the UI thread. | |
| 97 FileCache(const base::FilePath& cache_root_path, | 99 FileCache(const base::FilePath& cache_root_path, |
| 98 base::SequencedTaskRunner* blocking_task_runner, | 100 base::SequencedTaskRunner* blocking_task_runner, |
| 99 FreeDiskSpaceGetterInterface* free_disk_space_getter); | 101 FreeDiskSpaceGetterInterface* free_disk_space_getter); |
| 100 | 102 |
| 101 // Returns the sub-directory under drive cache directory for the given sub | 103 // Returns the sub-directory under drive cache directory for the given sub |
| 102 // directory type. Example: <user_profile_dir>/GCache/v1/tmp | 104 // directory type. Example: <user_profile_dir>/GCache/v1/tmp |
| 103 // | 105 // |
| 104 // Can be called on any thread. | 106 // Can be called on any thread. |
| 105 base::FilePath GetCacheDirectoryPath( | 107 base::FilePath GetCacheDirectoryPath( |
| 106 CacheSubDirectoryType sub_dir_type) const; | 108 CacheSubDirectoryType sub_dir_type) const; |
| 107 | 109 |
| 108 // Returns true if the given path is under drive cache directory, i.e. | 110 // Returns true if the given path is under drive cache directory, i.e. |
| 109 // <user_profile_dir>/GCache/v1 | 111 // <user_profile_dir>/GCache/v1 |
| 110 // | 112 // |
| 111 // Can be called on any thread. | 113 // Can be called on any thread. |
| 112 bool IsUnderFileCacheDirectory(const base::FilePath& path) const; | 114 bool IsUnderFileCacheDirectory(const base::FilePath& path) const; |
| 113 | 115 |
| 114 // Adds observer. | 116 // Adds observer. |
| 117 // Must be called on the UI thread. | |
| 115 void AddObserver(FileCacheObserver* observer); | 118 void AddObserver(FileCacheObserver* observer); |
| 116 | 119 |
| 117 // Removes observer. | 120 // Removes observer. |
| 121 // Must be called on the UI thread. | |
| 118 void RemoveObserver(FileCacheObserver* observer); | 122 void RemoveObserver(FileCacheObserver* observer); |
| 119 | 123 |
| 120 // Gets the cache entry for file corresponding to |resource_id| and |md5| | 124 // Gets the cache entry for file corresponding to |resource_id| and |md5| |
| 121 // and runs |callback| with true and the entry found if entry exists in cache | 125 // and runs |callback| with true and the entry found if entry exists in cache |
| 122 // map. Otherwise, runs |callback| with false. | 126 // map. Otherwise, runs |callback| with false. |
| 123 // |md5| can be empty if only matching |resource_id| is desired, which may | 127 // |md5| can be empty if only matching |resource_id| is desired, which may |
| 124 // happen when looking for pinned entries where symlinks' filenames have no | 128 // happen when looking for pinned entries where symlinks' filenames have no |
| 125 // extension and hence no md5. | 129 // extension and hence no md5. |
| 126 // |callback| must not be null. | 130 // |callback| must not be null. |
| 127 void GetCacheEntry(const std::string& resource_id, | 131 // Must be called on the UI thread. |
| 128 const std::string& md5, | 132 void GetCacheEntryOnUIThread(const std::string& resource_id, |
| 129 const GetCacheEntryCallback& callback); | 133 const std::string& md5, |
| 134 const GetCacheEntryCallback& callback); | |
| 130 | 135 |
| 131 // Iterates all files in the cache and calls |iteration_callback| for each | 136 // Iterates all files in the cache and calls |iteration_callback| for each |
| 132 // file. |completion_callback| is run upon completion. | 137 // file. |completion_callback| is run upon completion. |
| 133 void Iterate(const CacheIterateCallback& iteration_callback, | 138 // Must be called on the UI thread. |
| 134 const base::Closure& completion_callback); | 139 void IterateOnUIThread(const CacheIterateCallback& iteration_callback, |
| 140 const base::Closure& completion_callback); | |
| 135 | 141 |
| 136 // Frees up disk space to store the given number of bytes, while keeping | 142 // Frees up disk space to store the given number of bytes, while keeping |
| 137 // kMinFreeSpace bytes on the disk, if needed. | 143 // kMinFreeSpace bytes on the disk, if needed. |
| 138 // Runs |callback| with true when we successfully manage to have enough space. | 144 // Runs |callback| with true when we successfully manage to have enough space. |
| 139 void FreeDiskSpaceIfNeededFor(int64 num_bytes, | 145 // Must be called on the UI thread. |
| 140 const InitializeCacheCallback& callback); | 146 void FreeDiskSpaceIfNeededForOnUIThread( |
| 147 int64 num_bytes, | |
| 148 const InitializeCacheCallback& callback); | |
| 141 | 149 |
| 142 // Checks if file corresponding to |resource_id| and |md5| exists in cache. | 150 // Checks if file corresponding to |resource_id| and |md5| exists in cache. |
| 143 // |callback| must not be null. | 151 // |callback| must not be null. |
| 144 void GetFile(const std::string& resource_id, | 152 // Must be called on the UI thread. |
| 145 const std::string& md5, | 153 void GetFileOnUIThread(const std::string& resource_id, |
| 146 const GetFileFromCacheCallback& callback); | 154 const std::string& md5, |
| 155 const GetFileFromCacheCallback& callback); | |
| 147 | 156 |
| 148 // Stores |source_path| as a cache of the remote content of the file | 157 // Stores |source_path| as a cache of the remote content of the file |
| 149 // identified by |resource_id| and |md5|. | 158 // identified by |resource_id| and |md5|. |
| 150 // |callback| must not be null. | 159 // |callback| must not be null. |
| 151 void Store(const std::string& resource_id, | 160 // Must be called on the UI thread. |
| 152 const std::string& md5, | 161 void StoreOnUIThread(const std::string& resource_id, |
| 153 const base::FilePath& source_path, | 162 const std::string& md5, |
| 154 FileOperationType file_operation_type, | 163 const base::FilePath& source_path, |
| 155 const FileOperationCallback& callback); | 164 FileOperationType file_operation_type, |
| 165 const FileOperationCallback& callback); | |
| 156 | 166 |
| 157 // Stores |source_path| to the cache and mark it as dirty, i.e., needs to be | 167 // Stores |source_path| to the cache and mark it as dirty, i.e., needs to be |
| 158 // uploaded to the remove server for syncing. | 168 // uploaded to the remove server for syncing. |
| 159 // |callback| must not be null. | 169 // |callback| must not be null. |
| 160 void StoreLocallyModified(const std::string& resource_id, | 170 // Must be called on the UI thread. |
| 161 const std::string& md5, | 171 void StoreLocallyModifiedOnUIThread(const std::string& resource_id, |
| 162 const base::FilePath& source_path, | 172 const std::string& md5, |
| 163 FileOperationType file_operation_type, | 173 const base::FilePath& source_path, |
| 164 const FileOperationCallback& callback); | 174 FileOperationType file_operation_type, |
| 175 const FileOperationCallback& callback); | |
| 165 | 176 |
| 166 // Modifies cache state, which involves the following: | 177 // Modifies cache state, which involves the following: |
| 167 // - moves |source_path| to |dest_path| in persistent dir if | 178 // - moves |source_path| to |dest_path| in persistent dir if |
| 168 // file is not dirty | 179 // file is not dirty |
| 169 // - creates symlink in pinned dir that references downloaded or locally | 180 // - creates symlink in pinned dir that references downloaded or locally |
| 170 // modified file | 181 // modified file |
| 171 // |callback| must not be null. | 182 // |callback| must not be null. |
| 172 void Pin(const std::string& resource_id, | 183 // Must be called on the UI thread. |
| 173 const std::string& md5, | 184 void PinOnUIThread(const std::string& resource_id, |
| 174 const FileOperationCallback& callback); | 185 const std::string& md5, |
| 186 const FileOperationCallback& callback); | |
| 175 | 187 |
| 176 // Modifies cache state, which involves the following: | 188 // Modifies cache state, which involves the following: |
| 177 // - moves |source_path| to |dest_path| in tmp dir if file is not dirty | 189 // - moves |source_path| to |dest_path| in tmp dir if file is not dirty |
| 178 // - deletes symlink from pinned dir | 190 // - deletes symlink from pinned dir |
| 179 // |callback| must not be null. | 191 // |callback| must not be null. |
| 180 void Unpin(const std::string& resource_id, | 192 // Must be called on the UI thread. |
| 181 const std::string& md5, | 193 void UnpinOnUIThread(const std::string& resource_id, |
| 182 const FileOperationCallback& callback); | 194 const std::string& md5, |
| 195 const FileOperationCallback& callback); | |
| 183 | 196 |
| 184 // Sets the state of the cache entry corresponding to |resource_id| and |md5| | 197 // Sets the state of the cache entry corresponding to |resource_id| and |md5| |
| 185 // as mounted. | 198 // as mounted. |
| 186 // |callback| must not be null. | 199 // |callback| must not be null. |
| 187 void MarkAsMounted(const std::string& resource_id, | 200 // Must be called on the UI thread. |
| 188 const std::string& md5, | 201 void MarkAsMountedOnUIThread(const std::string& resource_id, |
| 189 const GetFileFromCacheCallback& callback); | 202 const std::string& md5, |
| 203 const GetFileFromCacheCallback& callback); | |
| 190 | 204 |
| 191 // Set the state of the cache entry corresponding to file_path as unmounted. | 205 // Set the state of the cache entry corresponding to file_path as unmounted. |
| 192 // |callback| must not be null. | 206 // |callback| must not be null. |
| 193 void MarkAsUnmounted(const base::FilePath& file_path, | 207 // Must be called on the UI thread. |
| 194 const FileOperationCallback& callback); | 208 void MarkAsUnmountedOnUIThread(const base::FilePath& file_path, |
| 209 const FileOperationCallback& callback); | |
| 195 | 210 |
| 196 // Modifies cache state, which involves the following: | 211 // Modifies cache state, which involves the following: |
| 197 // - moves |source_path| to |dest_path| in persistent dir, where | 212 // - moves |source_path| to |dest_path| in persistent dir, where |
| 198 // |source_path| has .<md5> extension and |dest_path| has .local extension | 213 // |source_path| has .<md5> extension and |dest_path| has .local extension |
| 199 // - if file is pinned, updates symlink in pinned dir to reference dirty file | 214 // - if file is pinned, updates symlink in pinned dir to reference dirty file |
| 200 // |callback| must not be null. | 215 // |callback| must not be null. |
| 201 void MarkDirty(const std::string& resource_id, | 216 // Must be called on the UI thread. |
| 202 const std::string& md5, | 217 void MarkDirtyOnUIThread(const std::string& resource_id, |
| 203 const FileOperationCallback& callback); | 218 const std::string& md5, |
| 219 const FileOperationCallback& callback); | |
| 204 | 220 |
| 205 // Modifies cache state, i.e. creates symlink in outgoing | 221 // Modifies cache state, i.e. creates symlink in outgoing |
| 206 // dir to reference dirty file in persistent dir. | 222 // dir to reference dirty file in persistent dir. |
| 207 // |callback| must not be null. | 223 // |callback| must not be null. |
| 208 void CommitDirty(const std::string& resource_id, | 224 // Must be called on the UI thread. |
| 209 const std::string& md5, | 225 void CommitDirtyOnUIThread(const std::string& resource_id, |
| 210 const FileOperationCallback& callback); | 226 const std::string& md5, |
| 227 const FileOperationCallback& callback); | |
| 211 | 228 |
| 212 // Modifies cache state, which involves the following: | 229 // Modifies cache state, which involves the following: |
| 213 // - moves |source_path| to |dest_path| in persistent dir if | 230 // - moves |source_path| to |dest_path| in persistent dir if |
| 214 // file is pinned or tmp dir otherwise, where |source_path| has .local | 231 // file is pinned or tmp dir otherwise, where |source_path| has .local |
| 215 // extension and |dest_path| has .<md5> extension | 232 // extension and |dest_path| has .<md5> extension |
| 216 // - deletes symlink in outgoing dir | 233 // - deletes symlink in outgoing dir |
| 217 // - if file is pinned, updates symlink in pinned dir to reference | 234 // - if file is pinned, updates symlink in pinned dir to reference |
| 218 // |dest_path| | 235 // |dest_path| |
| 219 // |callback| must not be null. | 236 // |callback| must not be null. |
| 220 void ClearDirty(const std::string& resource_id, | 237 // Must be called on the UI thread. |
| 221 const std::string& md5, | 238 void ClearDirtyOnUIThread(const std::string& resource_id, |
| 222 const FileOperationCallback& callback); | 239 const std::string& md5, |
| 240 const FileOperationCallback& callback); | |
| 223 | 241 |
| 224 // Does the following: | 242 // Does the following: |
| 225 // - remove all delete stale cache versions corresponding to |resource_id| in | 243 // - remove all delete stale cache versions corresponding to |resource_id| in |
| 226 // persistent, tmp and pinned directories | 244 // persistent, tmp and pinned directories |
| 227 // - remove entry corresponding to |resource_id| from cache map. | 245 // - remove entry corresponding to |resource_id| from cache map. |
| 228 // |callback| must not be null. | 246 // |callback| must not be null. |
| 229 void Remove(const std::string& resource_id, | 247 // Must be called on the UI thread. |
| 230 const FileOperationCallback& callback); | 248 void RemoveOnUIThread(const std::string& resource_id, |
| 249 const FileOperationCallback& callback); | |
| 231 | 250 |
| 232 // Does the following: | 251 // Does the following: |
| 233 // - remove all the files in the cache directory. | 252 // - remove all the files in the cache directory. |
| 234 // - re-create the |metadata_| instance. | 253 // - re-create the |metadata_| instance. |
| 235 // |callback| must not be null. | 254 // |callback| must not be null. |
| 236 void ClearAll(const InitializeCacheCallback& callback); | 255 // Must be called on the UI thread. |
| 256 void ClearAllOnUIThread(const InitializeCacheCallback& callback); | |
| 237 | 257 |
| 238 // Utility method to call Initialize on UI thread. |callback| is called on | 258 // Utility method to call Initialize on UI thread. |callback| is called on |
| 239 // UI thread when the initialization is complete. | 259 // UI thread when the initialization is complete. |
| 240 // |callback| must not be null. | 260 // |callback| must not be null. |
| 241 void RequestInitialize(const InitializeCacheCallback& callback); | 261 void RequestInitialize(const InitializeCacheCallback& callback); |
| 242 | 262 |
| 243 // Utility method to call InitializeForTesting on UI thread. | 263 // Utility method to call InitializeForTesting on UI thread. |
| 244 void RequestInitializeForTesting(); | 264 void RequestInitializeForTesting(); |
| 245 | 265 |
| 246 // Destroys this cache. This function posts a task to the blocking task | 266 // Destroys this cache. This function posts a task to the blocking task |
| 247 // runner to safely delete the object. | 267 // runner to safely delete the object. |
| 268 // Must be called on the UI thread. | |
| 248 void Destroy(); | 269 void Destroy(); |
| 249 | 270 |
| 250 // Returns file paths for all the cache sub directories under | 271 // Returns file paths for all the cache sub directories under |
| 251 // |cache_root_path|. | 272 // |cache_root_path|. |
| 252 static std::vector<base::FilePath> GetCachePaths( | 273 static std::vector<base::FilePath> GetCachePaths( |
| 253 const base::FilePath& cache_root_path); | 274 const base::FilePath& cache_root_path); |
| 254 | 275 |
| 255 // Creates cache directory and its sub-directories if they don't exist. | 276 // Creates cache directory and its sub-directories if they don't exist. |
| 256 // TODO(glotov): take care of this when the setup and cleanup part is | 277 // TODO(glotov): take care of this when the setup and cleanup part is |
| 257 // landed, noting that these directories need to be created for development | 278 // landed, noting that these directories need to be created for development |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 268 | 289 |
| 269 typedef std::pair<FileError, base::FilePath> GetFileResult; | 290 typedef std::pair<FileError, base::FilePath> GetFileResult; |
| 270 | 291 |
| 271 // Enum defining origin of a cached file. | 292 // Enum defining origin of a cached file. |
| 272 enum CachedFileOrigin { | 293 enum CachedFileOrigin { |
| 273 CACHED_FILE_FROM_SERVER = 0, | 294 CACHED_FILE_FROM_SERVER = 0, |
| 274 CACHED_FILE_LOCALLY_MODIFIED, | 295 CACHED_FILE_LOCALLY_MODIFIED, |
| 275 CACHED_FILE_MOUNTED, | 296 CACHED_FILE_MOUNTED, |
| 276 }; | 297 }; |
| 277 | 298 |
| 278 virtual ~FileCache(); | 299 virtual ~FileCache(); |
|
hidehiko
2013/05/09 06:41:04
off topic nit: s/virtual//
hashimoto
2013/05/09 07:13:44
Done.
| |
| 279 | 300 |
| 280 // Returns absolute path of the file if it were cached or to be cached. | 301 // Returns absolute path of the file if it were cached or to be cached. |
| 281 // | 302 // |
| 282 // Can be called on any thread. | 303 // Can be called on any thread. |
| 283 base::FilePath GetCacheFilePath(const std::string& resource_id, | 304 base::FilePath GetCacheFilePath(const std::string& resource_id, |
| 284 const std::string& md5, | 305 const std::string& md5, |
| 285 CacheSubDirectoryType sub_dir_type, | 306 CacheSubDirectoryType sub_dir_type, |
| 286 CachedFileOrigin file_origin) const; | 307 CachedFileOrigin file_origin) const; |
| 287 | 308 |
| 288 | 309 |
| 289 // Checks whether the current thread is on the right sequenced worker pool | 310 // Checks whether the current thread is on the right sequenced worker pool |
| 290 // with the right sequence ID. If not, DCHECK will fail. | 311 // with the right sequence ID. If not, DCHECK will fail. |
| 291 void AssertOnSequencedWorkerPool(); | 312 void AssertOnSequencedWorkerPool(); |
| 292 | 313 |
| 293 // Initializes the cache. Returns true on success. | 314 // Initializes the cache. Returns true on success. |
| 294 bool InitializeOnBlockingPool(); | 315 bool InitializeOnBlockingPool(); |
| 295 | 316 |
| 296 // Initializes the cache with in-memory cache for testing. | 317 // Initializes the cache with in-memory cache for testing. |
| 297 // The in-memory cache is used since it's faster than the db. | 318 // The in-memory cache is used since it's faster than the db. |
| 298 void InitializeOnBlockingPoolForTesting(); | 319 void InitializeOnBlockingPoolForTesting(); |
| 299 | 320 |
| 300 // Destroys the cache on the blocking pool. | 321 // Destroys the cache on the blocking pool. |
| 301 void DestroyOnBlockingPool(); | 322 void DestroyOnBlockingPool(); |
| 302 | 323 |
| 303 // Gets the cache entry by the given resource ID and MD5. | 324 // Gets the cache entry by the given resource ID and MD5. |
| 304 // See also GetCacheEntry(). | 325 // See also GetCacheEntryOnUIThread(). |
| 305 bool GetCacheEntryOnBlockingPool(const std::string& resource_id, | 326 bool GetCacheEntry(const std::string& resource_id, |
| 306 const std::string& md5, | 327 const std::string& md5, |
| 307 FileCacheEntry* entry); | 328 FileCacheEntry* entry); |
| 308 | 329 |
| 309 // Used to implement Iterate(). | 330 // Used to implement IterateOnUIThread(). |
| 310 void IterateOnBlockingPool(const CacheIterateCallback& iteration_callback); | 331 void Iterate(const CacheIterateCallback& iteration_callback); |
| 311 | 332 |
| 312 // Used to implement FreeDiskSpaceIfNeededFor(). | 333 // Used to implement FreeDiskSpaceIfNeededForOnUIThread(). |
| 313 bool FreeDiskSpaceOnBlockingPoolIfNeededFor(int64 num_bytes); | 334 bool FreeDiskSpaceIfNeededFor(int64 num_bytes); |
| 314 | 335 |
| 315 // Used to implement GetFile. | 336 // Used to implement GetFileOnUIThread. |
| 316 scoped_ptr<GetFileResult> GetFileOnBlockingPool( | 337 scoped_ptr<GetFileResult> GetFile(const std::string& resource_id, |
| 317 const std::string& resource_id, | |
| 318 const std::string& md5); | |
| 319 | |
| 320 // Used to implement Store. | |
| 321 FileError StoreOnBlockingPool(const std::string& resource_id, | |
| 322 const std::string& md5, | |
| 323 const base::FilePath& source_path, | |
| 324 FileOperationType file_operation_type, | |
| 325 CachedFileOrigin origin); | |
| 326 | |
| 327 // Used to implement Pin. | |
| 328 FileError PinOnBlockingPool(const std::string& resource_id, | |
| 329 const std::string& md5); | |
| 330 | |
| 331 // Used to implement Unpin. | |
| 332 FileError UnpinOnBlockingPool(const std::string& resource_id, | |
| 333 const std::string& md5); | |
| 334 | |
| 335 // Used to implement MarkAsMounted. | |
| 336 scoped_ptr<GetFileResult> MarkAsMountedOnBlockingPool( | |
| 337 const std::string& resource_id, | |
| 338 const std::string& md5); | |
| 339 | |
| 340 // Used to implement MarkAsUnmounted. | |
| 341 FileError MarkAsUnmountedOnBlockingPool(const base::FilePath& file_path); | |
| 342 | |
| 343 // Used to implement MarkDirty. | |
| 344 FileError MarkDirtyOnBlockingPool(const std::string& resource_id, | |
| 345 const std::string& md5); | 338 const std::string& md5); |
| 346 | 339 |
| 347 // Used to implement CommitDirty. | 340 // Used to implement StoreOnUIThread. |
| 348 FileError CommitDirtyOnBlockingPool(const std::string& resource_id, | 341 FileError Store(const std::string& resource_id, |
| 349 const std::string& md5); | 342 const std::string& md5, |
| 343 const base::FilePath& source_path, | |
| 344 FileOperationType file_operation_type, | |
| 345 CachedFileOrigin origin); | |
| 350 | 346 |
| 351 // Used to implement ClearDirty. | 347 // Used to implement PinOnUIThread. |
| 352 FileError ClearDirtyOnBlockingPool(const std::string& resource_id, | 348 FileError Pin(const std::string& resource_id, |
| 353 const std::string& md5); | 349 const std::string& md5); |
| 354 | 350 |
| 355 // Used to implement Remove. | 351 // Used to implement UnpinOnUIThread. |
| 356 FileError RemoveOnBlockingPool(const std::string& resource_id); | 352 FileError Unpin(const std::string& resource_id, |
| 353 const std::string& md5); | |
| 357 | 354 |
| 358 // Used to implement ClearAll. | 355 // Used to implement MarkAsMountedOnUIThread. |
| 359 bool ClearAllOnBlockingPool(); | 356 scoped_ptr<GetFileResult> MarkAsMounted(const std::string& resource_id, |
| 357 const std::string& md5); | |
| 358 | |
| 359 // Used to implement MarkAsUnmountedOnUIThread. | |
| 360 FileError MarkAsUnmounted(const base::FilePath& file_path); | |
| 361 | |
| 362 // Used to implement MarkDirtyOnUIThread. | |
| 363 FileError MarkDirty(const std::string& resource_id, | |
| 364 const std::string& md5); | |
| 365 | |
| 366 // Used to implement CommitDirtyOnUIThread. | |
| 367 FileError CommitDirty(const std::string& resource_id, | |
| 368 const std::string& md5); | |
| 369 | |
| 370 // Used to implement ClearDirtyOnUIThread. | |
| 371 FileError ClearDirty(const std::string& resource_id, | |
| 372 const std::string& md5); | |
| 373 | |
| 374 // Used to implement RemoveOnUIThread. | |
| 375 FileError Remove(const std::string& resource_id); | |
| 376 | |
| 377 // Used to implement ClearAllOnUIThread. | |
| 378 bool ClearAll(); | |
| 360 | 379 |
| 361 // Runs callback and notifies the observers when file is pinned. | 380 // Runs callback and notifies the observers when file is pinned. |
| 362 void OnPinned(const std::string& resource_id, | 381 void OnPinned(const std::string& resource_id, |
| 363 const std::string& md5, | 382 const std::string& md5, |
| 364 const FileOperationCallback& callback, | 383 const FileOperationCallback& callback, |
| 365 FileError error); | 384 FileError error); |
| 366 | 385 |
| 367 // Runs callback and notifies the observers when file is unpinned. | 386 // Runs callback and notifies the observers when file is unpinned. |
| 368 void OnUnpinned(const std::string& resource_id, | 387 void OnUnpinned(const std::string& resource_id, |
| 369 const std::string& md5, | 388 const std::string& md5, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 // this value. | 424 // this value. |
| 406 // | 425 // |
| 407 // Copied from cryptohome/homedirs.h. | 426 // Copied from cryptohome/homedirs.h. |
| 408 // TODO(satorux): Share the constant. | 427 // TODO(satorux): Share the constant. |
| 409 const int64 kMinFreeSpace = 512 * 1LL << 20; | 428 const int64 kMinFreeSpace = 512 * 1LL << 20; |
| 410 | 429 |
| 411 } // namespace internal | 430 } // namespace internal |
| 412 } // namespace drive | 431 } // namespace drive |
| 413 | 432 |
| 414 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ | 433 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ |
| OLD | NEW |