Android media: VideoFrame should not store so many sync points.
[chromium-blink-merge.git] / content / browser / devtools / devtools_agent_host_impl.cc
blobbcb60b55b7832b0348550bead85a164ffffc1539
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/browser/devtools/forwarding_agent_host.h"
14 #include "content/public/browser/browser_thread.h"
16 namespace content {
18 namespace {
19 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances;
20 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER;
21 } // namespace
23 DevToolsAgentHostImpl::DevToolsAgentHostImpl()
24 : close_listener_(NULL),
25 id_(base::GenerateGUID()) {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27 g_instances.Get()[id_] = this;
30 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 g_instances.Get().erase(g_instances.Get().find(id_));
35 //static
36 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId(
37 const std::string& id) {
38 if (g_instances == NULL)
39 return NULL;
40 Instances::iterator it = g_instances.Get().find(id);
41 if (it == g_instances.Get().end())
42 return NULL;
43 return it->second;
46 //static
47 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::Create(
48 DevToolsExternalAgentProxyDelegate* delegate) {
49 return new ForwardingAgentHost(delegate);
52 bool DevToolsAgentHostImpl::IsAttached() {
53 return !!DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(this);
56 void DevToolsAgentHostImpl::InspectElement(int x, int y) {
59 std::string DevToolsAgentHostImpl::GetId() {
60 return id_;
63 RenderViewHost* DevToolsAgentHostImpl::GetRenderViewHost() {
64 return NULL;
67 void DevToolsAgentHostImpl::DisconnectRenderViewHost() {}
69 void DevToolsAgentHostImpl::ConnectRenderViewHost(RenderViewHost* rvh) {}
71 bool DevToolsAgentHostImpl::IsWorker() const {
72 return false;
75 void DevToolsAgentHostImpl::NotifyCloseListener() {
76 if (close_listener_) {
77 scoped_refptr<DevToolsAgentHostImpl> protect(this);
78 close_listener_->AgentHostClosing(this);
79 close_listener_ = NULL;
83 } // namespace content