ExtensionInstallDialogView: fix scrolling behavior on Views (Win,Linux)
[chromium-blink-merge.git] / components / devtools_service / devtools_registry_impl.cc
blob3fc7e0d3a6d37ad02f5fe23eab6463b14d4673aa
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(DevToolsAgentPtr agent) {
40 linked_ptr<DevToolsAgentHost> agent_host(new DevToolsAgentHost(agent.Pass()));
41 std::string id = agent_host->id();
42 agent_host->set_agent_connection_error_handler(
43 [this, id]() { OnAgentConnectionError(id); });
45 agents_[agent_host->id()] = agent_host;
48 void DevToolsRegistryImpl::OnAgentConnectionError(const std::string& id) {
49 DCHECK(agents_.find(id) != agents_.end());
50 agents_.erase(id);
53 } // namespace devtools_service