summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 02:23:15 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 02:23:15 +0000
commitb411da300f6a750553c2d4e30150a83a2be4895a (patch)
treeab8bc09fde9decd764c6ed8172ffc2b3df57981c /base
parent08b307ced9f38b758d1fc79c0948f17508c87eb7 (diff)
downloadchromium_src-b411da300f6a750553c2d4e30150a83a2be4895a.zip
chromium_src-b411da300f6a750553c2d4e30150a83a2be4895a.tar.gz
chromium_src-b411da300f6a750553c2d4e30150a83a2be4895a.tar.bz2
Revert 67201 - Revert 67191 - chrome_paths: refactor and sanitize cache directory handling
[Checking to see if this build failures on Windows.] [[Nope. Failure was a flake.]] Previously we had a bunch of logic in profile_impl.cc that computed where the cache directory lives. This change relocates it to chrome_paths.cc. Some background on cache directories. There are two possible places to store cache files: 1) in the user data directory 2) in an OS-specific user cache directory On Windows, we always pick (1). On Mac and Linux, we currently use (2) in some circumstances. This patch changes both Mac and Linux to have the same behavior with respect to (2). The Mac/Linux shared behavior is that if the profile directory is in the standard location for profiles, we put the cache files into a matching directory name in the standard system cache directory (e.g. on Linux if you're using ~/.config/google-chrome, your cache ends up in ~/.cache/google-chrome; on Mac, the directories are ~/Library/Application Support versus ~/Library/Caches). If your user data directory is not in the standard location, we use behavior (1). The semantic changes of this patch should be: - On Mac, previously we checked whether the (2) directory had some particular subdirectories already when picking which one to use. This was removed; which directory is used is solely a question of whether the profile directory is in the standard location. I think the previous behavior was unpredictable. - On Linux, previously we only used behavior (2) if you hadn't changed your user-data-directory at all. Now, to match Mac, as long as your user-data-dir is in the standard place, you use the system cache dir. So e.g. using ~/.config/foobar puts your cache in ~/.cache/foobar. - On Linux, previously the default cache would end up as directories under ~/.cache/google-chrome/; now it ends up as directories under ~/.cache/google-chrome/Default/. (In all instances above, on Linux we continue to obey $XDG_CACHE_HOME.) BUG=59824 TEST=New test ChromePaths.UserCacheDir Review URL: http://codereview.chromium.org/5123004 TBR=evan@chromium.org Review URL: http://codereview.chromium.org/5344003 TBR=viettrungluu@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67202 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base_paths.h9
-rw-r--r--base/base_paths_linux.cc2
-rw-r--r--base/base_paths_mac.mm2
-rw-r--r--base/path_service.cc8
-rw-r--r--base/path_service.h5
-rw-r--r--base/path_service_unittest.cc4
6 files changed, 9 insertions, 21 deletions
diff --git a/base/base_paths.h b/base/base_paths.h
index 0f9be04..72cff15 100644
--- a/base/base_paths.h
+++ b/base/base_paths.h
@@ -33,10 +33,11 @@ enum {
// for tests that need to locate various resources. It
// should not be used outside of test code.
#if defined(OS_POSIX)
- DIR_USER_CACHE, // Directory where user cache data resides. The Chromium
- // browser cache can be a subdirectory of DIR_USER_CACHE.
- // This is $XDG_CACHE_HOME on Linux and ~/Library/Caches
- // on Mac.
+ DIR_CACHE, // Directory where to put cache data. Note this is
+ // *not* where the browser cache lives, but the
+ // browser cache can be a subdirectory.
+ // This is $XDG_CACHE_HOME on Linux and
+ // ~/Library/Caches on Mac.
#endif
PATH_END
diff --git a/base/base_paths_linux.cc b/base/base_paths_linux.cc
index 6d837f2..701b983 100644
--- a/base/base_paths_linux.cc
+++ b/base/base_paths_linux.cc
@@ -105,7 +105,7 @@ bool PathProviderPosix(int key, FilePath* result) {
<< "Try running from your chromium/src directory.";
return false;
}
- case base::DIR_USER_CACHE:
+ case base::DIR_CACHE:
scoped_ptr<base::Environment> env(base::Environment::Create());
FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME",
".cache"));
diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm
index b9225d8..97413ba 100644
--- a/base/base_paths_mac.mm
+++ b/base/base_paths_mac.mm
@@ -47,7 +47,7 @@ bool PathProviderMac(int key, FilePath* result) {
case base::FILE_MODULE: {
return GetNSExecutablePath(result);
}
- case base::DIR_USER_CACHE:
+ case base::DIR_CACHE:
return mac_util::GetUserDirectory(NSCachesDirectory, result);
case base::DIR_APP_DATA:
return mac_util::GetUserDirectory(NSApplicationSupportDirectory, result);
diff --git a/base/path_service.cc b/base/path_service.cc
index 9eed56d..8660c42 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -215,14 +215,6 @@ bool PathService::Get(int key, std::wstring* result) {
}
#endif
-// TODO(evan): remove me -- see comments in header.
-bool PathService::IsOverridden(int key) {
- PathData* path_data = GetPathData();
- DCHECK(path_data);
- AutoLock scoped_lock(path_data->lock);
- return path_data->overrides.find(key) != path_data->overrides.end();
-}
-
bool PathService::Override(int key, const FilePath& path) {
PathData* path_data = GetPathData();
DCHECK(path_data);
diff --git a/base/path_service.h b/base/path_service.h
index 6873e1f..4d99cdc 100644
--- a/base/path_service.h
+++ b/base/path_service.h
@@ -45,11 +45,6 @@ class PathService {
// over the lifetime of the app, so this method should be used with caution.
static bool Override(int key, const FilePath& path);
- // Return whether a path was overridden.
- // TODO(evan): temporarily restoring this to quick-fix a regression.
- // Remove me again once it's fixed properly.
- static bool IsOverridden(int key);
-
// To extend the set of supported keys, you can register a path provider,
// which is just a function mirroring PathService::Get. The ProviderFunc
// returns false if it cannot provide a non-empty path for the given key.
diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc
index c65f7a5..26998de 100644
--- a/base/path_service_unittest.cc
+++ b/base/path_service_unittest.cc
@@ -22,9 +22,9 @@ bool ReturnsValidPath(int dir_type) {
FilePath path;
bool result = PathService::Get(dir_type, &path);
#if defined(OS_POSIX)
- // If chromium has never been started on this account, the cache path will not
+ // If chromium has never been started on this account, the cache path may not
// exist.
- if (dir_type == base::DIR_USER_CACHE)
+ if (dir_type == base::DIR_CACHE)
return result && !path.value().empty();
#endif
return result && !path.value().empty() && file_util::PathExists(path);