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
3 // found in the LICENSE file.
5 #ifndef MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
6 #define MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
11 #include "mojo/application/public/cpp/application_connection.h"
12 #include "mojo/application/public/cpp/lib/service_connector_registry.h"
13 #include "mojo/application/public/interfaces/service_provider.mojom.h"
18 class ApplicationImpl
;
22 // A ServiceRegistry represents each half of a connection between two
23 // applications, allowing customization of which services are published to the
25 class ServiceRegistry
: public ServiceProvider
, public ApplicationConnection
{
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
30 // the string value "*" all interfaces may be exposed.
31 ServiceRegistry(ApplicationImpl
* application_impl
,
32 const std::string
& connection_url
,
33 const std::string
& remote_url
,
34 ServiceProviderPtr remote_services
,
35 InterfaceRequest
<ServiceProvider
> local_services
,
36 const std::set
<std::string
>& allowed_interfaces
);
38 // ApplicationConnection overrides.
39 void SetServiceConnector(ServiceConnector
* service_connector
) override
;
40 bool SetServiceConnectorForName(ServiceConnector
* service_connector
,
41 const std::string
& interface_name
) override
;
42 const std::string
& GetConnectionURL() override
;
43 const std::string
& GetRemoteApplicationURL() override
;
44 ServiceProvider
* GetServiceProvider() override
;
45 ServiceProvider
* GetLocalServiceProvider() override
;
46 void SetRemoteServiceProviderConnectionErrorHandler(
47 const Closure
& handler
) override
;
49 void RemoveServiceConnectorForName(const std::string
& interface_name
);
52 ~ServiceRegistry() override
;
54 // ApplicationConnection overrides.
55 void OnCloseConnection() override
;
57 // ServiceProvider method.
58 void ConnectToService(const mojo::String
& service_name
,
59 ScopedMessagePipeHandle client_handle
) override
;
61 ApplicationImpl
* application_impl_
;
62 const std::string connection_url_
;
63 const std::string remote_url_
;
64 Binding
<ServiceProvider
> local_binding_
;
65 ServiceProviderPtr remote_service_provider_
;
66 ServiceConnectorRegistry service_connector_registry_
;
67 const std::set
<std::string
> allowed_interfaces_
;
68 const bool allow_all_interfaces_
;
70 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry
);
73 } // namespace internal
76 #endif // MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_