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

Side by Side Diff: mojo/public/cpp/application/lib/service_connector_registry.cc

Issue 1984463002: More cleanup: Get rid of ServiceConnectorRegistry. (Closed) Base URL: https://github.com/domokit/mojo.git@work791_app_conn_devo_4
Patch Set: Created 4 years, 7 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
(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
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/lib/service_connector_registry.h ('k') | mojo/public/cpp/application/lib/service_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698