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 | 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 kAgentHostTypePage[] = "page"; |
| 20 const char kAgentHostTypeWorker[] = "worker"; |
| 21 const char kAgentHostTypeServiceWorker[] = "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_)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |