• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_
6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_
7 
8 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
9 
10 namespace mojo {
11 
12 class Application;
13 
14 namespace internal {
15 
16 class ServiceConnectorBase;
17 
18 class ServiceRegistry : public ServiceProvider {
19  public:
20   ServiceRegistry(Application* application);
21   ServiceRegistry(Application* application,
22                   ScopedMessagePipeHandle service_provider_handle);
23   virtual ~ServiceRegistry();
24 
25   void AddServiceConnector(ServiceConnectorBase* service_connector);
26   void RemoveServiceConnector(ServiceConnectorBase* service_connector);
27 
remote_service_provider()28   ServiceProvider* remote_service_provider() {
29     return remote_service_provider_.get();
30   }
31 
32   void BindRemoteServiceProvider(
33       ScopedMessagePipeHandle service_provider_handle);
34 
35   // ServiceProvider method.
36   virtual void ConnectToService(const mojo::String& service_url,
37                                 const mojo::String& service_name,
38                                 ScopedMessagePipeHandle client_handle,
39                                 const mojo::String& requestor_url)
40       MOJO_OVERRIDE;
41 
42  private:
43   Application* application_;
44   typedef std::map<std::string, ServiceConnectorBase*>
45       NameToServiceConnectorMap;
46   NameToServiceConnectorMap name_to_service_connector_;
47   ServiceProviderPtr remote_service_provider_;
48 
49   MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry);
50 };
51 
52 }  // namespace internal
53 }  // namespace mojo
54 
55 #endif  // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_
56