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

Side by Side Diff: content/common/mojo/service_registry_impl.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 | « no previous file | mojo/runner/child/runner_connection.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 "content/common/mojo/service_registry_impl.h" 5 #include "content/common/mojo/service_registry_impl.h"
6 6
7 #include "mojo/common/common_type_converters.h" 7 #include "mojo/common/common_type_converters.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 ServiceRegistryImpl::ServiceRegistryImpl() 11 ServiceRegistryImpl::ServiceRegistryImpl()
12 : binding_(this), weak_factory_(this) { 12 : binding_(this), weak_factory_(this) {}
13 binding_.set_connection_error_handler(
14 base::Bind(&ServiceRegistryImpl::OnConnectionError,
15 base::Unretained(this)));
16 }
17 13
18 ServiceRegistryImpl::~ServiceRegistryImpl() { 14 ServiceRegistryImpl::~ServiceRegistryImpl() {
19 while (!pending_connects_.empty()) { 15 while (!pending_connects_.empty()) {
20 mojo::CloseRaw(pending_connects_.front().second); 16 mojo::CloseRaw(pending_connects_.front().second);
21 pending_connects_.pop(); 17 pending_connects_.pop();
22 } 18 }
23 } 19 }
24 20
25 void ServiceRegistryImpl::Bind( 21 void ServiceRegistryImpl::Bind(
26 mojo::InterfaceRequest<mojo::ServiceProvider> request) { 22 mojo::InterfaceRequest<mojo::ServiceProvider> request) {
27 binding_.Bind(request.Pass()); 23 binding_.Bind(request.Pass());
24 binding_.set_connection_error_handler(base::Bind(
25 &ServiceRegistryImpl::OnConnectionError, base::Unretained(this)));
28 } 26 }
29 27
30 void ServiceRegistryImpl::BindRemoteServiceProvider( 28 void ServiceRegistryImpl::BindRemoteServiceProvider(
31 mojo::ServiceProviderPtr service_provider) { 29 mojo::ServiceProviderPtr service_provider) {
32 CHECK(!remote_provider_); 30 CHECK(!remote_provider_);
33 remote_provider_ = service_provider.Pass(); 31 remote_provider_ = service_provider.Pass();
34 while (!pending_connects_.empty()) { 32 while (!pending_connects_.empty()) {
35 remote_provider_->ConnectToService( 33 remote_provider_->ConnectToService(
36 mojo::String::From(pending_connects_.front().first), 34 mojo::String::From(pending_connects_.front().first),
37 mojo::ScopedMessagePipeHandle(pending_connects_.front().second)); 35 mojo::ScopedMessagePipeHandle(pending_connects_.front().second));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 84 }
87 85
88 it->second.Run(client_handle.Pass()); 86 it->second.Run(client_handle.Pass());
89 } 87 }
90 88
91 void ServiceRegistryImpl::OnConnectionError() { 89 void ServiceRegistryImpl::OnConnectionError() {
92 binding_.Close(); 90 binding_.Close();
93 } 91 }
94 92
95 } // namespace content 93 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | mojo/runner/child/runner_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698