Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: mojo/shell/public/cpp/lib/service_connector_registry.h

Issue 1675083002: Rename ApplicationDelegate to ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate
Patch Set: . Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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_CONNECTOR_REGISTRY_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_CONNECTOR_REGISTRY_H_
6 #define MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_CONNECTOR_REGISTRY_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_CONNECTOR_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "mojo/public/cpp/system/message_pipe.h" 11 #include "mojo/public/cpp/system/message_pipe.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 14
15 class ApplicationConnection; 15 class Connection;
16 class ServiceConnector; 16 class ServiceConnector;
17 17
18 namespace internal { 18 namespace internal {
19 19
20 // ServiceConnectorRegistry maintains a default ServiceConnector as well as at 20 // ServiceConnectorRegistry maintains a default ServiceConnector as well as at
21 // most one ServiceConnector per interface name. When ConnectToService() is 21 // most one ServiceConnector per interface name. When ConnectToService() is
22 // invoked the ServiceConnector registered by name is given the request. If 22 // invoked the ServiceConnector registered by name is given the request. If
23 // a ServiceConnector has not been registered by name than the default 23 // a ServiceConnector has not been registered by name than the default
24 // ServiceConnector is given the request. 24 // ServiceConnector is given the request.
25 class ServiceConnectorRegistry { 25 class ServiceConnectorRegistry {
26 public: 26 public:
27 ServiceConnectorRegistry(); 27 ServiceConnectorRegistry();
28 ~ServiceConnectorRegistry(); 28 ~ServiceConnectorRegistry();
29 29
30 // Sets the default ServiceConnector. ServiceConnectorRegistry does *not* 30 // Sets the default ServiceConnector. ServiceConnectorRegistry does *not*
31 // take ownership of |service_connector|. 31 // take ownership of |service_connector|.
32 void set_service_connector(ServiceConnector* service_connector) { 32 void set_service_connector(ServiceConnector* service_connector) {
33 service_connector_ = service_connector; 33 service_connector_ = service_connector;
34 } 34 }
35 35
36 // Returns true if non ServiceConnectors have been registered by name. 36 // Returns true if non ServiceConnectors have been registered by name.
37 bool empty() const { return name_to_service_connector_.empty(); } 37 bool empty() const { return name_to_service_connector_.empty(); }
38 38
39 // Sets a ServiceConnector by name. This deletes the existing ServiceConnector 39 // Sets a ServiceConnector by name. This deletes the existing ServiceConnector
40 // and takes ownership of |service_connector|. 40 // and takes ownership of |service_connector|.
41 void SetServiceConnectorForName(ServiceConnector* service_connector, 41 void SetServiceConnectorForName(ServiceConnector* service_connector,
42 const std::string& interface_name); 42 const std::string& interface_name);
43 void RemoveServiceConnectorForName(const std::string& interface_name); 43 void RemoveServiceConnectorForName(const std::string& interface_name);
44 44
45 void ConnectToService(ApplicationConnection* application_connection, 45 void ConnectToService(Connection* connection,
46 const std::string& interface_name, 46 const std::string& interface_name,
47 ScopedMessagePipeHandle client_handle); 47 ScopedMessagePipeHandle client_handle);
48 48
49 private: 49 private:
50 using NameToServiceConnectorMap = std::map<std::string, ServiceConnector*>; 50 using NameToServiceConnectorMap = std::map<std::string, ServiceConnector*>;
51 51
52 ServiceConnector* service_connector_; 52 ServiceConnector* service_connector_;
53 53
54 NameToServiceConnectorMap name_to_service_connector_; 54 NameToServiceConnectorMap name_to_service_connector_;
55 55
56 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceConnectorRegistry); 56 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceConnectorRegistry);
57 }; 57 };
58 58
59 } // namespace internal 59 } // namespace internal
60 } // namespace mojo 60 } // namespace mojo
61 61
62 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_CONNECTOR_REGISTRY_H_ 62 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_CONNECTOR_REGISTRY_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/lib/interface_factory_connector.h ('k') | mojo/shell/public/cpp/lib/service_connector_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698