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 "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 Loading... |
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 |
OLD | NEW |