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

Unified Diff: chrome/browser/user_data_dir_extractor.cc

Issue 174253002: Initialize chrome::DIR_USER_DATA early on for service processes, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Append the fallback user-data-dir to the commandline. Created 6 years, 10 months 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 | « chrome/browser/chrome_browser_main.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/user_data_dir_extractor.cc
diff --git a/chrome/browser/user_data_dir_extractor.cc b/chrome/browser/user_data_dir_extractor.cc
index 3c7e9cbd1166f4fbd1194a6da026149f6993b2af..e2d17e96e79fe51f42d2d6e4e75158719351879e 100644
--- a/chrome/browser/user_data_dir_extractor.cc
+++ b/chrome/browser/user_data_dir_extractor.cc
@@ -94,17 +94,24 @@ base::FilePath GetUserDataDir(const content::MainFunctionParams& parameters) {
#endif
// If the directory does not exist and cannot be created, prompt the user.
- if (!user_data_dir.empty() &&
+ const bool specified_directory_was_invalid = !user_data_dir.empty() &&
!PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA,
- user_data_dir, chrome::ProcessNeedsProfileDir(process_type))) {
+ user_data_dir, chrome::ProcessNeedsProfileDir(process_type));
+ if (specified_directory_was_invalid)
ShowUserDataDirWarning(user_data_dir);
- }
// Getting the user data directory can fail if the directory isn't creatable.
// ProcessSingleton needs a real user data directory on Mac/Linux, so it's
// better to fail here than fail mysteriously elsewhere.
CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir))
<< "Must be able to get user data directory!";
+
+ // Append the fallback user data directory to the commandline. Otherwise,
+ // child or service processes will attempt to use the invalid directory.
+ if (specified_directory_was_invalid)
+ CommandLine::ForCurrentProcess()->AppendSwitchPath(switches::kUserDataDir,
Vitaly Buka (NO REVIEWS) 2014/02/20 21:28:05 actually you just did that
+ user_data_dir);
+
return user_data_dir;
}
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698