| 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 "mojo/public/cpp/application/lib/service_registry.h" | 5 #include "mojo/public/cpp/application/lib/service_registry.h" |
| 6 | 6 |
| 7 #include "mojo/public/cpp/application/application_connection.h" | 7 #include "mojo/public/cpp/application/application_connection.h" |
| 8 #include "mojo/public/cpp/application/service_connector.h" | 8 #include "mojo/public/cpp/application/service_connector.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 ServiceRegistry::ServiceRegistry() : local_binding_(this) {} | 13 ServiceRegistry::ServiceRegistry() {} |
| 14 | 14 |
| 15 ServiceRegistry::ServiceRegistry( | 15 ServiceRegistry::ServiceRegistry( |
| 16 const ConnectionContext& connection_context, | 16 const ConnectionContext& connection_context, |
| 17 InterfaceRequest<ServiceProvider> local_services) | 17 InterfaceRequest<ServiceProvider> local_services) |
| 18 : connection_context_(connection_context), local_binding_(this) { | 18 : service_provider_impl_(connection_context, local_services.Pass()) {} |
| 19 if (local_services.is_pending()) | |
| 20 local_binding_.Bind(local_services.Pass()); | |
| 21 } | |
| 22 | 19 |
| 23 ServiceRegistry::~ServiceRegistry() {} | 20 ServiceRegistry::~ServiceRegistry() {} |
| 24 | 21 |
| 25 void ServiceRegistry::SetServiceConnectorForName( | 22 void ServiceRegistry::SetServiceConnectorForName( |
| 26 ServiceConnector* service_connector, | 23 ServiceConnector* service_connector, |
| 27 const std::string& interface_name) { | 24 const std::string& interface_name) { |
| 28 service_connector_registry_.SetServiceConnectorForName( | 25 service_provider_impl_.AddServiceForName( |
| 29 std::unique_ptr<ServiceConnector>(service_connector), interface_name); | 26 std::unique_ptr<ServiceConnector>(service_connector), interface_name); |
| 30 } | 27 } |
| 31 | 28 |
| 32 void ServiceRegistry::RemoveServiceConnectorForName( | 29 void ServiceRegistry::RemoveServiceConnectorForName( |
| 33 const std::string& interface_name) { | 30 const std::string& interface_name) { |
| 34 service_connector_registry_.RemoveServiceConnectorForName(interface_name); | 31 service_provider_impl_.RemoveServiceForName(interface_name); |
| 32 } |
| 33 |
| 34 ServiceProviderImpl& ServiceRegistry::GetServiceProviderImpl() { |
| 35 return service_provider_impl_; |
| 35 } | 36 } |
| 36 | 37 |
| 37 const ConnectionContext& ServiceRegistry::GetConnectionContext() const { | 38 const ConnectionContext& ServiceRegistry::GetConnectionContext() const { |
| 38 return connection_context_; | 39 return service_provider_impl_.connection_context(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 const std::string& ServiceRegistry::GetConnectionURL() { | 42 const std::string& ServiceRegistry::GetConnectionURL() { |
| 42 return connection_context_.connection_url; | 43 return service_provider_impl_.connection_context().connection_url; |
| 43 } | 44 } |
| 44 | 45 |
| 45 const std::string& ServiceRegistry::GetRemoteApplicationURL() { | 46 const std::string& ServiceRegistry::GetRemoteApplicationURL() { |
| 46 return connection_context_.remote_url; | 47 return service_provider_impl_.connection_context().remote_url; |
| 47 } | |
| 48 | |
| 49 void ServiceRegistry::ConnectToService(const String& service_name, | |
| 50 ScopedMessagePipeHandle client_handle) { | |
| 51 service_connector_registry_.ConnectToService(connection_context_, | |
| 52 service_name, &client_handle); | |
| 53 } | 48 } |
| 54 | 49 |
| 55 } // namespace internal | 50 } // namespace internal |
| 56 } // namespace mojo | 51 } // namespace mojo |
| OLD | NEW |