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

Side by Side Diff: mojo/runner/host/child_process.cc

Issue 1525033004: Always set the error handler closure of Binding<> after binding to a message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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
« no previous file with comments | « mojo/runner/child/runner_connection.cc ('k') | mojo/shell/application_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/runner/host/child_process.h" 5 #include "mojo/runner/host/child_process.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 DCHECK(!app_context->controller()); 211 DCHECK(!app_context->controller());
212 212
213 scoped_ptr<ChildControllerImpl> impl( 213 scoped_ptr<ChildControllerImpl> impl(
214 new ChildControllerImpl(app_context, app_library, unblocker)); 214 new ChildControllerImpl(app_context, app_library, unblocker));
215 215
216 impl->Bind(host_message_pipe.Pass()); 216 impl->Bind(host_message_pipe.Pass());
217 217
218 app_context->set_controller(impl.Pass()); 218 app_context->set_controller(impl.Pass());
219 } 219 }
220 220
221 void Bind(ScopedMessagePipeHandle handle) { binding_.Bind(handle.Pass()); } 221 void Bind(ScopedMessagePipeHandle handle) {
222 binding_.Bind(handle.Pass());
223 binding_.set_connection_error_handler([this]() { OnConnectionError(); });
224 }
222 225
223 void OnConnectionError() { 226 void OnConnectionError() {
224 // A connection error means the connection to the shell is lost. This is not 227 // A connection error means the connection to the shell is lost. This is not
225 // recoverable. 228 // recoverable.
226 LOG(ERROR) << "Connection error to the shell."; 229 LOG(ERROR) << "Connection error to the shell.";
227 _exit(1); 230 _exit(1);
228 } 231 }
229 232
230 // |ChildController| methods: 233 // |ChildController| methods:
231 void StartApp(InterfaceRequest<Application> application_request, 234 void StartApp(InterfaceRequest<Application> application_request,
(...skipping 12 matching lines...) Expand all
244 } 247 }
245 248
246 private: 249 private:
247 ChildControllerImpl(AppContext* app_context, 250 ChildControllerImpl(AppContext* app_context,
248 base::NativeLibrary app_library, 251 base::NativeLibrary app_library,
249 const Blocker::Unblocker& unblocker) 252 const Blocker::Unblocker& unblocker)
250 : app_context_(app_context), 253 : app_context_(app_context),
251 app_library_(app_library), 254 app_library_(app_library),
252 unblocker_(unblocker), 255 unblocker_(unblocker),
253 channel_info_(nullptr), 256 channel_info_(nullptr),
254 binding_(this) { 257 binding_(this) {}
255 binding_.set_connection_error_handler([this]() { OnConnectionError(); });
256 }
257 258
258 static void StartAppOnMainThread( 259 static void StartAppOnMainThread(
259 base::NativeLibrary app_library, 260 base::NativeLibrary app_library,
260 InterfaceRequest<Application> application_request) { 261 InterfaceRequest<Application> application_request) {
261 if (!RunNativeApplication(app_library, application_request.Pass())) { 262 if (!RunNativeApplication(app_library, application_request.Pass())) {
262 LOG(ERROR) << "Failure to RunNativeApplication()"; 263 LOG(ERROR) << "Failure to RunNativeApplication()";
263 } 264 }
264 } 265 }
265 266
266 base::ThreadChecker thread_checker_; 267 base::ThreadChecker thread_checker_;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // This will block, then run whatever the controller wants. 387 // This will block, then run whatever the controller wants.
387 blocker.Block(); 388 blocker.Block();
388 389
389 app_context.Shutdown(); 390 app_context.Shutdown();
390 391
391 return 0; 392 return 0;
392 } 393 }
393 394
394 } // namespace runner 395 } // namespace runner
395 } // namespace mojo 396 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/child/runner_connection.cc ('k') | mojo/shell/application_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698