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_GDATA_CACHE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 // TODO(glotov): take care of this when the setup and cleanup part is | 310 // TODO(glotov): take care of this when the setup and cleanup part is |
311 // landed, noting that these directories need to be created for development | 311 // landed, noting that these directories need to be created for development |
312 // in linux box and unittest. (http://crosbug.com/27577) | 312 // in linux box and unittest. (http://crosbug.com/27577) |
313 static bool CreateCacheDirectories( | 313 static bool CreateCacheDirectories( |
314 const std::vector<FilePath>& paths_to_create); | 314 const std::vector<FilePath>& paths_to_create); |
315 | 315 |
316 // Returns the type of the sub directory where the cache file is stored. | 316 // Returns the type of the sub directory where the cache file is stored. |
317 static CacheSubDirectoryType GetSubDirectoryType( | 317 static CacheSubDirectoryType GetSubDirectoryType( |
318 const GDataCacheEntry& cache_entry); | 318 const GDataCacheEntry& cache_entry); |
319 | 319 |
320 // Force std::map implementaition for metadata. | |
achuithb
2012/08/06 23:22:20
spelling - implementation.
You could also add a p
satorux1
2012/08/07 10:50:08
Yes, Ordering is nasty. Maybe we should add Reques
Haruki Sato
2012/08/08 05:00:42
Thank you for the advice!
Removed the flag and add
| |
321 // Must be called before Initialization. | |
322 // Used for testing. | |
323 void ForceMetadataMapForTesting(); | |
324 | |
320 private: | 325 private: |
321 GDataCache(const FilePath& cache_root_path, | 326 GDataCache(const FilePath& cache_root_path, |
322 base::SequencedTaskRunner* blocking_task_runner); | 327 base::SequencedTaskRunner* blocking_task_runner); |
323 virtual ~GDataCache(); | 328 virtual ~GDataCache(); |
324 | 329 |
325 // Checks whether the current thread is on the right sequenced worker pool | 330 // Checks whether the current thread is on the right sequenced worker pool |
326 // with the right sequence ID. If not, DCHECK will fail. | 331 // with the right sequence ID. If not, DCHECK will fail. |
327 void AssertOnSequencedWorkerPool(); | 332 void AssertOnSequencedWorkerPool(); |
328 | 333 |
329 // Initializes the cache. | 334 // Initializes the cache. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 // The cache state data. This member must be access only on the blocking pool. | 444 // The cache state data. This member must be access only on the blocking pool. |
440 scoped_ptr<GDataCacheMetadata> metadata_; | 445 scoped_ptr<GDataCacheMetadata> metadata_; |
441 | 446 |
442 // List of observers, this member must be accessed on UI thread. | 447 // List of observers, this member must be accessed on UI thread. |
443 ObserverList<Observer> observers_; | 448 ObserverList<Observer> observers_; |
444 | 449 |
445 // Note: This should remain the last member so it'll be destroyed and | 450 // Note: This should remain the last member so it'll be destroyed and |
446 // invalidate its weak pointers before any other members are destroyed. | 451 // invalidate its weak pointers before any other members are destroyed. |
447 base::WeakPtrFactory<GDataCache> weak_ptr_factory_; | 452 base::WeakPtrFactory<GDataCache> weak_ptr_factory_; |
448 DISALLOW_COPY_AND_ASSIGN(GDataCache); | 453 DISALLOW_COPY_AND_ASSIGN(GDataCache); |
454 | |
455 // Set to true when std::map cache implementation is desired. | |
456 // Used by tests. | |
457 bool force_metadata_map_for_testing_; | |
449 }; | 458 }; |
450 | 459 |
451 | 460 |
452 // The minimum free space to keep. GDataFileSystem::GetFileByPath() returns | 461 // The minimum free space to keep. GDataFileSystem::GetFileByPath() returns |
453 // GDATA_FILE_ERROR_NO_SPACE if the available space is smaller than | 462 // GDATA_FILE_ERROR_NO_SPACE if the available space is smaller than |
454 // this value. | 463 // this value. |
455 // | 464 // |
456 // Copied from cryptohome/homedirs.h. | 465 // Copied from cryptohome/homedirs.h. |
457 // TODO(satorux): Share the constant. | 466 // TODO(satorux): Share the constant. |
458 const int64 kMinFreeSpace = 512 * 1LL << 20; | 467 const int64 kMinFreeSpace = 512 * 1LL << 20; |
459 | 468 |
460 // Interface class used for getting the free disk space. Only for testing. | 469 // Interface class used for getting the free disk space. Only for testing. |
461 class FreeDiskSpaceGetterInterface { | 470 class FreeDiskSpaceGetterInterface { |
462 public: | 471 public: |
463 virtual ~FreeDiskSpaceGetterInterface() {} | 472 virtual ~FreeDiskSpaceGetterInterface() {} |
464 virtual int64 AmountOfFreeDiskSpace() const = 0; | 473 virtual int64 AmountOfFreeDiskSpace() const = 0; |
465 }; | 474 }; |
466 | 475 |
467 // Sets the free disk space getter for testing. | 476 // Sets the free disk space getter for testing. |
468 // The existing getter is deleted. | 477 // The existing getter is deleted. |
469 void SetFreeDiskSpaceGetterForTesting( | 478 void SetFreeDiskSpaceGetterForTesting( |
470 FreeDiskSpaceGetterInterface* getter); | 479 FreeDiskSpaceGetterInterface* getter); |
471 | 480 |
472 } // namespace gdata | 481 } // namespace gdata |
473 | 482 |
474 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ | 483 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ |
OLD | NEW |