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

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

Issue 1675153002: ApplicationImpl->ShellConnection, mojom::Application->mojom::ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ci2
Patch Set: . Created 4 years, 10 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 "mojo/shell/runner/host/child_process_host.h" 5 #include "mojo/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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // With the new EDK, bootstrap message pipes are created asynchronously. 106 // With the new EDK, bootstrap message pipes are created asynchronously.
107 // We recieve the bound pipe (if successful) on an arbitrary thread, 107 // We recieve the bound pipe (if successful) on an arbitrary thread,
108 // stash it in the thread-safe |pipe_holder_|, and then try to call 108 // stash it in the thread-safe |pipe_holder_|, and then try to call
109 // OnMessagePipeCreated() on the host's main thread. 109 // OnMessagePipeCreated() on the host's main thread.
110 // 110 //
111 // Because of the way the launcher process shuts down, it's possible for 111 // Because of the way the launcher process shuts down, it's possible for
112 // the main thread's MessageLoop to stop running (but not yet be destroyed!) 112 // the main thread's MessageLoop to stop running (but not yet be destroyed!)
113 // while this boostrap is pending, resulting in OnMessagePipeCreated() never 113 // while this boostrap is pending, resulting in OnMessagePipeCreated() never
114 // being called. 114 // being called.
115 // 115 //
116 // A typical child process (i.e. one using ApplicationImpl to bind the other 116 // A typical child process (i.e. one using ShellConnection to bind the other
117 // end of this pipe) may hang forever waiting for an Initialize() message 117 // end of this pipe) may hang forever waiting for an Initialize() message
118 // unless the pipe is closed. This in turn means that Join() could hang 118 // unless the pipe is closed. This in turn means that Join() could hang
119 // waiting for the process to exit. Deadlock! 119 // waiting for the process to exit. Deadlock!
120 // 120 //
121 // |pipe_holder_| exists for this reason. If it's still holding onto the 121 // |pipe_holder_| exists for this reason. If it's still holding onto the
122 // pipe when Join() is called, the pipe will be closed. 122 // pipe when Join() is called, the pipe will be closed.
123 DCHECK(!primordial_pipe_token_.empty()); 123 DCHECK(!primordial_pipe_token_.empty());
124 edk::CreateParentMessagePipe( 124 edk::CreateParentMessagePipe(
125 primordial_pipe_token_, 125 primordial_pipe_token_,
126 base::Bind(&OnParentMessagePipeCreated, pipe_holder_, 126 base::Bind(&OnParentMessagePipeCreated, pipe_holder_,
(...skipping 22 matching lines...) Expand all
149 int rv = -1; 149 int rv = -1;
150 LOG_IF(ERROR, !child_process_.WaitForExit(&rv)) 150 LOG_IF(ERROR, !child_process_.WaitForExit(&rv))
151 << "Failed to wait for child process"; 151 << "Failed to wait for child process";
152 152
153 child_process_.Close(); 153 child_process_.Close();
154 154
155 return rv; 155 return rv;
156 } 156 }
157 157
158 void ChildProcessHost::StartApp( 158 void ChildProcessHost::StartApp(
159 InterfaceRequest<mojom::Application> application_request, 159 InterfaceRequest<mojom::ShellClient> request,
160 const mojom::ChildController::StartAppCallback& on_app_complete) { 160 const mojom::ChildController::StartAppCallback& on_app_complete) {
161 DCHECK(controller_); 161 DCHECK(controller_);
162 162
163 on_app_complete_ = on_app_complete; 163 on_app_complete_ = on_app_complete;
164 controller_->StartApp( 164 controller_->StartApp(
165 std::move(application_request), 165 std::move(request),
166 base::Bind(&ChildProcessHost::AppCompleted, weak_factory_.GetWeakPtr())); 166 base::Bind(&ChildProcessHost::AppCompleted, weak_factory_.GetWeakPtr()));
167 } 167 }
168 168
169 void ChildProcessHost::ExitNow(int32_t exit_code) { 169 void ChildProcessHost::ExitNow(int32_t exit_code) {
170 DCHECK(controller_); 170 DCHECK(controller_);
171 171
172 controller_->ExitNow(exit_code); 172 controller_->ExitNow(exit_code);
173 } 173 }
174 174
175 void ChildProcessHost::DidStart() { 175 void ChildProcessHost::DidStart() {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 scoped_refptr<PipeHolder> holder, 302 scoped_refptr<PipeHolder> holder,
303 scoped_refptr<base::TaskRunner> callback_task_runner, 303 scoped_refptr<base::TaskRunner> callback_task_runner,
304 const base::Closure& callback, 304 const base::Closure& callback,
305 ScopedMessagePipeHandle pipe) { 305 ScopedMessagePipeHandle pipe) {
306 holder->SetPipe(std::move(pipe)); 306 holder->SetPipe(std::move(pipe));
307 callback_task_runner->PostTask(FROM_HERE, callback); 307 callback_task_runner->PostTask(FROM_HERE, callback);
308 } 308 }
309 309
310 } // namespace shell 310 } // namespace shell
311 } // namespace mojo 311 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/runner/host/child_process_host.h ('k') | mojo/shell/runner/host/in_process_native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698