| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "mojo/common/common_type_converters.h" | 9 #include "mojo/common/common_type_converters.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 ServiceRegistryImpl::ServiceRegistryImpl() | 13 ServiceRegistryImpl::ServiceRegistryImpl() |
| 14 : binding_(this), weak_factory_(this) {} | 14 : binding_(this), weak_factory_(this) {} |
| 15 | 15 |
| 16 ServiceRegistryImpl::~ServiceRegistryImpl() { | 16 ServiceRegistryImpl::~ServiceRegistryImpl() { |
| 17 while (!pending_connects_.empty()) { | 17 while (!pending_connects_.empty()) { |
| 18 mojo::CloseRaw(pending_connects_.front().second); | 18 mojo::CloseRaw(pending_connects_.front().second); |
| 19 pending_connects_.pop(); | 19 pending_connects_.pop(); |
| 20 } | 20 } |
| 21 } | 21 } |
| 22 | 22 |
| 23 void ServiceRegistryImpl::Bind( | 23 void ServiceRegistryImpl::Bind(shell::mojom::InterfaceProviderRequest request) { |
| 24 mojo::shell::mojom::InterfaceProviderRequest request) { | |
| 25 binding_.Bind(std::move(request)); | 24 binding_.Bind(std::move(request)); |
| 26 binding_.set_connection_error_handler(base::Bind( | 25 binding_.set_connection_error_handler(base::Bind( |
| 27 &ServiceRegistryImpl::OnConnectionError, base::Unretained(this))); | 26 &ServiceRegistryImpl::OnConnectionError, base::Unretained(this))); |
| 28 } | 27 } |
| 29 | 28 |
| 30 void ServiceRegistryImpl::BindRemoteServiceProvider( | 29 void ServiceRegistryImpl::BindRemoteServiceProvider( |
| 31 mojo::shell::mojom::InterfaceProviderPtr service_provider) { | 30 shell::mojom::InterfaceProviderPtr service_provider) { |
| 32 CHECK(!remote_provider_); | 31 CHECK(!remote_provider_); |
| 33 remote_provider_ = std::move(service_provider); | 32 remote_provider_ = std::move(service_provider); |
| 34 while (!pending_connects_.empty()) { | 33 while (!pending_connects_.empty()) { |
| 35 remote_provider_->GetInterface( | 34 remote_provider_->GetInterface( |
| 36 mojo::String::From(pending_connects_.front().first), | 35 mojo::String::From(pending_connects_.front().first), |
| 37 mojo::ScopedMessagePipeHandle(pending_connects_.front().second)); | 36 mojo::ScopedMessagePipeHandle(pending_connects_.front().second)); |
| 38 pending_connects_.pop(); | 37 pending_connects_.pop(); |
| 39 } | 38 } |
| 40 } | 39 } |
| 41 | 40 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 98 } |
| 100 | 99 |
| 101 it->second.Run(std::move(client_handle)); | 100 it->second.Run(std::move(client_handle)); |
| 102 } | 101 } |
| 103 | 102 |
| 104 void ServiceRegistryImpl::OnConnectionError() { | 103 void ServiceRegistryImpl::OnConnectionError() { |
| 105 binding_.Close(); | 104 binding_.Close(); |
| 106 } | 105 } |
| 107 | 106 |
| 108 } // namespace content | 107 } // namespace content |
| OLD | NEW |