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

Side by Side Diff: chrome/common/service_process_util.cc

Issue 347953002: Use the same set of switches for service process autorun and for launching process from browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fri 06/20/2014 2:04:49.68 Created 6 years, 6 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/common/service_process_util.h ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/service_process_util.h"
6
5 #include <algorithm> 7 #include <algorithm>
6 8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
10 #include "base/path_service.h" 12 #include "base/path_service.h"
11 #include "base/sha1.h" 13 #include "base/sha1.h"
12 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
16 #include "base/version.h" 18 #include "base/version.h"
17 #include "chrome/common/chrome_constants.h" 19 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/chrome_version_info.h" 22 #include "chrome/common/chrome_version_info.h"
21 #include "chrome/common/service_process_util.h" 23 #include "components/cloud_devices/common/cloud_devices_switches.h"
22 #include "content/public/common/content_paths.h" 24 #include "content/public/common/content_paths.h"
25 #include "google_apis/gaia/gaia_switches.h"
26 #include "ui/base/ui_base_switches.h"
23 27
24 #if !defined(OS_MACOSX) 28 #if !defined(OS_MACOSX)
25 29
26 namespace { 30 namespace {
27 31
28 // This should be more than enough to hold a version string assuming each part 32 // This should be more than enough to hold a version string assuming each part
29 // of the version string is an int64. 33 // of the version string is an int64.
30 const uint32 kMaxVersionStringLength = 256; 34 const uint32 kMaxVersionStringLength = 256;
31 35
32 // The structure that gets written to shared memory. 36 // The structure that gets written to shared memory.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 *version = service_data->service_process_version; 148 *version = service_data->service_process_version;
145 if (pid) 149 if (pid)
146 *pid = service_data->service_process_pid; 150 *pid = service_data->service_process_pid;
147 return true; 151 return true;
148 } 152 }
149 return false; 153 return false;
150 } 154 }
151 155
152 #endif // !OS_MACOSX 156 #endif // !OS_MACOSX
153 157
158 scoped_ptr<base::CommandLine> CreateServiceProcessCommandLine() {
159 base::FilePath exe_path;
160 PathService::Get(content::CHILD_PROCESS_EXE, &exe_path);
161 DCHECK(!exe_path.empty()) << "Unable to get service process binary name.";
162 scoped_ptr<base::CommandLine> command_line(new base::CommandLine(exe_path));
163 command_line->AppendSwitchASCII(switches::kProcessType,
164 switches::kServiceProcess);
165 static const char* const kSwitchesToCopy[] = {
166 switches::kCloudPrintSetupProxy,
167 switches::kCloudPrintURL,
168 switches::kCloudPrintXmppEndpoint,
169 #if defined(OS_WIN)
170 switches::kEnableCloudPrintXps,
171 #endif
172 switches::kEnableLogging,
173 switches::kIgnoreUrlFetcherCertRequests,
174 switches::kLang,
175 switches::kLoggingLevel,
176 switches::kLsoUrl,
177 switches::kNoServiceAutorun,
178 switches::kUserDataDir,
179 switches::kV,
180 switches::kVModule,
181 switches::kWaitForDebugger,
182 };
183
184 command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
185 kSwitchesToCopy,
186 arraysize(kSwitchesToCopy));
187 return command_line.Pass();
188 }
189
154 ServiceProcessState::ServiceProcessState() : state_(NULL) { 190 ServiceProcessState::ServiceProcessState() : state_(NULL) {
155 CreateAutoRunCommandLine(); 191 autorun_command_line_ = CreateServiceProcessCommandLine();
156 CreateState(); 192 CreateState();
157 } 193 }
158 194
159 ServiceProcessState::~ServiceProcessState() { 195 ServiceProcessState::~ServiceProcessState() {
160 #if !defined(OS_MACOSX) 196 #if !defined(OS_MACOSX)
161 if (shared_mem_service_data_.get()) { 197 if (shared_mem_service_data_.get()) {
162 shared_mem_service_data_->Delete(GetServiceProcessSharedMemName()); 198 shared_mem_service_data_->Delete(GetServiceProcessSharedMemName());
163 } 199 }
164 #endif // !OS_MACOSX 200 #endif // !OS_MACOSX
165 TearDownState(); 201 TearDownState();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 shared_data->service_process_pid = base::GetCurrentProcId(); 276 shared_data->service_process_pid = base::GetCurrentProcId();
241 shared_mem_service_data_.reset(shared_mem_service_data.release()); 277 shared_mem_service_data_.reset(shared_mem_service_data.release());
242 return true; 278 return true;
243 } 279 }
244 280
245 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() { 281 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() {
246 return ::GetServiceProcessChannel(); 282 return ::GetServiceProcessChannel();
247 } 283 }
248 284
249 #endif // !OS_MACOSX 285 #endif // !OS_MACOSX
250
251 void ServiceProcessState::CreateAutoRunCommandLine() {
252 base::FilePath exe_path;
253 PathService::Get(content::CHILD_PROCESS_EXE, &exe_path);
254 DCHECK(!exe_path.empty()) << "Unable to get service process binary name.";
255 autorun_command_line_.reset(new CommandLine(exe_path));
256 autorun_command_line_->AppendSwitchASCII(switches::kProcessType,
257 switches::kServiceProcess);
258
259 // The user data directory is the only other flag we currently want to
260 // possibly store.
261 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
262 base::FilePath user_data_dir =
263 browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
264 if (!user_data_dir.empty())
265 autorun_command_line_->AppendSwitchPath(switches::kUserDataDir,
266 user_data_dir);
267 }
OLDNEW
« no previous file with comments | « chrome/common/service_process_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698