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 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_ | 5 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_ |
6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_ | 6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
| 11 #include "mojo/public/cpp/application/lib/service_connector_registry.h" |
9 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 12 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
10 | 13 |
11 namespace mojo { | 14 namespace mojo { |
12 | 15 |
13 class Application; | 16 class Application; |
14 class ApplicationImpl; | 17 class ApplicationImpl; |
15 | 18 |
16 namespace internal { | 19 namespace internal { |
17 | 20 |
18 class ServiceConnectorBase; | |
19 | |
20 // A ServiceRegistry represents each half of a connection between two | 21 // A ServiceRegistry represents each half of a connection between two |
21 // applications, allowing customization of which services are published to the | 22 // applications, allowing customization of which services are published to the |
22 // other. | 23 // other. |
23 class ServiceRegistry : public ServiceProvider, public ApplicationConnection { | 24 class ServiceRegistry : public ServiceProvider, public ApplicationConnection { |
24 public: | 25 public: |
25 ServiceRegistry(); | 26 ServiceRegistry(); |
26 ServiceRegistry(ApplicationImpl* application_impl, | 27 ServiceRegistry(ApplicationImpl* application_impl, |
27 const std::string& connection_url, | 28 const std::string& connection_url, |
28 const std::string& remote_url, | 29 const std::string& remote_url, |
29 ServiceProviderPtr remote_services, | 30 ServiceProviderPtr remote_services, |
30 InterfaceRequest<ServiceProvider> local_services); | 31 InterfaceRequest<ServiceProvider> local_services); |
31 ~ServiceRegistry() override; | 32 ~ServiceRegistry() override; |
32 | 33 |
33 // ApplicationConnection overrides. | 34 // ApplicationConnection overrides. |
34 void AddServiceConnector(ServiceConnectorBase* service_connector) override; | 35 void SetServiceConnector(ServiceConnector* service_connector) override; |
| 36 void SetServiceConnectorForName(ServiceConnector* service_connector, |
| 37 const std::string& interface_name) override; |
35 const std::string& GetConnectionURL() override; | 38 const std::string& GetConnectionURL() override; |
36 const std::string& GetRemoteApplicationURL() override; | 39 const std::string& GetRemoteApplicationURL() override; |
37 ServiceProvider* GetServiceProvider() override; | 40 ServiceProvider* GetServiceProvider() override; |
38 | 41 |
39 virtual void RemoveServiceConnector(ServiceConnectorBase* service_connector); | 42 void RemoveServiceConnectorForName(const std::string& interface_name); |
40 | 43 |
41 private: | 44 private: |
42 // ServiceProvider method. | 45 // ServiceProvider method. |
43 void ConnectToService(const mojo::String& service_name, | 46 void ConnectToService(const mojo::String& service_name, |
44 ScopedMessagePipeHandle client_handle) override; | 47 ScopedMessagePipeHandle client_handle) override; |
45 | 48 |
46 ApplicationImpl* application_impl_; | 49 ApplicationImpl* application_impl_; |
47 const std::string connection_url_; | 50 const std::string connection_url_; |
48 const std::string remote_url_; | 51 const std::string remote_url_; |
49 | 52 |
50 private: | 53 private: |
51 bool RemoveServiceConnectorInternal(ServiceConnectorBase* service_connector); | 54 void RemoveServiceConnectorForNameInternal(const std::string& interface_name); |
52 | 55 |
53 Application* application_; | 56 Application* application_; |
54 typedef std::map<std::string, ServiceConnectorBase*> | |
55 NameToServiceConnectorMap; | |
56 NameToServiceConnectorMap name_to_service_connector_; | |
57 Binding<ServiceProvider> local_binding_; | 57 Binding<ServiceProvider> local_binding_; |
58 ServiceProviderPtr remote_service_provider_; | 58 ServiceProviderPtr remote_service_provider_; |
| 59 ServiceConnectorRegistry service_connector_registry_; |
59 | 60 |
60 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry); | 61 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry); |
61 }; | 62 }; |
62 | 63 |
63 } // namespace internal | 64 } // namespace internal |
64 } // namespace mojo | 65 } // namespace mojo |
65 | 66 |
66 #endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_ | 67 #endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_ |
OLD | NEW |