| 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/application_impl.h" | 8 #include "mojo/public/cpp/application/application_impl.h" |
| 9 #include "mojo/public/cpp/application/lib/service_connector.h" | 9 #include "mojo/public/cpp/application/lib/service_connector.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 ServiceRegistry::ServiceRegistry(ApplicationImpl* application_impl, | 14 ServiceRegistry::ServiceRegistry( |
| 15 const std::string& url, | 15 ApplicationImpl* application_impl, |
| 16 ServiceProviderPtr service_provider) | 16 const std::string& url, |
| 17 ServiceProviderPtr remote_services, |
| 18 InterfaceRequest<ServiceProvider> local_services) |
| 17 : application_impl_(application_impl), | 19 : application_impl_(application_impl), |
| 18 url_(url), | 20 url_(url), |
| 19 remote_service_provider_(service_provider.Pass()) { | 21 local_binding_(this, local_services.Pass()), |
| 20 remote_service_provider_.set_client(this); | 22 remote_service_provider_(remote_services.Pass()) { |
| 21 } | 23 } |
| 22 | 24 |
| 23 ServiceRegistry::ServiceRegistry() : application_impl_(nullptr) { | 25 ServiceRegistry::ServiceRegistry() |
| 26 : application_impl_(nullptr), local_binding_(this) { |
| 24 } | 27 } |
| 25 | 28 |
| 26 ServiceRegistry::~ServiceRegistry() { | 29 ServiceRegistry::~ServiceRegistry() { |
| 27 for (NameToServiceConnectorMap::iterator i = | 30 for (NameToServiceConnectorMap::iterator i = |
| 28 name_to_service_connector_.begin(); | 31 name_to_service_connector_.begin(); |
| 29 i != name_to_service_connector_.end(); | 32 i != name_to_service_connector_.end(); |
| 30 ++i) { | 33 ++i) { |
| 31 delete i->second; | 34 delete i->second; |
| 32 } | 35 } |
| 33 name_to_service_connector_.clear(); | 36 name_to_service_connector_.clear(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 return; | 82 return; |
| 80 } | 83 } |
| 81 internal::ServiceConnectorBase* service_connector = | 84 internal::ServiceConnectorBase* service_connector = |
| 82 name_to_service_connector_[service_name]; | 85 name_to_service_connector_[service_name]; |
| 83 return service_connector->ConnectToService(service_name, | 86 return service_connector->ConnectToService(service_name, |
| 84 client_handle.Pass()); | 87 client_handle.Pass()); |
| 85 } | 88 } |
| 86 | 89 |
| 87 } // namespace internal | 90 } // namespace internal |
| 88 } // namespace mojo | 91 } // namespace mojo |
| OLD | NEW |