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

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

Issue 988003002: DevTools: pick sw targets to attach to on the backend side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: track url, not frame Created 5 years, 9 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 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "content/browser/devtools/devtools_manager.h" 13 #include "content/browser/devtools/devtools_manager.h"
14 #include "content/browser/devtools/forwarding_agent_host.h" 14 #include "content/browser/devtools/forwarding_agent_host.h"
15 #include "content/browser/devtools/service_worker_devtools_agent_host.h"
15 #include "content/browser/devtools/service_worker_devtools_manager.h" 16 #include "content/browser/devtools/service_worker_devtools_manager.h"
17 #include "content/browser/devtools/shared_worker_devtools_agent_host.h"
16 #include "content/browser/devtools/shared_worker_devtools_manager.h" 18 #include "content/browser/devtools/shared_worker_devtools_manager.h"
17 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/devtools_manager_delegate.h" 20 #include "content/public/browser/devtools_manager_delegate.h"
19 21
20 namespace content { 22 namespace content {
21 23
22 namespace { 24 namespace {
23 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; 25 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances;
24 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; 26 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER;
25 27
26 typedef std::vector<const DevToolsAgentHost::AgentStateCallback*> 28 typedef std::vector<const DevToolsAgentHost::AgentStateCallback*>
27 AgentStateCallbacks; 29 AgentStateCallbacks;
28 base::LazyInstance<AgentStateCallbacks>::Leaky g_callbacks = 30 base::LazyInstance<AgentStateCallbacks>::Leaky g_callbacks =
29 LAZY_INSTANCE_INITIALIZER; 31 LAZY_INSTANCE_INITIALIZER;
30 } // namespace 32 } // namespace
31 33
32 // static 34 // static
33 DevToolsAgentHost::List DevToolsAgentHost::GetOrCreateAll() { 35 DevToolsAgentHost::List DevToolsAgentHost::GetOrCreateAll() {
36 SharedWorkerDevToolsAgentHost::List shared_list;
37 SharedWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&shared_list);
38 ServiceWorkerDevToolsAgentHost::List service_list;
39 ServiceWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&service_list);
40
34 List result; 41 List result;
35 SharedWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&result); 42 for (const auto& host : shared_list)
36 ServiceWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&result); 43 result.push_back(host);
44 for (const auto& host : service_list)
45 result.push_back(host);
46
37 std::vector<WebContents*> wc_list = 47 std::vector<WebContents*> wc_list =
38 DevToolsAgentHostImpl::GetInspectableWebContents(); 48 DevToolsAgentHostImpl::GetInspectableWebContents();
39 for (std::vector<WebContents*>::iterator it = wc_list.begin(); 49 for (std::vector<WebContents*>::iterator it = wc_list.begin();
40 it != wc_list.end(); ++it) { 50 it != wc_list.end(); ++it) {
41 result.push_back(GetOrCreateFor(*it)); 51 result.push_back(GetOrCreateFor(*it));
42 } 52 }
43 return result; 53 return result;
44 } 54 }
45 55
46 // Called on the UI thread. 56 // Called on the UI thread.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 (*it)->Run(agent_host, attached); 216 (*it)->Run(agent_host, attached);
207 } 217 }
208 218
209 void DevToolsAgentHostImpl::Inspect(BrowserContext* browser_context) { 219 void DevToolsAgentHostImpl::Inspect(BrowserContext* browser_context) {
210 DevToolsManager* manager = DevToolsManager::GetInstance(); 220 DevToolsManager* manager = DevToolsManager::GetInstance();
211 if (manager->delegate()) 221 if (manager->delegate())
212 manager->delegate()->Inspect(browser_context, this); 222 manager->delegate()->Inspect(browser_context, this);
213 } 223 }
214 224
215 } // namespace content 225 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698