diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 18:45:13 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 18:45:13 +0000 |
commit | bc96d5610e96f0c86ca227c539643454b1960e36 (patch) | |
tree | ed75f412d57298d89153d1a008b38b5fd7619805 /chrome | |
parent | aae605a26c03dc4a68ef546d3f5358601fa3d3bb (diff) | |
download | chromium_src-bc96d5610e96f0c86ca227c539643454b1960e36.zip chromium_src-bc96d5610e96f0c86ca227c539643454b1960e36.tar.gz chromium_src-bc96d5610e96f0c86ca227c539643454b1960e36.tar.bz2 |
Use $XDG_CACHE_HOME for the cache on Linux. This only works for the default profile.
BUG=16976
TEST=Run Chromium, visit some webpages, make sure it's using the cache under $XDG_CACHE_HOME (~/.cache by default)
Review URL: http://codereview.chromium.org/159028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/profile.cc | 10 | ||||
-rw-r--r-- | chrome/browser/profile.h | 1 | ||||
-rw-r--r-- | chrome/common/chrome_paths.cc | 10 | ||||
-rw-r--r-- | chrome/common/chrome_paths.h | 1 | ||||
-rw-r--r-- | chrome/common/chrome_paths_internal.h | 7 | ||||
-rw-r--r-- | chrome/common/chrome_paths_linux.cc | 14 |
6 files changed, 40 insertions, 3 deletions
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 6304c2b..6186394 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -6,7 +6,6 @@ #include "base/command_line.h" #include "base/file_path.h" -#include "base/file_util.h" #include "base/path_service.h" #include "base/scoped_ptr.h" #include "base/string_util.h" @@ -534,6 +533,11 @@ ProfileImpl::ProfileImpl(const FilePath& path) blacklist_ = new Blacklist(path); } + if (!PathService::IsOverridden(chrome::DIR_USER_DATA)) + PathService::Get(chrome::DIR_USER_CACHE, &base_cache_path_); + if (base_cache_path_.empty()) + base_cache_path_ = path_; + // Listen for theme installation. registrar_.Add(this, NotificationType::THEME_INSTALLED, NotificationService::AllSources()); @@ -790,7 +794,7 @@ URLRequestContext* ProfileImpl::GetRequestContext() { if (!request_context_) { FilePath cookie_path = GetPath(); cookie_path = cookie_path.Append(chrome::kCookieFilename); - FilePath cache_path = GetPath(); + FilePath cache_path = base_cache_path_; int max_size; GetCacheParameters(kNormalContext, &cache_path, &max_size); @@ -821,7 +825,7 @@ URLRequestContext* ProfileImpl::GetRequestContext() { URLRequestContext* ProfileImpl::GetRequestContextForMedia() { if (!media_request_context_) { - FilePath cache_path = GetPath(); + FilePath cache_path = base_cache_path_; int max_size; GetCacheParameters(kMediaContext, &cache_path, &max_size); diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h index 2eacb43..3f3a127 100644 --- a/chrome/browser/profile.h +++ b/chrome/browser/profile.h @@ -419,6 +419,7 @@ class ProfileImpl : public Profile, NotificationRegistrar registrar_; FilePath path_; + FilePath base_cache_path_; scoped_ptr<VisitedLinkEventListener> visited_link_event_listener_; scoped_ptr<VisitedLinkMaster> visited_link_master_; scoped_refptr<ExtensionsService> extensions_service_; diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index f8188c2..e8f26b6 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -75,6 +75,16 @@ bool PathProvider(int key, FilePath* result) { return false; create_dir = true; break; + case chrome::DIR_USER_CACHE: +#if defined(OS_LINUX) + if (!GetUserCacheDirectory(&cur)) + return false; + create_dir = true; +#else + // No concept of a separate cache directory on non-Linux systems. + return false; +#endif + break; case chrome::DIR_USER_DOCUMENTS: if (!GetUserDocumentsDirectory(&cur)) return false; diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h index c5191c3..da61650 100644 --- a/chrome/common/chrome_paths.h +++ b/chrome/common/chrome_paths.h @@ -16,6 +16,7 @@ enum { DIR_APP = PATH_START, // directory where dlls and data reside DIR_LOGS, // directory where logs should be written DIR_USER_DATA, // directory where user data can be written + DIR_USER_CACHE, // directory where user cache data resides DIR_CRASH_DUMPS, // directory where crash dumps are written DIR_USER_DESKTOP, // directory that correspond to the desktop DIR_INSPECTOR, // directory where web inspector is located diff --git a/chrome/common/chrome_paths_internal.h b/chrome/common/chrome_paths_internal.h index ce7a039..f1f0fa9 100644 --- a/chrome/common/chrome_paths_internal.h +++ b/chrome/common/chrome_paths_internal.h @@ -5,6 +5,8 @@ #ifndef CHROME_COMMON_CHROME_PATHS_INTERNAL_H_ #define CHROME_COMMON_CHROME_PATHS_INTERNAL_H_ +#include "build/build_config.h" + class FilePath; namespace chrome { @@ -13,6 +15,11 @@ namespace chrome { // DIR_USER_DATA has been overridden by a command-line option. bool GetDefaultUserDataDirectory(FilePath* result); +#if defined(OS_LINUX) +// Get the path to the user's cache directory. +bool GetUserCacheDirectory(FilePath* result); +#endif + // Get the path to the user's documents directory. bool GetUserDocumentsDirectory(FilePath* result); diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc index d3ce207..abc7f8d 100644 --- a/chrome/common/chrome_paths_linux.cc +++ b/chrome/common/chrome_paths_linux.cc @@ -72,6 +72,20 @@ bool GetDefaultUserDataDirectory(FilePath* result) { return true; } +// See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html +// for a spec on where cache files go. The net effect for most +// systems is we use ~/.cache/chromium/ for Chromium and +// ~/.cache/google-chrome/ for official builds. +bool GetUserCacheDirectory(FilePath* result) { + FilePath cache_dir(GetXDGDirectory("XDG_CACHE_HOME", ".cache")); +#if defined(GOOGLE_CHROME_BUILD) + *result = cache_dir.Append("google-chrome"); +#else + *result = cache_dir.Append("chromium"); +#endif + return true; +} + bool GetUserDocumentsDirectory(FilePath* result) { *result = GetXDGUserDirectory("DOCUMENTS", "Documents"); return true; |