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

Issue 5123004: chrome_paths: refactor and sanitize cache directory handling (Closed)

Created:
10 years, 1 month ago by Evan Martin
Modified:
9 years, 7 months ago
CC:
chromium-reviews, ben+cc_chromium.org, Paweł Hajdan Jr., pam+watch_chromium.org, brettw-cc_chromium.org
Visibility:
Public.

Description

chrome_paths: refactor and sanitize cache directory handling 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 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=67160

Patch Set 1 #

Patch Set 2 : better #

Patch Set 3 : forgot file #

Patch Set 4 : mac #

Patch Set 5 : mac #

Patch Set 6 : works #

Total comments: 11

Patch Set 7 : review comments #

Patch Set 8 : 80 #

Total comments: 2

Patch Set 9 : more mac #

Patch Set 10 : mac #

Total comments: 1

Patch Set 11 : akalin #

Total comments: 1

Patch Set 12 : bool removal #

Patch Set 13 : more win #

Unified diffs Side-by-side diffs Delta from patch set Stats (+121 lines, -70 lines) Patch
M base/base_paths.h View 1 2 3 4 5 6 1 chunk +5 lines, -4 lines 0 comments Download
M base/base_paths_linux.cc View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M base/base_paths_mac.mm View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -1 line 0 comments Download
M base/path_service.h View 1 chunk +0 lines, -5 lines 0 comments Download
M base/path_service.cc View 1 chunk +0 lines, -8 lines 0 comments Download
M base/path_service_unittest.cc View 1 chunk +0 lines, -6 lines 0 comments Download
M chrome/browser/profile_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +6 lines, -45 lines 0 comments Download
M chrome/chrome_tests.gypi View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M chrome/common/chrome_paths_internal.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +9 lines, -0 lines 0 comments Download
M chrome/common/chrome_paths_linux.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +27 lines, -0 lines 0 comments Download
M chrome/common/chrome_paths_mac.mm View 1 2 3 4 5 6 7 8 9 10 1 chunk +22 lines, -0 lines 0 comments Download
A chrome/common/chrome_paths_unittest.cc View 3 4 5 6 7 8 9 10 11 12 1 chunk +44 lines, -0 lines 0 comments Download
M chrome/common/chrome_paths_win.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 22 (0 generated)
Evan Martin
akalin/mark: mac change thestig/phajdan: linux change rvargas: FYI, just if you'd like to comment This ...
10 years, 1 month ago (2010-11-17 22:26:51 UTC) #1
Mark Mentovai
This sounds good on the basis of the CL description. I haven’t read the code. ...
10 years, 1 month ago (2010-11-17 22:32:49 UTC) #2
Lei Zhang
Can this be done without changing base/base_paths* ? The reason I put DIR_USER_CACHE in base/ ...
10 years, 1 month ago (2010-11-18 01:36:55 UTC) #3
Evan Martin
On 2010/11/18 01:36:55, Lei Zhang wrote: > Can this be done without changing base/base_paths* ? ...
10 years, 1 month ago (2010-11-18 01:54:47 UTC) #4
Evan Martin
On 2010/11/18 01:54:47, Evan Martin wrote: > On 2010/11/18 01:36:55, Lei Zhang wrote: > > ...
10 years, 1 month ago (2010-11-18 01:55:10 UTC) #5
Lei Zhang
On 2010/11/18 01:54:47, Evan Martin wrote: > On 2010/11/18 01:36:55, Lei Zhang wrote: > > ...
10 years, 1 month ago (2010-11-18 02:10:35 UTC) #6
Lei Zhang
On 2010/11/18 02:10:35, Lei Zhang wrote: > On 2010/11/18 01:54:47, Evan Martin wrote: > > ...
10 years, 1 month ago (2010-11-18 02:11:49 UTC) #7
Paweł Hajdan Jr.
LGTM
10 years, 1 month ago (2010-11-18 10:39:57 UTC) #8
Mark Mentovai
LGTM http://codereview.chromium.org/5123004/diff/14001/chrome/common/chrome_paths_internal.h File chrome/common/chrome_paths_internal.h (right): http://codereview.chromium.org/5123004/diff/14001/chrome/common/chrome_paths_internal.h#newcode27 chrome/common/chrome_paths_internal.h:27: // Note that we create subdirectories from this ...
10 years, 1 month ago (2010-11-18 16:54:54 UTC) #9
Mark Mentovai
http://codereview.chromium.org/5123004/diff/14001/chrome/common/chrome_paths_linux.cc File chrome/common/chrome_paths_linux.cc (right): http://codereview.chromium.org/5123004/diff/14001/chrome/common/chrome_paths_linux.cc#newcode46 chrome/common/chrome_paths_linux.cc:46: FilePath system_relative_dir = cache_dir; By the way, “why the ...
10 years, 1 month ago (2010-11-18 16:55:57 UTC) #10
Evan Martin
Ok, PTAL. I reinstated base::DIR_CACHE (but I renamed it slightly -- I'm scared of people ...
10 years, 1 month ago (2010-11-18 18:13:07 UTC) #11
Mark Mentovai
http://codereview.chromium.org/5123004/diff/14001/chrome/common/chrome_paths_unittest.cc File chrome/common/chrome_paths_unittest.cc (right): http://codereview.chromium.org/5123004/diff/14001/chrome/common/chrome_paths_unittest.cc#newcode18 chrome/common/chrome_paths_unittest.cc:18: FilePath homedir = FilePath(getenv("HOME")); Evan Martin wrote: > On ...
10 years, 1 month ago (2010-11-18 19:11:48 UTC) #12
Evan Martin
On 2010/11/18 19:11:48, Mark Mentovai wrote: > I can give you a quick Mac implementation ...
10 years, 1 month ago (2010-11-18 19:18:54 UTC) #13
Evan Martin
http://codereview.chromium.org/5123004/diff/34001/chrome/common/chrome_paths_mac.mm File chrome/common/chrome_paths_mac.mm (right): http://codereview.chromium.org/5123004/diff/34001/chrome/common/chrome_paths_mac.mm#newcode60 chrome/common/chrome_paths_mac.mm:60: FilePath cache_dir = cache_dir; On 2010/11/18 19:11:48, Mark Mentovai ...
10 years, 1 month ago (2010-11-18 19:19:06 UTC) #14
Mark Mentovai
Evan Martin wrote: > Since the test is verifying that we handle the special Library/Caches ...
10 years, 1 month ago (2010-11-18 19:36:49 UTC) #15
Evan Martin
On 2010/11/18 19:36:49, Mark Mentovai wrote: > I guess we should use the path service, ...
10 years, 1 month ago (2010-11-22 23:16:13 UTC) #16
akalin
http://codereview.chromium.org/5123004/diff/42001/chrome/browser/profile_impl.cc File chrome/browser/profile_impl.cc (right): http://codereview.chromium.org/5123004/diff/42001/chrome/browser/profile_impl.cc#newcode279 chrome/browser/profile_impl.cc:279: if (!chrome::GetUserCacheDirectory(path_, &base_cache_path_)) All implementations of GetUserCacheDirectory() already set ...
10 years, 1 month ago (2010-11-22 23:22:44 UTC) #17
Evan Martin
OK, PTAL
10 years, 1 month ago (2010-11-22 23:31:38 UTC) #18
akalin
LGTM On 2010/11/22 23:31:38, Evan Martin wrote: > OK, PTAL
10 years, 1 month ago (2010-11-22 23:54:20 UTC) #19
akalin
http://codereview.chromium.org/5123004/diff/50001/chrome/common/chrome_paths_unittest.cc File chrome/common/chrome_paths_unittest.cc (right): http://codereview.chromium.org/5123004/diff/50001/chrome/common/chrome_paths_unittest.cc#newcode15 chrome/common/chrome_paths_unittest.cc:15: // Test the behavior of chrome::GetUserCacheDirectory. May be worth ...
10 years, 1 month ago (2010-11-22 23:54:28 UTC) #20
Evan Martin
PTAL
10 years, 1 month ago (2010-11-23 18:57:52 UTC) #21
akalin
10 years, 1 month ago (2010-11-23 19:08:11 UTC) #22
LGTM

On 2010/11/23 18:57:52, Evan Martin wrote:
> PTAL

Powered by Google App Engine
This is Rietveld 408576698