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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // Stores |source_path| to the cache and mark it as dirty, i.e., needs to be | 201 // Stores |source_path| to the cache and mark it as dirty, i.e., needs to be |
202 // uploaded to the remove server for syncing. | 202 // uploaded to the remove server for syncing. |
203 // |callback| must not be null. | 203 // |callback| must not be null. |
204 // Must be called on the UI thread. | 204 // Must be called on the UI thread. |
205 void StoreLocallyModifiedOnUIThread(const std::string& resource_id, | 205 void StoreLocallyModifiedOnUIThread(const std::string& resource_id, |
206 const std::string& md5, | 206 const std::string& md5, |
207 const base::FilePath& source_path, | 207 const base::FilePath& source_path, |
208 FileOperationType file_operation_type, | 208 FileOperationType file_operation_type, |
209 const FileOperationCallback& callback); | 209 const FileOperationCallback& callback); |
210 | 210 |
211 // Pins the specified entry. | 211 // Runs Pin() on |blocking_task_runner_|, and calls |callback| with the result |
| 212 // asynchronously. |
212 // |callback| must not be null. | 213 // |callback| must not be null. |
213 // Must be called on the UI thread. | 214 // Must be called on the UI thread. |
214 void PinOnUIThread(const std::string& resource_id, | 215 void PinOnUIThread(const std::string& resource_id, |
215 const std::string& md5, | 216 const std::string& md5, |
216 const FileOperationCallback& callback); | 217 const FileOperationCallback& callback); |
217 | 218 |
| 219 // Pins the specified entry. |
| 220 FileError Pin(const std::string& resource_id, |
| 221 const std::string& md5); |
| 222 |
218 // Runs Unpin() on |blocking_task_runner_|, and calls |callback| with the | 223 // Runs Unpin() on |blocking_task_runner_|, and calls |callback| with the |
219 // result asynchronously. | 224 // result asynchronously. |
220 // |callback| must not be null. | 225 // |callback| must not be null. |
221 // Must be called on the UI thread. | 226 // Must be called on the UI thread. |
222 void UnpinOnUIThread(const std::string& resource_id, | 227 void UnpinOnUIThread(const std::string& resource_id, |
223 const std::string& md5, | 228 const std::string& md5, |
224 const FileOperationCallback& callback); | 229 const FileOperationCallback& callback); |
225 | 230 |
226 // Unpins the specified entry. | 231 // Unpins the specified entry. |
227 FileError Unpin(const std::string& resource_id, const std::string& md5); | 232 FileError Unpin(const std::string& resource_id, const std::string& md5); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // in linux box and unittest. (http://crosbug.com/27577) | 301 // in linux box and unittest. (http://crosbug.com/27577) |
297 static bool CreateCacheDirectories( | 302 static bool CreateCacheDirectories( |
298 const std::vector<base::FilePath>& paths_to_create); | 303 const std::vector<base::FilePath>& paths_to_create); |
299 | 304 |
300 // Returns the type of the sub directory where the cache file is stored. | 305 // Returns the type of the sub directory where the cache file is stored. |
301 static CacheSubDirectoryType GetSubDirectoryType( | 306 static CacheSubDirectoryType GetSubDirectoryType( |
302 const FileCacheEntry& cache_entry); | 307 const FileCacheEntry& cache_entry); |
303 | 308 |
304 private: | 309 private: |
305 friend class FileCacheTest; | 310 friend class FileCacheTest; |
| 311 friend class FileCacheTestOnUIThread; |
306 | 312 |
307 // Enum defining origin of a cached file. | 313 // Enum defining origin of a cached file. |
308 enum CachedFileOrigin { | 314 enum CachedFileOrigin { |
309 CACHED_FILE_FROM_SERVER = 0, | 315 CACHED_FILE_FROM_SERVER = 0, |
310 CACHED_FILE_LOCALLY_MODIFIED, | 316 CACHED_FILE_LOCALLY_MODIFIED, |
311 CACHED_FILE_MOUNTED, | 317 CACHED_FILE_MOUNTED, |
312 }; | 318 }; |
313 | 319 |
314 ~FileCache(); | 320 ~FileCache(); |
315 | 321 |
(...skipping 18 matching lines...) Expand all Loading... |
334 | 340 |
335 // Used to implement Store and StoreLocallyModifiedOnUIThread. | 341 // Used to implement Store and StoreLocallyModifiedOnUIThread. |
336 // TODO(hidehiko): Merge this method with Store(), after | 342 // TODO(hidehiko): Merge this method with Store(), after |
337 // StoreLocallyModifiedOnUIThread is removed. | 343 // StoreLocallyModifiedOnUIThread is removed. |
338 FileError StoreInternal(const std::string& resource_id, | 344 FileError StoreInternal(const std::string& resource_id, |
339 const std::string& md5, | 345 const std::string& md5, |
340 const base::FilePath& source_path, | 346 const base::FilePath& source_path, |
341 FileOperationType file_operation_type, | 347 FileOperationType file_operation_type, |
342 CachedFileOrigin origin); | 348 CachedFileOrigin origin); |
343 | 349 |
344 // Used to implement PinOnUIThread. | |
345 FileError Pin(const std::string& resource_id, | |
346 const std::string& md5); | |
347 | |
348 // Used to implement MarkAsMountedOnUIThread. | 350 // Used to implement MarkAsMountedOnUIThread. |
349 FileError MarkAsMounted(const std::string& resource_id, | 351 FileError MarkAsMounted(const std::string& resource_id, |
350 const std::string& md5, | 352 const std::string& md5, |
351 base::FilePath* cache_file_path); | 353 base::FilePath* cache_file_path); |
352 | 354 |
353 // Used to implement MarkAsUnmountedOnUIThread. | 355 // Used to implement MarkAsUnmountedOnUIThread. |
354 FileError MarkAsUnmounted(const base::FilePath& file_path); | 356 FileError MarkAsUnmounted(const base::FilePath& file_path); |
355 | 357 |
356 // Used to implement MarkDirtyOnUIThread. | 358 // Used to implement MarkDirtyOnUIThread. |
357 FileError MarkDirty(const std::string& resource_id, | 359 FileError MarkDirty(const std::string& resource_id, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // this value. | 409 // this value. |
408 // | 410 // |
409 // Copied from cryptohome/homedirs.h. | 411 // Copied from cryptohome/homedirs.h. |
410 // TODO(satorux): Share the constant. | 412 // TODO(satorux): Share the constant. |
411 const int64 kMinFreeSpace = 512 * 1LL << 20; | 413 const int64 kMinFreeSpace = 512 * 1LL << 20; |
412 | 414 |
413 } // namespace internal | 415 } // namespace internal |
414 } // namespace drive | 416 } // namespace drive |
415 | 417 |
416 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ | 418 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ |
OLD | NEW |