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

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

Issue 10198003: gdata: Get rid of GetGDataCacheTmpDirectory() and friends (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix infinite recursion Created 8 years, 8 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
Index: chrome/browser/chromeos/gdata/gdata_file_system.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index 90e7026ea1e264d0a4613a98edb42dc1698aa6b1..32de23b96d40494d898362f3bde69e6be07acc10 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -1687,7 +1687,8 @@ void GDataFileSystem::GetFileByPath(const FilePath& file_path,
kGDataFileSystemToken,
FROM_HERE,
base::Bind(&GDataFileSystem::CreateDocumentJsonFileOnIOThreadPool,
- GetGDataTempDocumentFolderPath(),
+ GetCacheDirectoryPath(
+ GDataRootDirectory::CACHE_TYPE_TMP_DOCUMENTS),
file_properties.alternate_url,
file_properties.resource_id,
error,
@@ -1817,7 +1818,7 @@ void GDataFileSystem::FreeDiskSpaceIfNeededFor(int64 num_bytes,
// First remove temporary files from the cache map.
root_->RemoveTemporaryFilesFromCacheMap();
// Then remove all files under "tmp" directory.
- RemoveAllFiles(GetGDataCacheTmpDirectory());
+ RemoveAllFiles(GetCacheDirectoryPath(GDataRootDirectory::CACHE_TYPE_TMP));
// Check the disk space again.
*has_enough_space = HasEnoughSpaceFor(num_bytes);
@@ -2009,26 +2010,6 @@ bool GDataFileSystem::GetFileInfoByPath(
return true;
}
-FilePath GDataFileSystem::GetGDataCacheTmpDirectory() const {
- return cache_paths_[GDataRootDirectory::CACHE_TYPE_TMP];
-}
-
-FilePath GDataFileSystem::GetGDataTempDownloadFolderPath() const {
- return cache_paths_[GDataRootDirectory::CACHE_TYPE_TMP_DOWNLOADS];
-}
-
-FilePath GDataFileSystem::GetGDataTempDocumentFolderPath() const {
- return cache_paths_[GDataRootDirectory::CACHE_TYPE_TMP_DOCUMENTS];
-}
-
-FilePath GDataFileSystem::GetGDataCachePinnedDirectory() const {
- return cache_paths_[GDataRootDirectory::CACHE_TYPE_PINNED];
-}
-
-FilePath GDataFileSystem::GetGDataCachePersistentDirectory() const {
- return cache_paths_[GDataRootDirectory::CACHE_TYPE_PERSISTENT];
-}
-
base::WeakPtr<GDataFileSystem> GDataFileSystem::GetWeakPtrForCurrentThread() {
if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
return ui_weak_ptr_factory_->GetWeakPtr();
@@ -2302,7 +2283,7 @@ void GDataFileSystem::LoadRootFeedFromCache(
const FilePath& search_file_path,
const FindEntryCallback& callback) {
const FilePath path =
- cache_paths_[GDataRootDirectory::CACHE_TYPE_META].Append(
+ GetCacheDirectoryPath(GDataRootDirectory::CACHE_TYPE_META).Append(
kFilesystemProtoFile);
LoadRootFeedParams* params = new LoadRootFeedParams(search_file_path,
should_load_from_server,
@@ -2376,7 +2357,7 @@ void GDataFileSystem::SaveFileSystemAsProto() {
}
const FilePath path =
- cache_paths_[GDataRootDirectory::CACHE_TYPE_META].Append(
+ GetCacheDirectoryPath(GDataRootDirectory::CACHE_TYPE_META).Append(
kFilesystemProtoFile);
scoped_ptr<std::string> serialized_proto(new std::string());
root_->SerializeToString(serialized_proto.get());
@@ -2501,8 +2482,8 @@ void GDataFileSystem::SaveFeed(scoped_ptr<base::Value> feed,
kGDataFileSystemToken,
FROM_HERE,
base::Bind(&SaveFeedOnIOThreadPool,
- cache_paths_[GDataRootDirectory::CACHE_TYPE_META].Append(
- name),
+ GetCacheDirectoryPath(
+ GDataRootDirectory::CACHE_TYPE_META).Append(name),
base::Passed(&feed)));
}
@@ -3203,6 +3184,11 @@ void GDataFileSystem::SetHideHostedDocuments(bool hide) {
//===================== GDataFileSystem: Cache entry points ====================
+FilePath GDataFileSystem::GetCacheDirectoryPath(
+ GDataRootDirectory::CacheSubDirectoryType sub_dir_type) const {
+ return cache_paths_[sub_dir_type];
achuithb 2012/04/23 23:48:02 Are there any DCHECKs that might be appropriate he
satorux1 2012/04/24 00:04:36 Sounds good. Added.
+}
+
FilePath GDataFileSystem::GetCacheFilePath(
const std::string& resource_id,
const std::string& md5,
@@ -3222,7 +3208,7 @@ FilePath GDataFileSystem::GetCacheFilePath(
base_name += FilePath::kExtensionSeparator;
base_name += GDataEntry::EscapeUtf8FileName(md5);
}
- return cache_paths_[sub_dir_type].Append(base_name);
+ return GetCacheDirectoryPath(sub_dir_type).Append(base_name);
}
void GDataFileSystem::StoreToCache(const std::string& resource_id,
@@ -3411,7 +3397,7 @@ void GDataFileSystem::InitializeCacheOnIOThreadPool() {
// Change permissions of cache persistent directory to u+rwx,og+x in order to
// allow archive files in that directory to be mounted by cros-disks.
error = ChangeFilePermissions(
- cache_paths_[GDataRootDirectory::CACHE_TYPE_PERSISTENT],
+ GetCacheDirectoryPath(GDataRootDirectory::CACHE_TYPE_PERSISTENT),
S_IRWXU | S_IXGRP | S_IXOTH);
if (error != base::PLATFORM_FILE_OK)
return;
@@ -4150,7 +4136,7 @@ void GDataFileSystem::ScanCacheDirectory(
GDataRootDirectory::CacheSubDirectoryType sub_dir_type,
GDataRootDirectory::CacheMap* cache_map) {
file_util::FileEnumerator enumerator(
- cache_paths_[sub_dir_type],
+ GetCacheDirectoryPath(sub_dir_type),
false, // not recursive
static_cast<file_util::FileEnumerator::FileType>(
file_util::FileEnumerator::FILES |
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | chrome/browser/chromeos/gdata/gdata_sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698