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

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

Issue 6591002: Removed the command line from ServiceProcessState::AddToAutoRun() and had the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/command_line.h"
7 #include "base/file_util.h" 8 #include "base/file_util.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/mac/scoped_nsautorelease_pool.h" 10 #include "base/mac/scoped_nsautorelease_pool.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "base/process_util.h" 12 #include "base/process_util.h"
12 #include "base/sha1.h" 13 #include "base/sha1.h"
13 #include "base/singleton.h" 14 #include "base/singleton.h"
14 #include "base/string16.h" 15 #include "base/string16.h"
15 #include "base/string_number_conversions.h" 16 #include "base/string_number_conversions.h"
16 #include "base/string_util.h" 17 #include "base/string_util.h"
17 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
18 #include "base/version.h" 19 #include "base/version.h"
20 #include "chrome/common/child_process_host.h"
19 #include "chrome/common/chrome_constants.h" 21 #include "chrome/common/chrome_constants.h"
20 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/chrome_version_info.h" 24 #include "chrome/common/chrome_version_info.h"
22 #include "chrome/common/service_process_util.h" 25 #include "chrome/common/service_process_util.h"
23 26
24 #if !defined(OS_MACOSX) 27 #if !defined(OS_MACOSX)
25 28
26 namespace { 29 namespace {
27 30
28 // This should be more than enough to hold a version string assuming each part 31 // This should be more than enough to hold a version string assuming each part
29 // of the version string is an int64. 32 // of the version string is an int64.
30 const uint32 kMaxVersionStringLength = 256; 33 const uint32 kMaxVersionStringLength = 256;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 154 }
152 155
153 // Gets the name of the service process IPC channel. 156 // Gets the name of the service process IPC channel.
154 IPC::ChannelHandle GetServiceProcessChannel() { 157 IPC::ChannelHandle GetServiceProcessChannel() {
155 return GetServiceProcessScopedVersionedName("_service_ipc"); 158 return GetServiceProcessScopedVersionedName("_service_ipc");
156 } 159 }
157 160
158 #endif // !OS_MACOSX 161 #endif // !OS_MACOSX
159 162
160 ServiceProcessState::ServiceProcessState() : state_(NULL) { 163 ServiceProcessState::ServiceProcessState() : state_(NULL) {
164 CreateAutoRunCommandLine();
161 } 165 }
162 166
163 ServiceProcessState::~ServiceProcessState() { 167 ServiceProcessState::~ServiceProcessState() {
164 #if !defined(OS_MACOSX) 168 #if !defined(OS_MACOSX)
165 if (shared_mem_service_data_.get()) { 169 if (shared_mem_service_data_.get()) {
166 shared_mem_service_data_->Delete(GetServiceProcessSharedMemName()); 170 shared_mem_service_data_->Delete(GetServiceProcessSharedMemName());
167 } 171 }
168 #endif // !OS_MACOSX 172 #endif // !OS_MACOSX
169 TearDownState(); 173 TearDownState();
170 } 174 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 shared_data->service_process_pid = base::GetCurrentProcId(); 255 shared_data->service_process_pid = base::GetCurrentProcId();
252 shared_mem_service_data_.reset(shared_mem_service_data.release()); 256 shared_mem_service_data_.reset(shared_mem_service_data.release());
253 return true; 257 return true;
254 } 258 }
255 259
256 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() { 260 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() {
257 return ::GetServiceProcessChannel(); 261 return ::GetServiceProcessChannel();
258 } 262 }
259 263
260 #endif // !OS_MACOSX 264 #endif // !OS_MACOSX
265
266 void ServiceProcessState::CreateAutoRunCommandLine() {
267 FilePath exe_path = ChildProcessHost::GetChildPath(false);
268 if (exe_path.empty()) {
269 NOTREACHED() << "Unable to get service process binary name.";
270 }
271 autorun_command_line_.reset(new CommandLine(exe_path));
272 autorun_command_line_->AppendSwitchASCII(switches::kProcessType,
273 switches::kServiceProcess);
274
275 // The user data directory is the only other flag we currently want to
276 // possibly store.
277 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
278 FilePath user_data_dir =
279 browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
280 if (!user_data_dir.empty())
281 autorun_command_line_->AppendSwitchPath(switches::kUserDataDir,
282 user_data_dir);
283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698