| 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_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ | 5 #ifndef MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ |
| 6 #define MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ | 6 #define MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
| 14 #include "mojo/shell/public/cpp/application_connection.h" | 14 #include "mojo/shell/public/cpp/connection.h" |
| 15 #include "mojo/shell/public/cpp/lib/service_connector_registry.h" | 15 #include "mojo/shell/public/cpp/lib/service_connector_registry.h" |
| 16 #include "mojo/shell/public/interfaces/service_provider.mojom.h" | 16 #include "mojo/shell/public/interfaces/service_provider.mojom.h" |
| 17 #include "mojo/shell/public/interfaces/shell.mojom.h" | 17 #include "mojo/shell/public/interfaces/shell.mojom.h" |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 namespace internal { | 20 namespace internal { |
| 21 | 21 |
| 22 // A ServiceRegistry represents each half of a connection between two | 22 // A ServiceRegistry represents each half of a connection between two |
| 23 // applications, allowing customization of which services are published to the | 23 // applications, allowing customization of which services are published to the |
| 24 // other. | 24 // other. |
| 25 class ServiceRegistry : public ServiceProvider, public ApplicationConnection { | 25 class ServiceRegistry : public ServiceProvider, public Connection { |
| 26 public: | 26 public: |
| 27 ServiceRegistry(); | 27 ServiceRegistry(); |
| 28 // |allowed_interfaces| are the set of interfaces that the shell has allowed | 28 // |allowed_interfaces| are the set of interfaces that the shell has allowed |
| 29 // an application to expose to another application. If this set contains only | 29 // an application to expose to another application. If this set contains only |
| 30 // the string value "*" all interfaces may be exposed. | 30 // the string value "*" all interfaces may be exposed. |
| 31 ServiceRegistry(const std::string& connection_url, | 31 ServiceRegistry(const std::string& connection_url, |
| 32 const std::string& remote_url, | 32 const std::string& remote_url, |
| 33 uint32_t remote_id, | 33 uint32_t remote_id, |
| 34 ServiceProviderPtr remote_services, | 34 ServiceProviderPtr remote_services, |
| 35 InterfaceRequest<ServiceProvider> local_services, | 35 InterfaceRequest<ServiceProvider> local_services, |
| 36 const std::set<std::string>& allowed_interfaces); | 36 const std::set<std::string>& allowed_interfaces); |
| 37 ~ServiceRegistry() override; | 37 ~ServiceRegistry() override; |
| 38 | 38 |
| 39 shell::mojom::Shell::ConnectToApplicationCallback | 39 shell::mojom::Shell::ConnectToApplicationCallback |
| 40 GetConnectToApplicationCallback(); | 40 GetConnectToApplicationCallback(); |
| 41 | 41 |
| 42 // ApplicationConnection overrides. | 42 // Connection overrides. |
| 43 void SetServiceConnector(ServiceConnector* service_connector) override; | 43 void SetServiceConnector(ServiceConnector* service_connector) override; |
| 44 bool SetServiceConnectorForName(ServiceConnector* service_connector, | 44 bool SetServiceConnectorForName(ServiceConnector* service_connector, |
| 45 const std::string& interface_name) override; | 45 const std::string& interface_name) override; |
| 46 const std::string& GetConnectionURL() override; | 46 const std::string& GetConnectionURL() override; |
| 47 const std::string& GetRemoteApplicationURL() override; | 47 const std::string& GetRemoteApplicationURL() override; |
| 48 ServiceProvider* GetServiceProvider() override; | 48 ServiceProvider* GetServiceProvider() override; |
| 49 ServiceProvider* GetLocalServiceProvider() override; | 49 ServiceProvider* GetLocalServiceProvider() override; |
| 50 void SetRemoteServiceProviderConnectionErrorHandler( | 50 void SetRemoteServiceProviderConnectionErrorHandler( |
| 51 const Closure& handler) override; | 51 const Closure& handler) override; |
| 52 bool GetRemoteApplicationID(uint32_t* remote_id) const override; | 52 bool GetRemoteApplicationID(uint32_t* remote_id) const override; |
| 53 bool GetRemoteContentHandlerID(uint32_t* content_handler_id) const override; | 53 bool GetRemoteContentHandlerID(uint32_t* content_handler_id) const override; |
| 54 void AddRemoteIDCallback(const Closure& callback) override; | 54 void AddRemoteIDCallback(const Closure& callback) override; |
| 55 base::WeakPtr<ApplicationConnection> GetWeakPtr() override; | 55 base::WeakPtr<Connection> GetWeakPtr() override; |
| 56 | 56 |
| 57 void RemoveServiceConnectorForName(const std::string& interface_name); | 57 void RemoveServiceConnectorForName(const std::string& interface_name); |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 void OnGotRemoteIDs(uint32_t target_application_id, | 60 void OnGotRemoteIDs(uint32_t target_application_id, |
| 61 uint32_t content_handler_id); | 61 uint32_t content_handler_id); |
| 62 | 62 |
| 63 // ServiceProvider method. | 63 // ServiceProvider method. |
| 64 void ConnectToService(const mojo::String& service_name, | 64 void ConnectToService(const mojo::String& service_name, |
| 65 ScopedMessagePipeHandle client_handle) override; | 65 ScopedMessagePipeHandle client_handle) override; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 std::vector<Closure> remote_id_callbacks_; | 79 std::vector<Closure> remote_id_callbacks_; |
| 80 base::WeakPtrFactory<ServiceRegistry> weak_factory_; | 80 base::WeakPtrFactory<ServiceRegistry> weak_factory_; |
| 81 | 81 |
| 82 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry); | 82 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace internal | 85 } // namespace internal |
| 86 } // namespace mojo | 86 } // namespace mojo |
| 87 | 87 |
| 88 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ | 88 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ |
| OLD | NEW |