Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4284)

Unified Diff: chrome/browser/chromeos/gdata/gdata_cache.h

Issue 10702133: gdata: Remove sub_dir_type from CacheEntry for simplicity (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: the fix Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698