| 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() : local_binding_(this) {} |
| 14 | 14 |
| 15 ServiceRegistry::ServiceRegistry( | 15 ServiceRegistry::ServiceRegistry( |
| 16 const std::string& connection_url, | 16 const ConnectionContext& connection_context, |
| 17 const std::string& remote_url, | |
| 18 InterfaceRequest<ServiceProvider> local_services) | 17 InterfaceRequest<ServiceProvider> local_services) |
| 19 : connection_url_(connection_url), | 18 : connection_context_(connection_context), local_binding_(this) { |
| 20 remote_url_(remote_url), | |
| 21 local_binding_(this) { | |
| 22 if (local_services.is_pending()) | 19 if (local_services.is_pending()) |
| 23 local_binding_.Bind(local_services.Pass()); | 20 local_binding_.Bind(local_services.Pass()); |
| 24 } | 21 } |
| 25 | 22 |
| 26 ServiceRegistry::~ServiceRegistry() {} | 23 ServiceRegistry::~ServiceRegistry() {} |
| 27 | 24 |
| 28 void ServiceRegistry::SetServiceConnectorForName( | 25 void ServiceRegistry::SetServiceConnectorForName( |
| 29 ServiceConnector* service_connector, | 26 ServiceConnector* service_connector, |
| 30 const std::string& interface_name) { | 27 const std::string& interface_name) { |
| 31 service_connector_registry_.SetServiceConnectorForName( | 28 service_connector_registry_.SetServiceConnectorForName( |
| 32 std::unique_ptr<ServiceConnector>(service_connector), interface_name); | 29 std::unique_ptr<ServiceConnector>(service_connector), interface_name); |
| 33 } | 30 } |
| 34 | 31 |
| 35 void ServiceRegistry::RemoveServiceConnectorForName( | 32 void ServiceRegistry::RemoveServiceConnectorForName( |
| 36 const std::string& interface_name) { | 33 const std::string& interface_name) { |
| 37 service_connector_registry_.RemoveServiceConnectorForName(interface_name); | 34 service_connector_registry_.RemoveServiceConnectorForName(interface_name); |
| 38 } | 35 } |
| 39 | 36 |
| 40 const std::string& ServiceRegistry::GetConnectionURL() { | 37 const std::string& ServiceRegistry::GetConnectionURL() { |
| 41 return connection_url_; | 38 return connection_context_.connection_url; |
| 42 } | 39 } |
| 43 | 40 |
| 44 const std::string& ServiceRegistry::GetRemoteApplicationURL() { | 41 const std::string& ServiceRegistry::GetRemoteApplicationURL() { |
| 45 return remote_url_; | 42 return connection_context_.remote_url; |
| 46 } | 43 } |
| 47 | 44 |
| 48 void ServiceRegistry::ConnectToService(const String& service_name, | 45 void ServiceRegistry::ConnectToService(const String& service_name, |
| 49 ScopedMessagePipeHandle client_handle) { | 46 ScopedMessagePipeHandle client_handle) { |
| 50 service_connector_registry_.ConnectToService(this, service_name, | 47 service_connector_registry_.ConnectToService(this, service_name, |
| 51 &client_handle); | 48 &client_handle); |
| 52 } | 49 } |
| 53 | 50 |
| 54 } // namespace internal | 51 } // namespace internal |
| 55 } // namespace mojo | 52 } // namespace mojo |
| OLD | NEW |