| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/service_process_launcher.h" | 5 #include "services/service_manager/runner/host/service_process_launcher.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 33 #include "base/win/windows_version.h" | 33 #include "base/win/windows_version.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
| 37 #include "services/service_manager/public/cpp/standalone_service/mach_broker.h" | 37 #include "services/service_manager/public/cpp/standalone_service/mach_broker.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 #if defined(OS_WIN) && defined(COMPONENT_BUILD) | |
| 41 #include <windows.h> | |
| 42 | |
| 43 namespace { | |
| 44 | |
| 45 class ScopedDllDirectoryOverride { | |
| 46 public: | |
| 47 explicit ScopedDllDirectoryOverride(const base::FilePath& path) { | |
| 48 SetDllDirectory(path.value().c_str()); | |
| 49 } | |
| 50 | |
| 51 ~ScopedDllDirectoryOverride() { | |
| 52 SetDllDirectory(NULL); | |
| 53 } | |
| 54 | |
| 55 private: | |
| 56 DISALLOW_COPY_AND_ASSIGN(ScopedDllDirectoryOverride); | |
| 57 }; | |
| 58 | |
| 59 } // namespace | |
| 60 #endif // defined(OS_WIN) && defined(COMPONENT_BUILD) | |
| 61 | |
| 62 namespace service_manager { | 40 namespace service_manager { |
| 63 | 41 |
| 64 ServiceProcessLauncher::ServiceProcessLauncher( | 42 ServiceProcessLauncher::ServiceProcessLauncher( |
| 65 base::TaskRunner* launch_process_runner, | 43 base::TaskRunner* launch_process_runner, |
| 66 Delegate* delegate, | 44 Delegate* delegate, |
| 67 const base::FilePath& service_path) | 45 const base::FilePath& service_path) |
| 68 : launch_process_runner_(launch_process_runner), | 46 : launch_process_runner_(launch_process_runner), |
| 69 delegate_(delegate), | 47 delegate_(delegate), |
| 70 start_sandboxed_(false), | 48 start_sandboxed_(false), |
| 71 service_path_(service_path), | 49 service_path_(service_path), |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (!child_process_.IsValid()) { | 193 if (!child_process_.IsValid()) { |
| 216 LOG(ERROR) << "Starting the process with a sandbox failed. Missing kernel" | 194 LOG(ERROR) << "Starting the process with a sandbox failed. Missing kernel" |
| 217 << " support."; | 195 << " support."; |
| 218 } | 196 } |
| 219 } else | 197 } else |
| 220 #endif | 198 #endif |
| 221 { | 199 { |
| 222 #if defined(OS_MACOSX) | 200 #if defined(OS_MACOSX) |
| 223 MachBroker* mach_broker = MachBroker::GetInstance(); | 201 MachBroker* mach_broker = MachBroker::GetInstance(); |
| 224 base::AutoLock locker(mach_broker->GetLock()); | 202 base::AutoLock locker(mach_broker->GetLock()); |
| 225 #elif defined(OS_WIN) && defined(COMPONENT_BUILD) | |
| 226 ScopedDllDirectoryOverride dll_override(exe_dir); | |
| 227 #endif | 203 #endif |
| 228 child_process_ = base::LaunchProcess(*child_command_line, options); | 204 child_process_ = base::LaunchProcess(*child_command_line, options); |
| 229 #if defined(OS_MACOSX) | 205 #if defined(OS_MACOSX) |
| 230 mach_broker->ExpectPid(child_process_.Handle()); | 206 mach_broker->ExpectPid(child_process_.Handle()); |
| 231 #endif | 207 #endif |
| 232 } | 208 } |
| 233 | 209 |
| 234 if (child_process_.IsValid()) { | 210 if (child_process_.IsValid()) { |
| 235 DVLOG(0) << "Launched child process pid=" << child_process_.Pid() | 211 DVLOG(0) << "Launched child process pid=" << child_process_.Pid() |
| 236 << ", instance=" << target_.instance() | 212 << ", instance=" << target_.instance() |
| 237 << ", name=" << target_.name() | 213 << ", name=" << target_.name() |
| 238 << ", user_id=" << target_.user_id(); | 214 << ", user_id=" << target_.user_id(); |
| 239 | 215 |
| 240 if (mojo_ipc_channel_.get()) { | 216 if (mojo_ipc_channel_.get()) { |
| 241 mojo_ipc_channel_->ChildProcessLaunched(); | 217 mojo_ipc_channel_->ChildProcessLaunched(); |
| 242 mojo::edk::ChildProcessLaunched( | 218 mojo::edk::ChildProcessLaunched( |
| 243 child_process_.Handle(), | 219 child_process_.Handle(), |
| 244 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( | 220 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( |
| 245 mojo_ipc_channel_->PassServerHandle().release().handle)), | 221 mojo_ipc_channel_->PassServerHandle().release().handle)), |
| 246 child_token_); | 222 child_token_); |
| 247 } | 223 } |
| 248 } | 224 } |
| 249 start_child_process_event_.Signal(); | 225 start_child_process_event_.Signal(); |
| 250 } | 226 } |
| 251 | 227 |
| 252 } // namespace service_manager | 228 } // namespace service_manager |
| OLD | NEW |