Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / components / devtools_service / devtools_registry_impl.cc
blob5e402e890ae30242440076c2e26a505348186375
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 "components/devtools_service/devtools_registry_impl.h"
7 #include "base/logging.h"
8 #include "components/devtools_service/devtools_agent_host.h"
10 namespace devtools_service {
12 DevToolsRegistryImpl::Iterator::Iterator(DevToolsRegistryImpl* registry)
13 : registry_(registry), iter_(registry->agents_.begin()) {
16 DevToolsRegistryImpl::Iterator::~Iterator() {
19 DevToolsRegistryImpl::DevToolsRegistryImpl(DevToolsService* service)
20 : service_(service) {
23 DevToolsRegistryImpl::~DevToolsRegistryImpl() {
26 void DevToolsRegistryImpl::BindToRegistryRequest(
27 mojo::InterfaceRequest<DevToolsRegistry> request) {
28 bindings_.AddBinding(this, request.Pass());
31 DevToolsAgentHost* DevToolsRegistryImpl::GetAgentById(const std::string& id) {
32 auto iter = agents_.find(id);
33 if (iter == agents_.end())
34 return nullptr;
36 return iter->second.get();
39 void DevToolsRegistryImpl::RegisterAgent(const mojo::String& id,
40 DevToolsAgentPtr agent) {
41 linked_ptr<DevToolsAgentHost> agent_host(
42 new DevToolsAgentHost(id, agent.Pass()));
43 agent_host->set_agent_connection_error_handler(
44 [this, id]() { OnAgentConnectionError(id); });
46 agents_[id] = agent_host;
49 void DevToolsRegistryImpl::OnAgentConnectionError(const std::string& id) {
50 DCHECK(agents_.find(id) != agents_.end());
51 agents_.erase(id);
54 } // namespace devtools_service