OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "mojo/public/cpp/application/lib/service_connector_registry.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "mojo/public/cpp/application/connection_context.h" | |
10 #include "mojo/public/cpp/application/service_connector.h" | |
11 | |
12 namespace mojo { | |
13 namespace internal { | |
14 | |
15 ServiceConnectorRegistry::ServiceConnectorRegistry() {} | |
16 | |
17 ServiceConnectorRegistry::~ServiceConnectorRegistry() {} | |
18 | |
19 void ServiceConnectorRegistry::SetServiceConnectorForName( | |
20 std::unique_ptr<ServiceConnector> service_connector, | |
21 const std::string& interface_name) { | |
22 name_to_service_connector_[interface_name] = std::move(service_connector); | |
23 } | |
24 | |
25 void ServiceConnectorRegistry::RemoveServiceConnectorForName( | |
26 const std::string& interface_name) { | |
27 NameToServiceConnectorMap::iterator it = | |
28 name_to_service_connector_.find(interface_name); | |
29 if (it == name_to_service_connector_.end()) | |
30 return; | |
31 name_to_service_connector_.erase(it); | |
32 } | |
33 | |
34 bool ServiceConnectorRegistry::ConnectToService( | |
35 const ConnectionContext& connection_context, | |
36 const std::string& interface_name, | |
37 ScopedMessagePipeHandle* client_handle) { | |
38 auto iter = name_to_service_connector_.find(interface_name); | |
39 if (iter != name_to_service_connector_.end()) { | |
40 iter->second->ConnectToService(connection_context, interface_name, | |
41 client_handle->Pass()); | |
42 return true; | |
43 } | |
44 return false; | |
45 } | |
46 | |
47 } // namespace internal | |
48 } // namespace mojo | |
OLD | NEW |