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