| OLD | NEW |
| 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 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 target_(target), | 51 target_(target), |
| 52 app_path_(app_path), | 52 app_path_(app_path), |
| 53 child_token_(mojo::edk::GenerateRandomToken()), | 53 child_token_(mojo::edk::GenerateRandomToken()), |
| 54 start_child_process_event_( | 54 start_child_process_event_( |
| 55 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 55 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 56 base::WaitableEvent::InitialState::NOT_SIGNALED), | 56 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 57 weak_factory_(this) {} | 57 weak_factory_(this) {} |
| 58 | 58 |
| 59 ChildProcessHost::~ChildProcessHost() { | 59 ChildProcessHost::~ChildProcessHost() { |
| 60 if (!app_path_.empty()) { | 60 if (!app_path_.empty()) { |
| 61 CHECK(!mojo_ipc_channel_) | 61 // Destroying ChildProcessHost before calling Join |
| 62 << "Destroying ChildProcessHost before calling Join"; | 62 CHECK(!mojo_ipc_channel_); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 mojom::ServicePtr ChildProcessHost::Start( | 66 mojom::ServicePtr ChildProcessHost::Start( |
| 67 const Identity& target, | 67 const Identity& target, |
| 68 const ProcessReadyCallback& callback, | 68 const ProcessReadyCallback& callback, |
| 69 const base::Closure& quit_closure) { | 69 const base::Closure& quit_closure) { |
| 70 DCHECK(!child_process_.IsValid()); | 70 DCHECK(!child_process_.IsValid()); |
| 71 | 71 |
| 72 const base::CommandLine* parent_command_line = | 72 const base::CommandLine* parent_command_line = |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 std::unique_ptr<base::CommandLine> child_command_line) { | 136 std::unique_ptr<base::CommandLine> child_command_line) { |
| 137 if (delegate_) { | 137 if (delegate_) { |
| 138 delegate_->AdjustCommandLineArgumentsForTarget(target_, | 138 delegate_->AdjustCommandLineArgumentsForTarget(target_, |
| 139 child_command_line.get()); | 139 child_command_line.get()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 base::LaunchOptions options; | 142 base::LaunchOptions options; |
| 143 #if defined(OS_WIN) | 143 #if defined(OS_WIN) |
| 144 options.handles_to_inherit = &handle_passing_info_; | 144 options.handles_to_inherit = &handle_passing_info_; |
| 145 #if defined(OFFICIAL_BUILD) | 145 #if defined(OFFICIAL_BUILD) |
| 146 CHECK(false) << "Launching mojo process with inherit_handles is insecure!"; | 146 // Launching mojo process with inherit_handles is insecure! |
| 147 CHECK(false); |
| 147 #endif | 148 #endif |
| 148 options.inherit_handles = true; | 149 options.inherit_handles = true; |
| 149 options.stdin_handle = INVALID_HANDLE_VALUE; | 150 options.stdin_handle = INVALID_HANDLE_VALUE; |
| 150 options.stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); | 151 options.stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); |
| 151 options.stderr_handle = GetStdHandle(STD_ERROR_HANDLE); | 152 options.stderr_handle = GetStdHandle(STD_ERROR_HANDLE); |
| 152 // Always inherit stdout/stderr as a pair. | 153 // Always inherit stdout/stderr as a pair. |
| 153 if (!options.stdout_handle || !options.stdin_handle) | 154 if (!options.stdout_handle || !options.stdin_handle) |
| 154 options.stdin_handle = options.stdout_handle = nullptr; | 155 options.stdin_handle = options.stdout_handle = nullptr; |
| 155 | 156 |
| 156 // Pseudo handles are used when stdout and stderr redirect to the console. In | 157 // Pseudo handles are used when stdout and stderr redirect to the console. In |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 child_process_.Handle(), | 211 child_process_.Handle(), |
| 211 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( | 212 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( |
| 212 mojo_ipc_channel_->PassServerHandle().release().handle)), | 213 mojo_ipc_channel_->PassServerHandle().release().handle)), |
| 213 child_token_); | 214 child_token_); |
| 214 } | 215 } |
| 215 } | 216 } |
| 216 start_child_process_event_.Signal(); | 217 start_child_process_event_.Signal(); |
| 217 } | 218 } |
| 218 | 219 |
| 219 } // namespace service_manager | 220 } // namespace service_manager |
| OLD | NEW |