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

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

Issue 1565343003: Move mojo/application/public -> mojo/shell/public (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fetcher
Patch Set: . Created 4 years, 11 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/application/public/cpp/lib/service_connector_registry.h"
6
7 #include <utility>
8
9 #include "mojo/application/public/cpp/service_connector.h"
10
11 namespace mojo {
12 namespace internal {
13
14 ServiceConnectorRegistry::ServiceConnectorRegistry()
15 : service_connector_(nullptr) {
16 }
17
18 ServiceConnectorRegistry::~ServiceConnectorRegistry() {
19 for (NameToServiceConnectorMap::iterator i =
20 name_to_service_connector_.begin();
21 i != name_to_service_connector_.end(); ++i) {
22 delete i->second;
23 }
24 name_to_service_connector_.clear();
25 }
26
27 void ServiceConnectorRegistry::SetServiceConnectorForName(
28 ServiceConnector* service_connector,
29 const std::string& interface_name) {
30 RemoveServiceConnectorForName(interface_name);
31 name_to_service_connector_[interface_name] = service_connector;
32 }
33
34 void ServiceConnectorRegistry::RemoveServiceConnectorForName(
35 const std::string& interface_name) {
36 NameToServiceConnectorMap::iterator it =
37 name_to_service_connector_.find(interface_name);
38 if (it == name_to_service_connector_.end())
39 return;
40 delete it->second;
41 name_to_service_connector_.erase(it);
42 }
43
44 void ServiceConnectorRegistry::ConnectToService(
45 ApplicationConnection* application_connection,
46 const std::string& interface_name,
47 ScopedMessagePipeHandle client_handle) {
48 auto iter = name_to_service_connector_.find(interface_name);
49 if (iter != name_to_service_connector_.end()) {
50 iter->second->ConnectToService(application_connection, interface_name,
51 std::move(client_handle));
52 return;
53 }
54 if (service_connector_) {
55 service_connector_->ConnectToService(application_connection, interface_name,
56 std::move(client_handle));
57 }
58 }
59
60 } // namespace internal
61 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/application/public/cpp/lib/service_connector_registry.h ('k') | mojo/application/public/cpp/lib/service_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698