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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/user_data_dir_extractor.h" 5 #include "chrome/browser/user_data_dir_extractor.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 IsStringUTF8(user_data_dir_string)) { 87 IsStringUTF8(user_data_dir_string)) {
88 user_data_dir = base::FilePath::FromUTF8Unsafe(user_data_dir_string); 88 user_data_dir = base::FilePath::FromUTF8Unsafe(user_data_dir_string);
89 } 89 }
90 } 90 }
91 #endif 91 #endif
92 #if defined(OS_MACOSX) || defined(OS_WIN) 92 #if defined(OS_MACOSX) || defined(OS_WIN)
93 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); 93 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir);
94 #endif 94 #endif
95 95
96 // If the directory does not exist and cannot be created, prompt the user. 96 // If the directory does not exist and cannot be created, prompt the user.
97 if (!user_data_dir.empty() && 97 const bool specified_directory_was_invalid = !user_data_dir.empty() &&
98 !PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA, 98 !PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA,
99 user_data_dir, chrome::ProcessNeedsProfileDir(process_type))) { 99 user_data_dir, chrome::ProcessNeedsProfileDir(process_type));
100 if (specified_directory_was_invalid)
100 ShowUserDataDirWarning(user_data_dir); 101 ShowUserDataDirWarning(user_data_dir);
101 }
102 102
103 // Getting the user data directory can fail if the directory isn't creatable. 103 // Getting the user data directory can fail if the directory isn't creatable.
104 // ProcessSingleton needs a real user data directory on Mac/Linux, so it's 104 // ProcessSingleton needs a real user data directory on Mac/Linux, so it's
105 // better to fail here than fail mysteriously elsewhere. 105 // better to fail here than fail mysteriously elsewhere.
106 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) 106 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir))
107 << "Must be able to get user data directory!"; 107 << "Must be able to get user data directory!";
108
109 // Append the fallback user data directory to the commandline. Otherwise,
110 // child or service processes will attempt to use the invalid directory.
111 if (specified_directory_was_invalid)
112 CommandLine::ForCurrentProcess()->AppendSwitchPath(switches::kUserDataDir,
Vitaly Buka (NO REVIEWS) 2014/02/20 21:28:05 actually you just did that
113 user_data_dir);
114
108 return user_data_dir; 115 return user_data_dir;
109 } 116 }
110 117
111 } // namespace chrome 118 } // namespace chrome
OLDNEW
« 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