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

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

Issue 10698135: Revert 145933 - gdata: Remove sub_dir_type from CacheEntry for simplicity (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | « chrome/browser/chromeos/gdata/gdata_cache.h ('k') | chrome/browser/chromeos/gdata/gdata_cache_metadata.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_cache.cc
===================================================================
--- chrome/browser/chromeos/gdata/gdata_cache.cc (revision 145940)
+++ chrome/browser/chromeos/gdata/gdata_cache.cc (working copy)
@@ -37,6 +37,30 @@
const FilePath::CharType kGDataCacheTmpDocumentsDir[] =
FILE_PATH_LITERAL("tmp/documents");
+std::string CacheSubDirectoryTypeToString(
+ GDataCache::CacheSubDirectoryType subdir) {
+ switch (subdir) {
+ case GDataCache::CACHE_TYPE_META:
+ return "meta";
+ case GDataCache::CACHE_TYPE_PINNED:
+ return "pinned";
+ case GDataCache::CACHE_TYPE_OUTGOING:
+ return "outgoing";
+ case GDataCache::CACHE_TYPE_PERSISTENT:
+ return "persistent";
+ case GDataCache::CACHE_TYPE_TMP:
+ return "tmp";
+ case GDataCache::CACHE_TYPE_TMP_DOWNLOADS:
+ return "tmp_downloads";
+ case GDataCache::CACHE_TYPE_TMP_DOCUMENTS:
+ return "tmp_documents";
+ case GDataCache::NUM_CACHE_TYPES:
+ NOTREACHED();
+ }
+ NOTREACHED();
+ return "unknown subdir";
+}
+
// Returns the home directory path, or an empty string if the home directory
// is not found.
// Copied from webkit/chromeos/cros_mount_point_provider.h.
@@ -343,11 +367,10 @@
cache_states.push_back("pinned");
if (GDataCache::IsCacheDirty(cache_state))
cache_states.push_back("dirty");
- if (GDataCache::IsCachePersistent(cache_state))
- cache_states.push_back("persistent");
- return base::StringPrintf("md5=%s, cache_state=%s",
+ return base::StringPrintf("md5=%s, subdir=%s, cache_state=%s",
md5.c_str(),
+ CacheSubDirectoryTypeToString(sub_dir_type).c_str(),
JoinString(cache_states, ',').c_str());
}
@@ -794,7 +817,7 @@
*cache_file_path = GetCacheFilePath(
resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ cache_entry->sub_dir_type,
file_origin);
*error = base::PLATFORM_FILE_OK;
} else {
@@ -880,10 +903,7 @@
if (*error == base::PLATFORM_FILE_OK) {
// Now that file operations have completed, update cache map.
- UpdateCacheWithSubDirectoryType(resource_id,
- md5,
- sub_dir_type,
- cache_state);
+ metadata_->UpdateCache(resource_id, md5, sub_dir_type, cache_state);
}
}
@@ -924,17 +944,17 @@
// set |source_path| the same, because ModifyCacheState only moves files if
// source and destination are different.
if (cache_entry->IsDirty() || cache_entry->IsMounted()) {
- DCHECK(cache_entry->IsPersistent());
+ DCHECK_EQ(CACHE_TYPE_PERSISTENT, cache_entry->sub_dir_type);
dest_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ cache_entry->sub_dir_type,
CACHED_FILE_LOCALLY_MODIFIED);
source_path = dest_path;
} else {
// Gets the current path of the file in cache.
source_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ cache_entry->sub_dir_type,
CACHED_FILE_FROM_SERVER);
// If file was pinned before but actual file blob doesn't exist in cache:
@@ -970,10 +990,7 @@
if (*error == base::PLATFORM_FILE_OK) {
// Now that file operations have completed, update cache map.
- UpdateCacheWithSubDirectoryType(resource_id,
- md5,
- sub_dir_type,
- cache_state);
+ metadata_->UpdateCache(resource_id, md5, sub_dir_type, cache_state);
}
}
@@ -1006,17 +1023,17 @@
// and destination are different.
if (cache_entry->IsDirty() || cache_entry->IsMounted()) {
sub_dir_type = CACHE_TYPE_PERSISTENT;
- DCHECK(cache_entry->IsPersistent());
+ DCHECK_EQ(sub_dir_type, cache_entry->sub_dir_type);
dest_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ cache_entry->sub_dir_type,
CACHED_FILE_LOCALLY_MODIFIED);
source_path = dest_path;
} else {
// Gets the current path of the file in cache.
source_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ cache_entry->sub_dir_type,
CACHED_FILE_FROM_SERVER);
// If file was pinned but actual file blob still doesn't exist in cache,
@@ -1052,10 +1069,7 @@
if (*error == base::PLATFORM_FILE_OK) {
// Now that file operations have completed, update cache map.
int cache_state = ClearCachePinned(cache_entry->cache_state);
- UpdateCacheWithSubDirectoryType(resource_id,
- md5,
- sub_dir_type,
- cache_state);
+ metadata_->UpdateCache(resource_id, md5, sub_dir_type, cache_state);
}
}
@@ -1119,10 +1133,7 @@
FILE_OPERATION_MOVE, FilePath(), false);
if (*error == base::PLATFORM_FILE_OK) {
// Now that cache operation is complete, update cache map
- UpdateCacheWithSubDirectoryType(resource_id,
- md5,
- dest_subdir,
- cache_state);
+ metadata_->UpdateCache(resource_id, md5, dest_subdir, cache_state);
}
}
@@ -1160,7 +1171,7 @@
// MarkDirtyInCache is called again.
if (cache_entry->IsDirty()) {
// The file must be in persistent dir.
- DCHECK(cache_entry->IsPersistent());
+ DCHECK_EQ(CACHE_TYPE_PERSISTENT, cache_entry->sub_dir_type);
// Determine symlink path in outgoing dir, so as to remove it.
FilePath symlink_path = GetCacheFilePath(
@@ -1196,7 +1207,7 @@
FilePath source_path = GetCacheFilePath(
resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ cache_entry->sub_dir_type,
CACHED_FILE_FROM_SERVER);
// Determine destination path.
@@ -1225,10 +1236,7 @@
if (*error == base::PLATFORM_FILE_OK) {
// Now that file operations have completed, update cache map.
int cache_state = SetCacheDirty(cache_entry->cache_state);
- UpdateCacheWithSubDirectoryType(resource_id,
- md5,
- sub_dir_type,
- cache_state);
+ metadata_->UpdateCache(resource_id, md5, sub_dir_type, cache_state);
}
}
@@ -1267,7 +1275,7 @@
}
// Dirty files must be in persistent dir.
- DCHECK(cache_entry->IsPersistent());
+ DCHECK_EQ(CACHE_TYPE_PERSISTENT, cache_entry->sub_dir_type);
// Create symlink in outgoing dir.
FilePath symlink_path = GetCacheFilePath(resource_id,
@@ -1278,7 +1286,7 @@
// Get target path of symlink i.e. current path of the file in cache.
FilePath target_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ cache_entry->sub_dir_type,
CACHED_FILE_LOCALLY_MODIFIED);
// Since there's no need to move files, use |target_path| for both
@@ -1324,12 +1332,12 @@
}
// File must be dirty and hence in persistent dir.
- DCHECK(cache_entry->IsPersistent());
+ DCHECK_EQ(CACHE_TYPE_PERSISTENT, cache_entry->sub_dir_type);
// Get the current path of the file in cache.
FilePath source_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ cache_entry->sub_dir_type,
CACHED_FILE_LOCALLY_MODIFIED);
// Determine destination path.
@@ -1374,10 +1382,7 @@
if (*error == base::PLATFORM_FILE_OK) {
// Now that file operations have completed, update cache map.
int cache_state = ClearCacheDirty(cache_entry->cache_state);
- UpdateCacheWithSubDirectoryType(resource_id,
- md5,
- sub_dir_type,
- cache_state);
+ metadata_->UpdateCache(resource_id, md5, sub_dir_type, cache_state);
}
}
@@ -1512,22 +1517,6 @@
*cache_entry = *value;
}
-void GDataCache::UpdateCacheWithSubDirectoryType(
- const std::string& resource_id,
- const std::string& md5,
- CacheSubDirectoryType sub_dir_type,
- int cache_state) {
- DCHECK(sub_dir_type == CACHE_TYPE_PERSISTENT ||
- sub_dir_type == CACHE_TYPE_TMP);
-
- if (sub_dir_type == CACHE_TYPE_PERSISTENT)
- cache_state = SetCachePersistent(cache_state);
- else
- cache_state = ClearCachePersistent(cache_state);
-
- metadata_->UpdateCache(resource_id, md5, cache_state);
-}
-
// static
FilePath GDataCache::GetCacheRootPath(Profile* profile) {
FilePath cache_base_path;
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_cache.h ('k') | chrome/browser/chromeos/gdata/gdata_cache_metadata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698