Update broken references to image assets
[chromium-blink-merge.git] / mojo / application / public / cpp / lib / service_connector_registry.cc
blob97c431685063985c134e56d4b8afecf1df0930a5
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 #include "mojo/application/public/cpp/lib/service_connector_registry.h"
7 #include "mojo/application/public/cpp/service_connector.h"
9 namespace mojo {
10 namespace internal {
12 ServiceConnectorRegistry::ServiceConnectorRegistry()
13 : service_connector_(nullptr) {
16 ServiceConnectorRegistry::~ServiceConnectorRegistry() {
17 for (NameToServiceConnectorMap::iterator i =
18 name_to_service_connector_.begin();
19 i != name_to_service_connector_.end(); ++i) {
20 delete i->second;
22 name_to_service_connector_.clear();
25 void ServiceConnectorRegistry::SetServiceConnectorForName(
26 ServiceConnector* service_connector,
27 const std::string& interface_name) {
28 RemoveServiceConnectorForName(interface_name);
29 name_to_service_connector_[interface_name] = service_connector;
32 void ServiceConnectorRegistry::RemoveServiceConnectorForName(
33 const std::string& interface_name) {
34 NameToServiceConnectorMap::iterator it =
35 name_to_service_connector_.find(interface_name);
36 if (it == name_to_service_connector_.end())
37 return;
38 delete it->second;
39 name_to_service_connector_.erase(it);
42 void ServiceConnectorRegistry::ConnectToService(
43 ApplicationConnection* application_connection,
44 const std::string& interface_name,
45 ScopedMessagePipeHandle client_handle) {
46 auto iter = name_to_service_connector_.find(interface_name);
47 if (iter != name_to_service_connector_.end()) {
48 iter->second->ConnectToService(application_connection, interface_name,
49 client_handle.Pass());
50 return;
52 if (service_connector_) {
53 service_connector_->ConnectToService(application_connection, interface_name,
54 client_handle.Pass());
58 } // namespace internal
59 } // namespace mojo