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

Unified Diff: chrome/common/chrome_paths_mac.mm

Issue 5123004: chrome_paths: refactor and sanitize cache directory handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: works 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
Index: chrome/common/chrome_paths_mac.mm
diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm
index b87b39788ecd09ae100c4a9eef4fedc03dfdf6bb..11494f822defab1e0dfa356f44e167449fd75e52 100644
--- a/chrome/common/chrome_paths_mac.mm
+++ b/chrome/common/chrome_paths_mac.mm
@@ -48,6 +48,30 @@ bool GetUserDocumentsDirectory(FilePath* result) {
return mac_util::GetUserDirectory(NSDocumentDirectory, result);
}
+bool GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) {
+ // If the profile directory 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 would use the cache directory
+ // ~/Library/Caches/Google/Chrome/MyProfileName.
+
+ FilePath cache_dir;
+ if (!mac_util::GetUserDirectory(NSCachesDirectory, &cache_dir))
+ return false;
+
+ FilePath app_data_dir;
+ if (PathService::Get(base::DIR_APP_DATA, &app_data_dir)) {
+ FilePath system_relative_dir = cache_dir;
Mark Mentovai 2010/11/18 16:54:54 Do you need this copy? Why don’t you just move the
Evan Martin 2010/11/18 18:13:07 I found the usage of AppendRelativePath kind of ha
+ if (app_data_dir.AppendRelativePath(profile_dir, &system_relative_dir)) {
+ *result = system_relative_dir;
+ return true;
+ }
+ }
+
+ *result = profile_dir;
+ return true;
+}
+
bool GetUserDownloadsDirectory(FilePath* result) {
return mac_util::GetUserDirectory(NSDownloadsDirectory, result);
}

Powered by Google App Engine
This is Rietveld 408576698