Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: content/browser/devtools/devtools_agent_host_impl.cc

Issue 13305002: Remove redundant DevToolsManager methods and clean up its clients. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/browser/devtools/devtools_agent_host_impl.h" 5 #include "content/browser/devtools/devtools_agent_host_impl.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/guid.h" 10 #include "base/guid.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "content/browser/devtools/devtools_manager_impl.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 namespace { 16 namespace {
16 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; 17 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances;
17 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; 18 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER;
18 } // namespace 19 } // namespace
19 20
20 DevToolsAgentHostImpl::DevToolsAgentHostImpl() 21 DevToolsAgentHostImpl::DevToolsAgentHostImpl()
21 : close_listener_(NULL), 22 : close_listener_(NULL),
22 id_(base::GenerateGUID()) { 23 id_(base::GenerateGUID()) {
23 g_instances.Get()[id_] = this; 24 g_instances.Get()[id_] = this;
24 } 25 }
25 26
26 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() { 27 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() {
27 g_instances.Get().erase(g_instances.Get().find(id_)); 28 g_instances.Get().erase(g_instances.Get().find(id_));
28 } 29 }
29 30
30 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId( 31 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId(
31 const std::string& id) { 32 const std::string& id) {
32 if (g_instances == NULL) 33 if (g_instances == NULL)
33 return NULL; 34 return NULL;
34 Instances::iterator it = g_instances.Get().find(id); 35 Instances::iterator it = g_instances.Get().find(id);
35 if (it == g_instances.Get().end()) 36 if (it == g_instances.Get().end())
36 return NULL; 37 return NULL;
37 return it->second; 38 return it->second;
38 } 39 }
39 40
41 bool DevToolsAgentHostImpl::IsAttached() {
42 return !!DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(this);
43 }
44
40 void DevToolsAgentHostImpl::InspectElement(int x, int y) { 45 void DevToolsAgentHostImpl::InspectElement(int x, int y) {
41 } 46 }
42 47
43 std::string DevToolsAgentHostImpl::GetId() { 48 std::string DevToolsAgentHostImpl::GetId() {
44 return id_; 49 return id_;
45 } 50 }
46 51
47 RenderViewHost* DevToolsAgentHostImpl::GetRenderViewHost() { 52 RenderViewHost* DevToolsAgentHostImpl::GetRenderViewHost() {
48 return NULL; 53 return NULL;
49 } 54 }
50 55
51 void DevToolsAgentHostImpl::NotifyCloseListener() { 56 void DevToolsAgentHostImpl::NotifyCloseListener() {
52 if (close_listener_) { 57 if (close_listener_) {
53 scoped_refptr<DevToolsAgentHostImpl> protect(this); 58 scoped_refptr<DevToolsAgentHostImpl> protect(this);
54 close_listener_->AgentHostClosing(this); 59 close_listener_->AgentHostClosing(this);
55 close_listener_ = NULL; 60 close_listener_ = NULL;
56 } 61 }
57 } 62 }
58 63
59 } // namespace content 64 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_agent_host_impl.h ('k') | content/browser/devtools/devtools_external_agent_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698