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 |
433 // List of observers, this member must be accessed on UI thread. | 437 // List of observers, this member must be accessed on UI thread. |
434 ObserverList<Observer> observers_; | 438 ObserverList<Observer> observers_; |
435 | 439 |
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_; | |
439 DISALLOW_COPY_AND_ASSIGN(GDataCache); | 440 DISALLOW_COPY_AND_ASSIGN(GDataCache); |
440 }; | 441 }; |
441 | 442 |
442 | 443 |
443 // The minimum free space to keep. GDataFileSystem::GetFileByPath() returns | 444 // The minimum free space to keep. GDataFileSystem::GetFileByPath() returns |
444 // GDATA_FILE_ERROR_NO_SPACE if the available space is smaller than | 445 // GDATA_FILE_ERROR_NO_SPACE if the available space is smaller than |
445 // this value. | 446 // this value. |
446 // | 447 // |
447 // Copied from cryptohome/homedirs.h. | 448 // Copied from cryptohome/homedirs.h. |
448 // TODO(satorux): Share the constant. | 449 // TODO(satorux): Share the constant. |
449 const int64 kMinFreeSpace = 512 * 1LL << 20; | 450 const int64 kMinFreeSpace = 512 * 1LL << 20; |
450 | 451 |
451 // Interface class used for getting the free disk space. Only for testing. | 452 // Interface class used for getting the free disk space. Only for testing. |
452 class FreeDiskSpaceGetterInterface { | 453 class FreeDiskSpaceGetterInterface { |
453 public: | 454 public: |
454 virtual ~FreeDiskSpaceGetterInterface() {} | 455 virtual ~FreeDiskSpaceGetterInterface() {} |
455 virtual int64 AmountOfFreeDiskSpace() const = 0; | 456 virtual int64 AmountOfFreeDiskSpace() const = 0; |
456 }; | 457 }; |
457 | 458 |
458 // Sets the free disk space getter for testing. | 459 // Sets the free disk space getter for testing. |
459 // The existing getter is deleted. | 460 // The existing getter is deleted. |
460 void SetFreeDiskSpaceGetterForTesting( | 461 void SetFreeDiskSpaceGetterForTesting( |
461 FreeDiskSpaceGetterInterface* getter); | 462 FreeDiskSpaceGetterInterface* getter); |
462 | 463 |
463 } // namespace gdata | 464 } // namespace gdata |
464 | 465 |
465 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ | 466 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ |
OLD | NEW |