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/common | |
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/common')
-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 |
4 files changed, 32 insertions, 0 deletions
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; |