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 "mojo/runner/host/child_process_host.h" | 5 #include "mojo/runner/host/child_process_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 ChildProcessHost::ChildProcessHost(base::TaskRunner* launch_process_runner, | 33 ChildProcessHost::ChildProcessHost(base::TaskRunner* launch_process_runner, |
34 bool start_sandboxed, | 34 bool start_sandboxed, |
35 const base::FilePath& app_path) | 35 const base::FilePath& app_path) |
36 : launch_process_runner_(launch_process_runner), | 36 : launch_process_runner_(launch_process_runner), |
37 start_sandboxed_(start_sandboxed), | 37 start_sandboxed_(start_sandboxed), |
38 app_path_(app_path), | 38 app_path_(app_path), |
39 channel_info_(nullptr), | 39 channel_info_(nullptr), |
40 start_child_process_event_(false, false), | 40 start_child_process_event_(false, false), |
41 weak_factory_(this) { | 41 weak_factory_(this) { |
42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 43 // TODO(jam): enable on POSIX |
43 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) | 44 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) |
44 serializer_platform_channel_pair_.reset(new edk::PlatformChannelPair(true)); | 45 serializer_platform_channel_pair_.reset(new edk::PlatformChannelPair(true)); |
45 #endif | 46 #endif |
46 | 47 |
47 child_message_pipe_ = embedder::CreateChannel( | 48 child_message_pipe_ = embedder::CreateChannel( |
48 platform_channel_pair_.PassServerHandle(), | 49 platform_channel_pair_.PassServerHandle(), |
49 base::Bind(&ChildProcessHost::DidCreateChannel, base::Unretained(this)), | 50 base::Bind(&ChildProcessHost::DidCreateChannel, base::Unretained(this)), |
50 base::ThreadTaskRunnerHandle::Get()); | 51 base::ThreadTaskRunnerHandle::Get()); |
51 } | 52 } |
52 | 53 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 #endif | 204 #endif |
204 child_process_ = base::LaunchProcess(child_command_line, options); | 205 child_process_ = base::LaunchProcess(child_command_line, options); |
205 | 206 |
206 if (child_process_.IsValid()) { | 207 if (child_process_.IsValid()) { |
207 platform_channel_pair_.ChildProcessLaunched(); | 208 platform_channel_pair_.ChildProcessLaunched(); |
208 #if defined(OS_WIN) | 209 #if defined(OS_WIN) |
209 if (serializer_platform_channel_pair_.get()) { | 210 if (serializer_platform_channel_pair_.get()) { |
210 serializer_platform_channel_pair_->ChildProcessLaunched(); | 211 serializer_platform_channel_pair_->ChildProcessLaunched(); |
211 mojo::embedder::ChildProcessLaunched( | 212 mojo::embedder::ChildProcessLaunched( |
212 child_process_.Handle(), | 213 child_process_.Handle(), |
213 serializer_platform_channel_pair_->PassServerHandle() | 214 mojo::embedder::ScopedPlatformHandle(mojo::embedder::PlatformHandle( |
214 .release() | 215 serializer_platform_channel_pair_->PassServerHandle().release(). |
215 .handle); | 216 #if defined(OS_WIN) |
| 217 handle |
| 218 #else |
| 219 fd |
| 220 #endif |
| 221 ))); |
216 } | 222 } |
217 #endif | 223 #endif |
218 } | 224 } |
219 start_child_process_event_.Signal(); | 225 start_child_process_event_.Signal(); |
220 } | 226 } |
221 | 227 |
222 void ChildProcessHost::AppCompleted(int32_t result) { | 228 void ChildProcessHost::AppCompleted(int32_t result) { |
223 if (!on_app_complete_.is_null()) { | 229 if (!on_app_complete_.is_null()) { |
224 auto on_app_complete = on_app_complete_; | 230 auto on_app_complete = on_app_complete_; |
225 on_app_complete_.reset(); | 231 on_app_complete_.reset(); |
226 on_app_complete.Run(result); | 232 on_app_complete.Run(result); |
227 } | 233 } |
228 } | 234 } |
229 | 235 |
230 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { | 236 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { |
231 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; | 237 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; |
232 | 238 |
233 DCHECK(channel_info || | 239 DCHECK(channel_info || |
234 base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")); | 240 base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")); |
235 channel_info_ = channel_info; | 241 channel_info_ = channel_info; |
236 } | 242 } |
237 | 243 |
238 } // namespace runner | 244 } // namespace runner |
239 } // namespace mojo | 245 } // namespace mojo |
OLD | NEW |