Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: services/shell/runner/host/child_process_host.cc

Issue 2019973002: [mojo-edk] Bind a child token to child launches and port reservations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert stuff. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_(false, false), 54 start_child_process_event_(false, false),
54 weak_factory_(this) { 55 weak_factory_(this) {
55 } 56 }
56 57
57 ChildProcessHost::~ChildProcessHost() { 58 ChildProcessHost::~ChildProcessHost() {
58 if (!app_path_.empty()) { 59 if (!app_path_.empty()) {
59 CHECK(!mojo_ipc_channel_) 60 CHECK(!mojo_ipc_channel_)
60 << "Destroying ChildProcessHost before calling Join"; 61 << "Destroying ChildProcessHost before calling Join";
61 } 62 }
62 } 63 }
(...skipping 27 matching lines...) Expand all
90 child_command_line->AppendSwitchPath(switches::kChildProcess, app_path_); 91 child_command_line->AppendSwitchPath(switches::kChildProcess, app_path_);
91 92
92 if (start_sandboxed_) 93 if (start_sandboxed_)
93 child_command_line->AppendSwitch(switches::kEnableSandbox); 94 child_command_line->AppendSwitch(switches::kEnableSandbox);
94 95
95 mojo_ipc_channel_.reset(new mojo::edk::PlatformChannelPair); 96 mojo_ipc_channel_.reset(new mojo::edk::PlatformChannelPair);
96 mojo_ipc_channel_->PrepareToPassClientHandleToChildProcess( 97 mojo_ipc_channel_->PrepareToPassClientHandleToChildProcess(
97 child_command_line.get(), &handle_passing_info_); 98 child_command_line.get(), &handle_passing_info_);
98 99
99 mojom::ShellClientPtr client = 100 mojom::ShellClientPtr client =
100 PassShellClientRequestOnCommandLine(child_command_line.get()); 101 PassShellClientRequestOnCommandLine(child_command_line.get(),
102 child_token_);
101 launch_process_runner_->PostTaskAndReply( 103 launch_process_runner_->PostTaskAndReply(
102 FROM_HERE, 104 FROM_HERE,
103 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this), 105 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this),
104 base::Passed(&child_command_line)), 106 base::Passed(&child_command_line)),
105 base::Bind(&ChildProcessHost::DidStart, 107 base::Bind(&ChildProcessHost::DidStart,
106 weak_factory_.GetWeakPtr(), callback)); 108 weak_factory_.GetWeakPtr(), callback));
107 return client; 109 return client;
108 } 110 }
109 111
110 void ChildProcessHost::Join() { 112 void ChildProcessHost::Join() {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 mach_broker->ExpectPid(child_process_.Handle()); 196 mach_broker->ExpectPid(child_process_.Handle());
195 #endif 197 #endif
196 } 198 }
197 199
198 if (child_process_.IsValid()) { 200 if (child_process_.IsValid()) {
199 if (mojo_ipc_channel_.get()) { 201 if (mojo_ipc_channel_.get()) {
200 mojo_ipc_channel_->ChildProcessLaunched(); 202 mojo_ipc_channel_->ChildProcessLaunched();
201 mojo::edk::ChildProcessLaunched( 203 mojo::edk::ChildProcessLaunched(
202 child_process_.Handle(), 204 child_process_.Handle(),
203 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( 205 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle(
204 mojo_ipc_channel_->PassServerHandle().release().handle))); 206 mojo_ipc_channel_->PassServerHandle().release().handle)),
207 child_token_);
205 } 208 }
206 } 209 }
207 start_child_process_event_.Signal(); 210 start_child_process_event_.Signal();
208 } 211 }
209 212
210 } // namespace shell 213 } // namespace shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698