OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "content/common/associated_interface_registry_impl.h" | 5 #include "content/common/associated_interface_registry_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 AssociatedInterfaceRegistryImpl::AssociatedInterfaceRegistryImpl() {} | 13 AssociatedInterfaceRegistryImpl::AssociatedInterfaceRegistryImpl() {} |
14 | 14 |
15 AssociatedInterfaceRegistryImpl::~AssociatedInterfaceRegistryImpl() {} | 15 AssociatedInterfaceRegistryImpl::~AssociatedInterfaceRegistryImpl() {} |
16 | 16 |
| 17 bool AssociatedInterfaceRegistryImpl::CanBindRequest( |
| 18 const std::string& interface_name) const { |
| 19 return interfaces_.find(interface_name) != interfaces_.end(); |
| 20 } |
| 21 |
17 void AssociatedInterfaceRegistryImpl::BindRequest( | 22 void AssociatedInterfaceRegistryImpl::BindRequest( |
18 const std::string& interface_name, | 23 const std::string& interface_name, |
19 mojo::ScopedInterfaceEndpointHandle handle) { | 24 mojo::ScopedInterfaceEndpointHandle handle) { |
20 auto it = interfaces_.find(interface_name); | 25 auto it = interfaces_.find(interface_name); |
21 if (it == interfaces_.end()) | 26 if (it == interfaces_.end()) |
22 return; | 27 return; |
23 it->second.Run(std::move(handle)); | 28 it->second.Run(std::move(handle)); |
24 } | 29 } |
25 | 30 |
26 void AssociatedInterfaceRegistryImpl::AddInterface(const std::string& name, | 31 void AssociatedInterfaceRegistryImpl::AddInterface(const std::string& name, |
27 const Binder& binder) { | 32 const Binder& binder) { |
28 auto result = interfaces_.insert(std::make_pair(name, binder)); | 33 auto result = interfaces_.insert(std::make_pair(name, binder)); |
29 DCHECK(result.second); | 34 DCHECK(result.second); |
30 } | 35 } |
31 | 36 |
32 void AssociatedInterfaceRegistryImpl::RemoveInterface(const std::string& name) { | 37 void AssociatedInterfaceRegistryImpl::RemoveInterface(const std::string& name) { |
33 auto it = interfaces_.find(name); | 38 auto it = interfaces_.find(name); |
34 DCHECK(it != interfaces_.end()); | 39 DCHECK(it != interfaces_.end()); |
35 interfaces_.erase(it); | 40 interfaces_.erase(it); |
36 } | 41 } |
37 | 42 |
38 } // namespace content | 43 } // namespace content |
OLD | NEW |