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

Unified Diff: chrome/browser/profile_impl.cc

Issue 5123004: chrome_paths: refactor and sanitize cache directory handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more win Created 10 years, 1 month 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 | « base/path_service_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profile_impl.cc
diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc
index 464c45c9f6541ce39d04ca6b9bec47a55baa89a9..c66428dbc7e80741c84de2c03c5ad92a444bb510 100644
--- a/chrome/browser/profile_impl.cc
+++ b/chrome/browser/profile_impl.cc
@@ -81,6 +81,7 @@
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/json_pref_store.h"
#include "chrome/common/notification_service.h"
@@ -172,11 +173,6 @@ FilePath GetMediaCachePath(const FilePath& base) {
return base.Append(chrome::kMediaCacheDirname);
}
-bool HasACacheSubdir(const FilePath &dir) {
- return file_util::PathExists(GetCachePath(dir)) ||
- file_util::PathExists(GetMediaCachePath(dir));
-}
-
// Simple task to log the size of the current profile.
class ProfileSizeTask : public Task {
public:
@@ -280,46 +276,11 @@ ProfileImpl::ProfileImpl(const FilePath& path)
// Convert active labs into switches. Modifies the current command line.
about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess());
-#if defined(OS_MACOSX)
- // If the profile directory doesn't already have a cache directory and it
- // is under ~/Library/Application Support, use a suitable cache directory
- // under ~/Library/Caches. For example, a profile directory of
- // ~/Library/Application Support/Google/Chrome/MyProfileName that doesn't
- // have a "Cache" or "MediaCache" subdirectory would use the cache directory
- // ~/Library/Caches/Google/Chrome/MyProfileName.
- //
- // TODO(akalin): Come up with unit tests for this.
- if (!HasACacheSubdir(path_)) {
- FilePath app_data_path, user_cache_path;
- if (PathService::Get(base::DIR_APP_DATA, &app_data_path) &&
- PathService::Get(base::DIR_USER_CACHE, &user_cache_path) &&
- app_data_path.AppendRelativePath(path_, &user_cache_path)) {
- base_cache_path_ = user_cache_path;
- }
- }
-#elif defined(OS_POSIX) // Posix minus Mac.
- // 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.
- // If we're using a different user-data-dir, though, fall through
- // to the "normal" cache directory (a subdirectory of that).
- // TODO(evan): all of this logic belongs in path_service; refactor and remove
- // this IsOverriden business.
- if (!PathService::IsOverridden(chrome::DIR_USER_DATA)) {
-#if defined(GOOGLE_CHROME_BUILD)
- const char kCacheDir[] = "google-chrome";
-#else
- const char kCacheDir[] = "chromium";
-#endif
- PathService::Get(base::DIR_USER_CACHE, &base_cache_path_);
- base_cache_path_ = base_cache_path_.Append(kCacheDir);
- if (!file_util::PathExists(base_cache_path_))
- file_util::CreateDirectory(base_cache_path_);
- }
-#endif
- if (base_cache_path_.empty())
- base_cache_path_ = path_;
+ // It would be nice to use PathService for fetching this directory, but
+ // the cache directory depends on the profile directory, which isn't available
+ // to PathService.
+ chrome::GetUserCacheDirectory(path_, &base_cache_path_);
+ file_util::CreateDirectory(base_cache_path_);
// Listen for theme installations from our original profile.
registrar_.Add(this, NotificationType::THEME_INSTALLED,
« no previous file with comments | « base/path_service_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698