| Index: chrome/browser/chromeos/gdata/gdata_cache.h
|
| diff --git a/chrome/browser/chromeos/gdata/gdata_cache.h b/chrome/browser/chromeos/gdata/gdata_cache.h
|
| index c4736730b7c4148c7f0f086e5a2876f567e2f1e6..de99af4fff7d7ef8fc28342c1d2c4da2dee1e1f6 100644
|
| --- a/chrome/browser/chromeos/gdata/gdata_cache.h
|
| +++ b/chrome/browser/chromeos/gdata/gdata_cache.h
|
| @@ -80,11 +80,12 @@ class GDataCache {
|
|
|
| // This is used as a bitmask for the cache state.
|
| enum CacheState {
|
| - CACHE_STATE_NONE = 0x0,
|
| - CACHE_STATE_PINNED = 0x1 << 0,
|
| - CACHE_STATE_PRESENT = 0x1 << 1,
|
| - CACHE_STATE_DIRTY = 0x1 << 2,
|
| - CACHE_STATE_MOUNTED = 0x1 << 3,
|
| + CACHE_STATE_NONE = 0x0,
|
| + CACHE_STATE_PINNED = 0x1 << 0,
|
| + CACHE_STATE_PRESENT = 0x1 << 1,
|
| + CACHE_STATE_DIRTY = 0x1 << 2,
|
| + CACHE_STATE_MOUNTED = 0x1 << 3,
|
| + CACHE_STATE_PERSISTENT = 0x1 << 4,
|
| };
|
|
|
| // Enum defining origin of a cached file.
|
| @@ -120,27 +121,29 @@ class GDataCache {
|
|
|
| // Structure to store information of an existing cache file.
|
| struct CacheEntry {
|
| - CacheEntry() : sub_dir_type(CACHE_TYPE_META),
|
| - cache_state(0) {}
|
| + CacheEntry() : cache_state(0) {}
|
|
|
| CacheEntry(const std::string& md5,
|
| - CacheSubDirectoryType sub_dir_type,
|
| int cache_state)
|
| : md5(md5),
|
| - sub_dir_type(sub_dir_type),
|
| cache_state(cache_state) {
|
| }
|
|
|
| bool IsPresent() const { return IsCachePresent(cache_state); }
|
| bool IsPinned() const { return IsCachePinned(cache_state); }
|
| bool IsDirty() const { return IsCacheDirty(cache_state); }
|
| - bool IsMounted() const { return IsCacheMounted(cache_state); }
|
| + bool IsMounted() const { return IsCacheMounted(cache_state); }
|
| + bool IsPersistent() const { return IsCachePersistent(cache_state); }
|
| +
|
| + // Returns the type of the sub directory where the cache file is stored.
|
| + CacheSubDirectoryType GetSubDirectoryType() const {
|
| + return IsPersistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP;
|
| + }
|
|
|
| // For debugging purposes.
|
| std::string ToString() const;
|
|
|
| std::string md5;
|
| - CacheSubDirectoryType sub_dir_type;
|
| int cache_state;
|
| };
|
|
|
| @@ -166,6 +169,9 @@ class GDataCache {
|
| static bool IsCacheMounted(int cache_state) {
|
| return cache_state & CACHE_STATE_MOUNTED;
|
| }
|
| + static bool IsCachePersistent(int cache_state) {
|
| + return cache_state & CACHE_STATE_PERSISTENT;
|
| + }
|
| static int SetCachePresent(int cache_state) {
|
| return cache_state |= CACHE_STATE_PRESENT;
|
| }
|
| @@ -178,6 +184,9 @@ class GDataCache {
|
| static int SetCacheMounted(int cache_state) {
|
| return cache_state |= CACHE_STATE_MOUNTED;
|
| }
|
| + static int SetCachePersistent(int cache_state) {
|
| + return cache_state |= CACHE_STATE_PERSISTENT;
|
| + }
|
| static int ClearCachePresent(int cache_state) {
|
| return cache_state &= ~CACHE_STATE_PRESENT;
|
| }
|
| @@ -190,6 +199,9 @@ class GDataCache {
|
| static int ClearCacheMounted(int cache_state) {
|
| return cache_state &= ~CACHE_STATE_MOUNTED;
|
| }
|
| + static int ClearCachePersistent(int cache_state) {
|
| + return cache_state &= ~CACHE_STATE_PERSISTENT;
|
| + }
|
|
|
| // Returns the sub-directory under gdata cache directory for the given sub
|
| // directory type. Example: <user_profile_dir>/GCache/v1/tmp
|
| @@ -468,6 +480,13 @@ class GDataCache {
|
| bool* success,
|
| GDataCache::CacheEntry* cache_entry);
|
|
|
| + // Wrapper around GDataCacheMetadata::UpdateCache(). This function takes
|
| + // |sub_dir_type| and modifies |cache_state| per the sub directory type.
|
| + void UpdateCacheWithSubDirectoryType(const std::string& resource_id,
|
| + const std::string& md5,
|
| + CacheSubDirectoryType sub_dir_type,
|
| + int cache_state);
|
| +
|
| // The root directory of the cache (i.e. <user_profile_dir>/GCache/v1).
|
| const FilePath cache_root_path_;
|
| // Paths for all subdirectories of GCache, one for each
|
|
|