| 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_GDATA_DRIVE_CACHE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_CACHE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_CACHE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_CACHE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 typedef base::Callback<void(const std::vector<std::string>& resource_ids)> | 58 typedef base::Callback<void(const std::vector<std::string>& resource_ids)> |
| 59 GetResourceIdsCallback; | 59 GetResourceIdsCallback; |
| 60 | 60 |
| 61 // Callback for GetCacheEntryOnUIThread. | 61 // Callback for GetCacheEntryOnUIThread. |
| 62 // |success| indicates if the operation was successful. | 62 // |success| indicates if the operation was successful. |
| 63 // |cache_entry| is the obtained cache entry. On failure, |cache_state| is | 63 // |cache_entry| is the obtained cache entry. On failure, |cache_state| is |
| 64 // set to TEST_CACHE_STATE_NONE. | 64 // set to TEST_CACHE_STATE_NONE. |
| 65 typedef base::Callback<void(bool success, const DriveCacheEntry& cache_entry)> | 65 typedef base::Callback<void(bool success, const DriveCacheEntry& cache_entry)> |
| 66 GetCacheEntryCallback; | 66 GetCacheEntryCallback; |
| 67 | 67 |
| 68 // DriveCache is used to maintain cache states of GDataFileSystem. | 68 // DriveCache is used to maintain cache states of DriveFileSystem. |
| 69 // | 69 // |
| 70 // All non-static public member functions, unless mentioned otherwise (see | 70 // All non-static public member functions, unless mentioned otherwise (see |
| 71 // GetCacheFilePath() for example), should be called from the sequenced | 71 // GetCacheFilePath() for example), should be called from the sequenced |
| 72 // worker pool with the sequence token set by CreateDriveCacheOnUIThread(). This | 72 // worker pool with the sequence token set by CreateDriveCacheOnUIThread(). This |
| 73 // threading model is enforced by AssertOnSequencedWorkerPool(). | 73 // threading model is enforced by AssertOnSequencedWorkerPool(). |
| 74 // | 74 // |
| 75 // TODO(hashimoto): Change threading model of this class to make public methods | 75 // TODO(hashimoto): Change threading model of this class to make public methods |
| 76 // being called on UI thread unless mentioned otherwise. crbug.com/132926 | 76 // being called on UI thread unless mentioned otherwise. crbug.com/132926 |
| 77 class DriveCache { | 77 class DriveCache { |
| 78 public: | 78 public: |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // List of observers, this member must be accessed on UI thread. | 449 // List of observers, this member must be accessed on UI thread. |
| 450 ObserverList<Observer> observers_; | 450 ObserverList<Observer> observers_; |
| 451 | 451 |
| 452 // Note: This should remain the last member so it'll be destroyed and | 452 // Note: This should remain the last member so it'll be destroyed and |
| 453 // invalidate its weak pointers before any other members are destroyed. | 453 // invalidate its weak pointers before any other members are destroyed. |
| 454 base::WeakPtrFactory<DriveCache> weak_ptr_factory_; | 454 base::WeakPtrFactory<DriveCache> weak_ptr_factory_; |
| 455 DISALLOW_COPY_AND_ASSIGN(DriveCache); | 455 DISALLOW_COPY_AND_ASSIGN(DriveCache); |
| 456 }; | 456 }; |
| 457 | 457 |
| 458 | 458 |
| 459 // The minimum free space to keep. GDataFileSystem::GetFileByPath() returns | 459 // The minimum free space to keep. DriveFileSystem::GetFileByPath() returns |
| 460 // GDATA_FILE_ERROR_NO_SPACE if the available space is smaller than | 460 // GDATA_FILE_ERROR_NO_SPACE if the available space is smaller than |
| 461 // this value. | 461 // this value. |
| 462 // | 462 // |
| 463 // Copied from cryptohome/homedirs.h. | 463 // Copied from cryptohome/homedirs.h. |
| 464 // TODO(satorux): Share the constant. | 464 // TODO(satorux): Share the constant. |
| 465 const int64 kMinFreeSpace = 512 * 1LL << 20; | 465 const int64 kMinFreeSpace = 512 * 1LL << 20; |
| 466 | 466 |
| 467 // Interface class used for getting the free disk space. Only for testing. | 467 // Interface class used for getting the free disk space. Only for testing. |
| 468 class FreeDiskSpaceGetterInterface { | 468 class FreeDiskSpaceGetterInterface { |
| 469 public: | 469 public: |
| 470 virtual ~FreeDiskSpaceGetterInterface() {} | 470 virtual ~FreeDiskSpaceGetterInterface() {} |
| 471 virtual int64 AmountOfFreeDiskSpace() const = 0; | 471 virtual int64 AmountOfFreeDiskSpace() const = 0; |
| 472 }; | 472 }; |
| 473 | 473 |
| 474 // Sets the free disk space getter for testing. | 474 // Sets the free disk space getter for testing. |
| 475 // The existing getter is deleted. | 475 // The existing getter is deleted. |
| 476 void SetFreeDiskSpaceGetterForTesting( | 476 void SetFreeDiskSpaceGetterForTesting( |
| 477 FreeDiskSpaceGetterInterface* getter); | 477 FreeDiskSpaceGetterInterface* getter); |
| 478 | 478 |
| 479 } // namespace gdata | 479 } // namespace gdata |
| 480 | 480 |
| 481 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_CACHE_H_ | 481 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_CACHE_H_ |
| OLD | NEW |