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