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

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

Issue 459403002: DevTools: Added service workers to remote debugging targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed constants Created 6 years, 4 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
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 #include "content/browser/devtools/devtools_manager_impl.h"
13 #include "content/browser/devtools/embedded_worker_devtools_manager.h"
13 #include "content/browser/devtools/forwarding_agent_host.h" 14 #include "content/browser/devtools/forwarding_agent_host.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 16
16 namespace content { 17 namespace content {
17 18
19 const char DevToolsAgentHost::kTypeWebContents[] = "web_contents";
20 const char DevToolsAgentHost::kTypeWorker[] = "worker";
21 const char DevToolsAgentHost::kTypeServiceWorker[] = "service_worker";
22
18 namespace { 23 namespace {
19 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; 24 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances;
20 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; 25 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER;
21 } // namespace 26 } // namespace
22 27
28 // static
29 DevToolsAgentHost::List DevToolsAgentHost::GetOrCreateAll() {
30 List result = EmbeddedWorkerDevToolsManager::GetInstance()
31 ->GetOrCreateAllAgentHosts();
32 std::vector<WebContents*> wc_list =
33 DevToolsAgentHostImpl::GetInspectableWebContents();
34 for (std::vector<WebContents*>::iterator it = wc_list.begin();
35 it != wc_list.end(); ++it) {
36 result.push_back(GetOrCreateFor(*it));
37 }
38 return result;
39 }
40
23 DevToolsAgentHostImpl::DevToolsAgentHostImpl() 41 DevToolsAgentHostImpl::DevToolsAgentHostImpl()
24 : close_listener_(NULL), 42 : close_listener_(NULL),
25 id_(base::GenerateGUID()) { 43 id_(base::GenerateGUID()) {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27 g_instances.Get()[id_] = this; 45 g_instances.Get()[id_] = this;
28 } 46 }
29 47
30 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() { 48 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 g_instances.Get().erase(g_instances.Get().find(id_)); 50 g_instances.Get().erase(g_instances.Get().find(id_));
33 } 51 }
34 52
35 //static 53 // static
36 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId( 54 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId(
37 const std::string& id) { 55 const std::string& id) {
38 if (g_instances == NULL) 56 if (g_instances == NULL)
39 return NULL; 57 return NULL;
40 Instances::iterator it = g_instances.Get().find(id); 58 Instances::iterator it = g_instances.Get().find(id);
41 if (it == g_instances.Get().end()) 59 if (it == g_instances.Get().end())
42 return NULL; 60 return NULL;
43 return it->second; 61 return it->second;
44 } 62 }
45 63
(...skipping 30 matching lines...) Expand all
76 94
77 void DevToolsAgentHostImpl::NotifyCloseListener() { 95 void DevToolsAgentHostImpl::NotifyCloseListener() {
78 if (close_listener_) { 96 if (close_listener_) {
79 scoped_refptr<DevToolsAgentHostImpl> protect(this); 97 scoped_refptr<DevToolsAgentHostImpl> protect(this);
80 close_listener_->AgentHostClosing(this); 98 close_listener_->AgentHostClosing(this);
81 close_listener_ = NULL; 99 close_listener_ = NULL;
82 } 100 }
83 } 101 }
84 102
85 } // namespace content 103 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698