Index: chrome/browser/chromeos/gdata/gdata_cache_metadata.cc |
=================================================================== |
--- chrome/browser/chromeos/gdata/gdata_cache_metadata.cc (revision 145940) |
+++ chrome/browser/chromeos/gdata/gdata_cache_metadata.cc (working copy) |
@@ -184,8 +184,9 @@ |
} |
void GDataCacheMetadataMap::UpdateCache(const std::string& resource_id, |
- const std::string& md5, |
- int cache_state) { |
+ const std::string& md5, |
+ GDataCache::CacheSubDirectoryType subdir, |
+ int cache_state) { |
AssertOnSequencedWorkerPool(); |
CacheMap::iterator iter = cache_map_.find(resource_id); |
@@ -193,7 +194,7 @@ |
// Makes no sense to create new entry if cache state is NONE. |
DCHECK(cache_state != GDataCache::CACHE_STATE_NONE); |
if (cache_state != GDataCache::CACHE_STATE_NONE) { |
- GDataCache::CacheEntry cache_entry(md5, cache_state); |
+ GDataCache::CacheEntry cache_entry(md5, subdir, cache_state); |
cache_map_.insert(std::make_pair(resource_id, cache_entry)); |
DVLOG(1) << "Added res_id=" << resource_id |
<< ", " << cache_entry.ToString(); |
@@ -206,6 +207,7 @@ |
cache_map_.erase(iter); |
} else { // Otherwise, update entry in cache map. |
iter->second.md5 = md5; |
+ iter->second.sub_dir_type = subdir; |
iter->second.cache_state = cache_state; |
DVLOG(1) << "Updated res_id=" << resource_id |
<< ", " << iter->second.ToString(); |
@@ -256,7 +258,7 @@ |
CacheMap::iterator iter = cache_map_.begin(); |
while (iter != cache_map_.end()) { |
- if (!iter->second.IsPersistent()) { |
+ if (iter->second.sub_dir_type == GDataCache::CACHE_TYPE_TMP) { |
// Post-increment the iterator to avoid iterator invalidation. |
cache_map_.erase(iter++); |
} else { |
@@ -352,9 +354,6 @@ |
continue; |
} else if (sub_dir_type == GDataCache::CACHE_TYPE_PERSISTENT || |
sub_dir_type == GDataCache::CACHE_TYPE_TMP) { |
- if (sub_dir_type == GDataCache::CACHE_TYPE_PERSISTENT) |
- cache_state = GDataCache::SetCachePersistent(cache_state); |
- |
if (file_util::IsLink(current)) { |
LOG(WARNING) << "Removing a symlink in persistent/tmp directory" |
<< current.value(); |
@@ -375,7 +374,7 @@ |
// the file is in the persistent directory. |
if (md5 == util::kLocallyModifiedFileExtension) { |
if (sub_dir_type == GDataCache::CACHE_TYPE_PERSISTENT) { |
- cache_state = GDataCache::SetCacheDirty(cache_state); |
+ cache_state |= GDataCache::SetCacheDirty(cache_state); |
} else { |
LOG(WARNING) << "Removing a dirty file in tmp directory: " |
<< current.value(); |
@@ -390,7 +389,8 @@ |
// Create and insert new entry into cache map. |
cache_map->insert(std::make_pair( |
- resource_id, GDataCache::CacheEntry(md5, cache_state))); |
+ resource_id, GDataCache::CacheEntry( |
+ md5, real_sub_dir_type, cache_state))); |
processed_file_map->insert(std::make_pair(resource_id, current)); |
} |
} |