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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 // The root directory of the cache (i.e. <user_profile_dir>/GCache/v1). | 423 // The root directory of the cache (i.e. <user_profile_dir>/GCache/v1). |
424 const FilePath cache_root_path_; | 424 const FilePath cache_root_path_; |
425 // Paths for all subdirectories of GCache, one for each | 425 // Paths for all subdirectories of GCache, one for each |
426 // GDataCache::CacheSubDirectoryType enum. | 426 // GDataCache::CacheSubDirectoryType enum. |
427 const std::vector<FilePath> cache_paths_; | 427 const std::vector<FilePath> cache_paths_; |
428 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 428 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
429 | 429 |
430 // The cache state data. This member must be access only on the blocking pool. | 430 // The cache state data. This member must be access only on the blocking pool. |
431 scoped_ptr<GDataCacheMetadata> metadata_; | 431 scoped_ptr<GDataCacheMetadata> metadata_; |
432 | 432 |
433 // WeakPtrFactory and WeakPtr bound to the UI thread. | |
434 base::WeakPtrFactory<GDataCache> ui_weak_ptr_factory_; | |
435 base::WeakPtr<GDataCache> ui_weak_ptr_; | |
436 | |
437 // List of observers, this member must be accessed on UI thread. | 433 // List of observers, this member must be accessed on UI thread. |
438 ObserverList<Observer> observers_; | 434 ObserverList<Observer> observers_; |
439 | 435 |
| 436 // Note: This should remain the last member so it'll be destroyed and |
| 437 // invalidate its weak pointers before any other members are destroyed. |
| 438 base::WeakPtrFactory<GDataCache> weak_ptr_factory_; |
440 DISALLOW_COPY_AND_ASSIGN(GDataCache); | 439 DISALLOW_COPY_AND_ASSIGN(GDataCache); |
441 }; | 440 }; |
442 | 441 |
443 | 442 |
444 // The minimum free space to keep. GDataFileSystem::GetFileByPath() returns | 443 // The minimum free space to keep. GDataFileSystem::GetFileByPath() returns |
445 // GDATA_FILE_ERROR_NO_SPACE if the available space is smaller than | 444 // GDATA_FILE_ERROR_NO_SPACE if the available space is smaller than |
446 // this value. | 445 // this value. |
447 // | 446 // |
448 // Copied from cryptohome/homedirs.h. | 447 // Copied from cryptohome/homedirs.h. |
449 // TODO(satorux): Share the constant. | 448 // TODO(satorux): Share the constant. |
450 const int64 kMinFreeSpace = 512 * 1LL << 20; | 449 const int64 kMinFreeSpace = 512 * 1LL << 20; |
451 | 450 |
452 // Interface class used for getting the free disk space. Only for testing. | 451 // Interface class used for getting the free disk space. Only for testing. |
453 class FreeDiskSpaceGetterInterface { | 452 class FreeDiskSpaceGetterInterface { |
454 public: | 453 public: |
455 virtual ~FreeDiskSpaceGetterInterface() {} | 454 virtual ~FreeDiskSpaceGetterInterface() {} |
456 virtual int64 AmountOfFreeDiskSpace() const = 0; | 455 virtual int64 AmountOfFreeDiskSpace() const = 0; |
457 }; | 456 }; |
458 | 457 |
459 // Sets the free disk space getter for testing. | 458 // Sets the free disk space getter for testing. |
460 // The existing getter is deleted. | 459 // The existing getter is deleted. |
461 void SetFreeDiskSpaceGetterForTesting( | 460 void SetFreeDiskSpaceGetterForTesting( |
462 FreeDiskSpaceGetterInterface* getter); | 461 FreeDiskSpaceGetterInterface* getter); |
463 | 462 |
464 } // namespace gdata | 463 } // namespace gdata |
465 | 464 |
466 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ | 465 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ |
OLD | NEW |