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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 CHECK(!mojo_ipc_channel_) |
62 << "Destroying ChildProcessHost before calling Join"; | 62 << "Destroying ChildProcessHost before calling Join"; |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 mojom::ShellClientPtr 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 = |
73 base::CommandLine::ForCurrentProcess(); | 73 base::CommandLine::ForCurrentProcess(); |
74 base::FilePath target_path = parent_command_line->GetProgram(); | 74 base::FilePath target_path = parent_command_line->GetProgram(); |
75 // |app_path_| can be empty in tests. | 75 // |app_path_| can be empty in tests. |
76 if (!app_path_.MatchesExtension(FILE_PATH_LITERAL(".mojo")) && | 76 if (!app_path_.MatchesExtension(FILE_PATH_LITERAL(".mojo")) && |
(...skipping 14 matching lines...) Expand all Loading... |
91 if (target_path != app_path_) | 91 if (target_path != app_path_) |
92 child_command_line->AppendSwitchPath(switches::kChildProcess, app_path_); | 92 child_command_line->AppendSwitchPath(switches::kChildProcess, app_path_); |
93 | 93 |
94 if (start_sandboxed_) | 94 if (start_sandboxed_) |
95 child_command_line->AppendSwitch(switches::kEnableSandbox); | 95 child_command_line->AppendSwitch(switches::kEnableSandbox); |
96 | 96 |
97 mojo_ipc_channel_.reset(new mojo::edk::PlatformChannelPair); | 97 mojo_ipc_channel_.reset(new mojo::edk::PlatformChannelPair); |
98 mojo_ipc_channel_->PrepareToPassClientHandleToChildProcess( | 98 mojo_ipc_channel_->PrepareToPassClientHandleToChildProcess( |
99 child_command_line.get(), &handle_passing_info_); | 99 child_command_line.get(), &handle_passing_info_); |
100 | 100 |
101 mojom::ShellClientPtr client = | 101 mojom::ServicePtr client = |
102 PassShellClientRequestOnCommandLine(child_command_line.get(), | 102 PassServiceRequestOnCommandLine(child_command_line.get(), |
103 child_token_); | 103 child_token_); |
104 launch_process_runner_->PostTaskAndReply( | 104 launch_process_runner_->PostTaskAndReply( |
105 FROM_HERE, | 105 FROM_HERE, |
106 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this), | 106 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this), |
107 base::Passed(&child_command_line)), | 107 base::Passed(&child_command_line)), |
108 base::Bind(&ChildProcessHost::DidStart, | 108 base::Bind(&ChildProcessHost::DidStart, |
109 weak_factory_.GetWeakPtr(), callback)); | 109 weak_factory_.GetWeakPtr(), callback)); |
110 return client; | 110 return client; |
111 } | 111 } |
112 | 112 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 child_process_.Handle(), | 205 child_process_.Handle(), |
206 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( | 206 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( |
207 mojo_ipc_channel_->PassServerHandle().release().handle)), | 207 mojo_ipc_channel_->PassServerHandle().release().handle)), |
208 child_token_); | 208 child_token_); |
209 } | 209 } |
210 } | 210 } |
211 start_child_process_event_.Signal(); | 211 start_child_process_event_.Signal(); |
212 } | 212 } |
213 | 213 |
214 } // namespace shell | 214 } // namespace shell |
OLD | NEW |