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/shell/runner/host/child_process_host.h" | 5 #include "services/shell/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 ChildProcessHost::ChildProcessHost(base::TaskRunner* launch_process_runner, | 43 ChildProcessHost::ChildProcessHost(base::TaskRunner* launch_process_runner, |
44 NativeRunnerDelegate* delegate, | 44 NativeRunnerDelegate* delegate, |
45 bool start_sandboxed, | 45 bool start_sandboxed, |
46 const Identity& target, | 46 const Identity& target, |
47 const base::FilePath& app_path) | 47 const base::FilePath& app_path) |
48 : launch_process_runner_(launch_process_runner), | 48 : launch_process_runner_(launch_process_runner), |
49 delegate_(delegate), | 49 delegate_(delegate), |
50 start_sandboxed_(start_sandboxed), | 50 start_sandboxed_(start_sandboxed), |
51 target_(target), | 51 target_(target), |
52 app_path_(app_path), | 52 app_path_(app_path), |
| 53 child_token_(mojo::edk::GenerateRandomToken()), |
53 start_child_process_event_( | 54 start_child_process_event_( |
54 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 55 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
55 base::WaitableEvent::InitialState::NOT_SIGNALED), | 56 base::WaitableEvent::InitialState::NOT_SIGNALED), |
56 weak_factory_(this) {} | 57 weak_factory_(this) {} |
57 | 58 |
58 ChildProcessHost::~ChildProcessHost() { | 59 ChildProcessHost::~ChildProcessHost() { |
59 if (!app_path_.empty()) { | 60 if (!app_path_.empty()) { |
60 CHECK(!mojo_ipc_channel_) | 61 CHECK(!mojo_ipc_channel_) |
61 << "Destroying ChildProcessHost before calling Join"; | 62 << "Destroying ChildProcessHost before calling Join"; |
62 } | 63 } |
(...skipping 28 matching lines...) Expand all Loading... |
91 child_command_line->AppendSwitchPath(switches::kChildProcess, app_path_); | 92 child_command_line->AppendSwitchPath(switches::kChildProcess, app_path_); |
92 | 93 |
93 if (start_sandboxed_) | 94 if (start_sandboxed_) |
94 child_command_line->AppendSwitch(switches::kEnableSandbox); | 95 child_command_line->AppendSwitch(switches::kEnableSandbox); |
95 | 96 |
96 mojo_ipc_channel_.reset(new mojo::edk::PlatformChannelPair); | 97 mojo_ipc_channel_.reset(new mojo::edk::PlatformChannelPair); |
97 mojo_ipc_channel_->PrepareToPassClientHandleToChildProcess( | 98 mojo_ipc_channel_->PrepareToPassClientHandleToChildProcess( |
98 child_command_line.get(), &handle_passing_info_); | 99 child_command_line.get(), &handle_passing_info_); |
99 | 100 |
100 mojom::ShellClientPtr client = | 101 mojom::ShellClientPtr client = |
101 PassShellClientRequestOnCommandLine(child_command_line.get()); | 102 PassShellClientRequestOnCommandLine(child_command_line.get(), |
| 103 child_token_); |
102 launch_process_runner_->PostTaskAndReply( | 104 launch_process_runner_->PostTaskAndReply( |
103 FROM_HERE, | 105 FROM_HERE, |
104 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this), | 106 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this), |
105 base::Passed(&child_command_line)), | 107 base::Passed(&child_command_line)), |
106 base::Bind(&ChildProcessHost::DidStart, | 108 base::Bind(&ChildProcessHost::DidStart, |
107 weak_factory_.GetWeakPtr(), callback)); | 109 weak_factory_.GetWeakPtr(), callback)); |
108 return client; | 110 return client; |
109 } | 111 } |
110 | 112 |
111 void ChildProcessHost::Join() { | 113 void ChildProcessHost::Join() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 mach_broker->ExpectPid(child_process_.Handle()); | 197 mach_broker->ExpectPid(child_process_.Handle()); |
196 #endif | 198 #endif |
197 } | 199 } |
198 | 200 |
199 if (child_process_.IsValid()) { | 201 if (child_process_.IsValid()) { |
200 if (mojo_ipc_channel_.get()) { | 202 if (mojo_ipc_channel_.get()) { |
201 mojo_ipc_channel_->ChildProcessLaunched(); | 203 mojo_ipc_channel_->ChildProcessLaunched(); |
202 mojo::edk::ChildProcessLaunched( | 204 mojo::edk::ChildProcessLaunched( |
203 child_process_.Handle(), | 205 child_process_.Handle(), |
204 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( | 206 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( |
205 mojo_ipc_channel_->PassServerHandle().release().handle))); | 207 mojo_ipc_channel_->PassServerHandle().release().handle)), |
| 208 child_token_); |
206 } | 209 } |
207 } | 210 } |
208 start_child_process_event_.Signal(); | 211 start_child_process_event_.Signal(); |
209 } | 212 } |
210 | 213 |
211 } // namespace shell | 214 } // namespace shell |
OLD | NEW |