| OLD | NEW |
| 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/render_frame_devtools_agent_host.h" |
| 15 #include "content/browser/devtools/service_worker_devtools_manager.h" | 16 #include "content/browser/devtools/service_worker_devtools_manager.h" |
| 16 #include "content/browser/devtools/shared_worker_devtools_manager.h" | 17 #include "content/browser/devtools/shared_worker_devtools_manager.h" |
| 17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/devtools_manager_delegate.h" | 19 #include "content/public/browser/devtools_manager_delegate.h" |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; | 24 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; |
| 24 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; | 25 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; |
| 25 | 26 |
| 26 typedef std::vector<const DevToolsAgentHost::AgentStateCallback*> | 27 typedef std::vector<const DevToolsAgentHost::AgentStateCallback*> |
| 27 AgentStateCallbacks; | 28 AgentStateCallbacks; |
| 28 base::LazyInstance<AgentStateCallbacks>::Leaky g_callbacks = | 29 base::LazyInstance<AgentStateCallbacks>::Leaky g_callbacks = |
| 29 LAZY_INSTANCE_INITIALIZER; | 30 LAZY_INSTANCE_INITIALIZER; |
| 30 } // namespace | 31 } // namespace |
| 31 | 32 |
| 32 // static | 33 // static |
| 33 DevToolsAgentHost::List DevToolsAgentHost::GetOrCreateAll() { | 34 DevToolsAgentHost::List DevToolsAgentHost::GetOrCreateAll() { |
| 34 List result; | 35 List result; |
| 35 SharedWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&result); | 36 SharedWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&result); |
| 36 ServiceWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&result); | 37 ServiceWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&result); |
| 37 std::vector<WebContents*> wc_list = | 38 RenderFrameDevToolsAgentHost::AddAllAgentHosts(&result); |
| 38 DevToolsAgentHostImpl::GetInspectableWebContents(); | |
| 39 for (std::vector<WebContents*>::iterator it = wc_list.begin(); | |
| 40 it != wc_list.end(); ++it) { | |
| 41 result.push_back(GetOrCreateFor(*it)); | |
| 42 } | |
| 43 return result; | 39 return result; |
| 44 } | 40 } |
| 45 | 41 |
| 46 // Called on the UI thread. | 42 // Called on the UI thread. |
| 47 // static | 43 // static |
| 48 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker( | 44 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker( |
| 49 int worker_process_id, | 45 int worker_process_id, |
| 50 int worker_route_id) { | 46 int worker_route_id) { |
| 51 if (scoped_refptr<DevToolsAgentHost> host = | 47 if (scoped_refptr<DevToolsAgentHost> host = |
| 52 SharedWorkerDevToolsManager::GetInstance() | 48 SharedWorkerDevToolsManager::GetInstance() |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 (*it)->Run(agent_host, attached); | 203 (*it)->Run(agent_host, attached); |
| 208 } | 204 } |
| 209 | 205 |
| 210 void DevToolsAgentHostImpl::Inspect(BrowserContext* browser_context) { | 206 void DevToolsAgentHostImpl::Inspect(BrowserContext* browser_context) { |
| 211 DevToolsManager* manager = DevToolsManager::GetInstance(); | 207 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 212 if (manager->delegate()) | 208 if (manager->delegate()) |
| 213 manager->delegate()->Inspect(browser_context, this); | 209 manager->delegate()->Inspect(browser_context, this); |
| 214 } | 210 } |
| 215 | 211 |
| 216 } // namespace content | 212 } // namespace content |
| OLD | NEW |