Update broken references to image assets
[chromium-blink-merge.git] / mojo / application / public / cpp / lib / service_connector_registry.h
blobb19635363e5eb0a9e4c0da1d60917189daa72c6b
1 // Copyright 2015 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_CONNECTOR_REGISTRY_H_
6 #define MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_CONNECTOR_REGISTRY_H_
8 #include <map>
9 #include <string>
11 #include "mojo/public/cpp/system/message_pipe.h"
13 namespace mojo {
15 class ApplicationConnection;
16 class ServiceConnector;
18 namespace internal {
20 // ServiceConnectorRegistry maintains a default ServiceConnector as well as at
21 // most one ServiceConnector per interface name. When ConnectToService() is
22 // invoked the ServiceConnector registered by name is given the request. If
23 // a ServiceConnector has not been registered by name than the default
24 // ServiceConnector is given the request.
25 class ServiceConnectorRegistry {
26 public:
27 ServiceConnectorRegistry();
28 ~ServiceConnectorRegistry();
30 // Sets the default ServiceConnector. ServiceConnectorRegistry does *not*
31 // take ownership of |service_connector|.
32 void set_service_connector(ServiceConnector* service_connector) {
33 service_connector_ = service_connector;
36 // Returns true if non ServiceConnectors have been registered by name.
37 bool empty() const { return name_to_service_connector_.empty(); }
39 // Sets a ServiceConnector by name. This deletes the existing ServiceConnector
40 // and takes ownership of |service_connector|.
41 void SetServiceConnectorForName(ServiceConnector* service_connector,
42 const std::string& interface_name);
43 void RemoveServiceConnectorForName(const std::string& interface_name);
45 void ConnectToService(ApplicationConnection* application_connection,
46 const std::string& interface_name,
47 ScopedMessagePipeHandle client_handle);
49 private:
50 using NameToServiceConnectorMap = std::map<std::string, ServiceConnector*>;
52 ServiceConnector* service_connector_;
54 NameToServiceConnectorMap name_to_service_connector_;
56 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceConnectorRegistry);
59 } // namespace internal
60 } // namespace mojo
62 #endif // MOJO_APPLICATION_PUBLIC_CPP_LIB_SERVICE_CONNECTOR_REGISTRY_H_