Generate ax enums from idl.
[chromium-blink-merge.git] / content / browser / devtools / devtools_agent_host_impl.cc
blob087004296d579fbaea6165192c6c1e3a4f356b91
1 // Copyright (c) 2012 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 "content/browser/devtools/devtools_agent_host_impl.h"
7 #include <map>
9 #include "base/basictypes.h"
10 #include "base/guid.h"
11 #include "base/lazy_instance.h"
12 #include "content/browser/devtools/devtools_manager_impl.h"
13 #include "content/public/browser/browser_thread.h"
15 namespace content {
17 namespace {
18 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances;
19 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER;
20 } // namespace
22 DevToolsAgentHostImpl::DevToolsAgentHostImpl()
23 : close_listener_(NULL),
24 id_(base::GenerateGUID()) {
25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
26 g_instances.Get()[id_] = this;
29 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() {
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
31 g_instances.Get().erase(g_instances.Get().find(id_));
34 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId(
35 const std::string& id) {
36 if (g_instances == NULL)
37 return NULL;
38 Instances::iterator it = g_instances.Get().find(id);
39 if (it == g_instances.Get().end())
40 return NULL;
41 return it->second;
44 bool DevToolsAgentHostImpl::IsAttached() {
45 return !!DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(this);
48 void DevToolsAgentHostImpl::InspectElement(int x, int y) {
51 std::string DevToolsAgentHostImpl::GetId() {
52 return id_;
55 RenderViewHost* DevToolsAgentHostImpl::GetRenderViewHost() {
56 return NULL;
59 void DevToolsAgentHostImpl::DisconnectRenderViewHost() {}
61 void DevToolsAgentHostImpl::ConnectRenderViewHost(RenderViewHost* rvh) {}
63 void DevToolsAgentHostImpl::NotifyCloseListener() {
64 if (close_listener_) {
65 scoped_refptr<DevToolsAgentHostImpl> protect(this);
66 close_listener_->AgentHostClosing(this);
67 close_listener_ = NULL;
71 } // namespace content