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

Side by Side Diff: services/service_manager/runner/host/child_process_host.cc

Issue 2574653002: Service Manager: Override DLL search path when launching services in component builds (Closed)
Patch Set: . Created 4 years 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
« no previous file with comments | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/service_manager/runner/host/child_process_host.h" 5 #include "services/service_manager/runner/host/child_process_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/base_paths.h" 11 #include "base/base_paths.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h"
14 #include "base/location.h" 15 #include "base/location.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
18 #include "base/path_service.h" 19 #include "base/path_service.h"
19 #include "base/process/kill.h" 20 #include "base/process/kill.h"
20 #include "base/process/launch.h" 21 #include "base/process/launch.h"
21 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
22 #include "base/task_runner.h" 23 #include "base/task_runner.h"
23 #include "base/threading/thread_task_runner_handle.h" 24 #include "base/threading/thread_task_runner_handle.h"
(...skipping 10 matching lines...) Expand all
34 #endif 35 #endif
35 36
36 #if defined(OS_WIN) 37 #if defined(OS_WIN)
37 #include "base/win/windows_version.h" 38 #include "base/win/windows_version.h"
38 #endif 39 #endif
39 40
40 #if defined(OS_MACOSX) 41 #if defined(OS_MACOSX)
41 #include "services/service_manager/public/cpp/standalone_service/mach_broker.h" 42 #include "services/service_manager/public/cpp/standalone_service/mach_broker.h"
42 #endif 43 #endif
43 44
45 #if defined(OS_WIN) && defined(COMPONENT_BUILD)
46 #include <windows.h>
47
48 namespace {
49
50 class ScopedDllDirectoryOverride {
51 public:
52 explicit ScopedDllDirectoryOverride(const base::FilePath& path) {
53 SetDllDirectory(path.value().c_str());
54 }
55
56 ~ScopedDllDirectoryOverride() {
57 SetDllDirectory(NULL);
58 }
59
60 private:
61 DISALLOW_COPY_AND_ASSIGN(ScopedDllDirectoryOverride);
62 };
63
64 } // namespace
65 #endif // defined(OS_WIN) && defined(COMPONENT_BUILD)
66
44 namespace service_manager { 67 namespace service_manager {
45 68
46 ChildProcessHost::ChildProcessHost(base::TaskRunner* launch_process_runner, 69 ChildProcessHost::ChildProcessHost(base::TaskRunner* launch_process_runner,
47 NativeRunnerDelegate* delegate, 70 NativeRunnerDelegate* delegate,
48 bool start_sandboxed, 71 bool start_sandboxed,
49 const Identity& target, 72 const Identity& target,
50 const base::FilePath& service_path) 73 const base::FilePath& service_path)
51 : launch_process_runner_(launch_process_runner), 74 : launch_process_runner_(launch_process_runner),
52 delegate_(delegate), 75 delegate_(delegate),
53 start_sandboxed_(start_sandboxed), 76 start_sandboxed_(start_sandboxed),
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (!child_process_.IsValid()) { 221 if (!child_process_.IsValid()) {
199 LOG(ERROR) << "Starting the process with a sandbox failed. Missing kernel" 222 LOG(ERROR) << "Starting the process with a sandbox failed. Missing kernel"
200 << " support."; 223 << " support.";
201 } 224 }
202 } else 225 } else
203 #endif 226 #endif
204 { 227 {
205 #if defined(OS_MACOSX) 228 #if defined(OS_MACOSX)
206 MachBroker* mach_broker = MachBroker::GetInstance(); 229 MachBroker* mach_broker = MachBroker::GetInstance();
207 base::AutoLock locker(mach_broker->GetLock()); 230 base::AutoLock locker(mach_broker->GetLock());
231 #elif defined(OS_WIN) && defined(COMPONENT_BUILD)
232 ScopedDllDirectoryOverride dll_override(exe_dir);
208 #endif 233 #endif
209 child_process_ = base::LaunchProcess(*child_command_line, options); 234 child_process_ = base::LaunchProcess(*child_command_line, options);
210 #if defined(OS_MACOSX) 235 #if defined(OS_MACOSX)
211 mach_broker->ExpectPid(child_process_.Handle()); 236 mach_broker->ExpectPid(child_process_.Handle());
212 #endif 237 #endif
213 } 238 }
214 239
215 if (child_process_.IsValid()) { 240 if (child_process_.IsValid()) {
216 DVLOG(0) << "Launched child process pid=" << child_process_.Pid() 241 DVLOG(0) << "Launched child process pid=" << child_process_.Pid()
217 << ", instance=" << target_.instance() 242 << ", instance=" << target_.instance()
218 << ", name=" << target_.name() 243 << ", name=" << target_.name()
219 << ", user_id=" << target_.user_id(); 244 << ", user_id=" << target_.user_id();
220 245
221 if (mojo_ipc_channel_.get()) { 246 if (mojo_ipc_channel_.get()) {
222 mojo_ipc_channel_->ChildProcessLaunched(); 247 mojo_ipc_channel_->ChildProcessLaunched();
223 mojo::edk::ChildProcessLaunched( 248 mojo::edk::ChildProcessLaunched(
224 child_process_.Handle(), 249 child_process_.Handle(),
225 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( 250 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle(
226 mojo_ipc_channel_->PassServerHandle().release().handle)), 251 mojo_ipc_channel_->PassServerHandle().release().handle)),
227 child_token_); 252 child_token_);
228 } 253 }
229 } 254 }
230 start_child_process_event_.Signal(); 255 start_child_process_event_.Signal();
231 } 256 }
232 257
233 } // namespace service_manager 258 } // namespace service_manager
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698