OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/embedded_worker_devtools_manager.h" | 5 #include "content/browser/devtools/embedded_worker_devtools_manager.h" |
6 | 6 |
7 #include "content/browser/devtools/devtools_manager.h" | |
8 #include "content/browser/devtools/devtools_protocol.h" | 7 #include "content/browser/devtools/devtools_protocol.h" |
9 #include "content/browser/devtools/devtools_protocol_constants.h" | 8 #include "content/browser/devtools/devtools_protocol_constants.h" |
10 #include "content/browser/devtools/embedded_worker_devtools_agent_host.h" | 9 #include "content/browser/devtools/embedded_worker_devtools_agent_host.h" |
11 #include "content/browser/devtools/ipc_devtools_agent_host.h" | 10 #include "content/browser/devtools/ipc_devtools_agent_host.h" |
12 #include "content/browser/shared_worker/shared_worker_instance.h" | 11 #include "content/browser/shared_worker/shared_worker_instance.h" |
13 #include "content/common/devtools_messages.h" | 12 #include "content/common/devtools_messages.h" |
14 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
16 #include "content/public/browser/worker_service.h" | 15 #include "content/public/browser/worker_service.h" |
17 #include "ipc/ipc_listener.h" | 16 #include "ipc/ipc_listener.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 97 |
99 bool EmbeddedWorkerDevToolsManager::SharedWorkerCreated( | 98 bool EmbeddedWorkerDevToolsManager::SharedWorkerCreated( |
100 int worker_process_id, | 99 int worker_process_id, |
101 int worker_route_id, | 100 int worker_route_id, |
102 const SharedWorkerInstance& instance) { | 101 const SharedWorkerInstance& instance) { |
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
104 const WorkerId id(worker_process_id, worker_route_id); | 103 const WorkerId id(worker_process_id, worker_route_id); |
105 AgentHostMap::iterator it = FindExistingSharedWorkerAgentHost(instance); | 104 AgentHostMap::iterator it = FindExistingSharedWorkerAgentHost(instance); |
106 if (it == workers_.end()) { | 105 if (it == workers_.end()) { |
107 workers_[id] = new EmbeddedWorkerDevToolsAgentHost(id, instance); | 106 workers_[id] = new EmbeddedWorkerDevToolsAgentHost(id, instance); |
108 DevToolsManager::GetInstance()->AgentHostChanged(workers_[id]); | |
109 return false; | 107 return false; |
110 } | 108 } |
111 WorkerRestarted(id, it); | 109 WorkerRestarted(id, it); |
112 return true; | 110 return true; |
113 } | 111 } |
114 | 112 |
115 bool EmbeddedWorkerDevToolsManager::ServiceWorkerCreated( | 113 bool EmbeddedWorkerDevToolsManager::ServiceWorkerCreated( |
116 int worker_process_id, | 114 int worker_process_id, |
117 int worker_route_id, | 115 int worker_route_id, |
118 const ServiceWorkerIdentifier& service_worker_id) { | 116 const ServiceWorkerIdentifier& service_worker_id) { |
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
120 const WorkerId id(worker_process_id, worker_route_id); | 118 const WorkerId id(worker_process_id, worker_route_id); |
121 AgentHostMap::iterator it = | 119 AgentHostMap::iterator it = |
122 FindExistingServiceWorkerAgentHost(service_worker_id); | 120 FindExistingServiceWorkerAgentHost(service_worker_id); |
123 if (it == workers_.end()) { | 121 if (it == workers_.end()) { |
124 workers_[id] = new EmbeddedWorkerDevToolsAgentHost( | 122 workers_[id] = new EmbeddedWorkerDevToolsAgentHost( |
125 id, service_worker_id, debug_service_worker_on_start_); | 123 id, service_worker_id, debug_service_worker_on_start_); |
126 DevToolsManager::GetInstance()->AgentHostChanged(workers_[id]); | |
127 return debug_service_worker_on_start_; | 124 return debug_service_worker_on_start_; |
128 } | 125 } |
129 WorkerRestarted(id, it); | 126 WorkerRestarted(id, it); |
130 return true; | 127 return true; |
131 } | 128 } |
132 | 129 |
133 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id, | 130 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id, |
134 int worker_route_id) { | 131 int worker_route_id) { |
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
136 const WorkerId id(worker_process_id, worker_route_id); | 133 const WorkerId id(worker_process_id, worker_route_id); |
137 AgentHostMap::iterator it = workers_.find(id); | 134 AgentHostMap::iterator it = workers_.find(id); |
138 DCHECK(it != workers_.end()); | 135 DCHECK(it != workers_.end()); |
139 scoped_refptr<EmbeddedWorkerDevToolsAgentHost> agent_host(it->second); | 136 it->second->WorkerDestroyed(); |
140 agent_host->WorkerDestroyed(); | |
141 DevToolsManager::GetInstance()->AgentHostChanged(agent_host); | |
142 } | 137 } |
143 | 138 |
144 void EmbeddedWorkerDevToolsManager::WorkerReadyForInspection( | 139 void EmbeddedWorkerDevToolsManager::WorkerReadyForInspection( |
145 int worker_process_id, | 140 int worker_process_id, |
146 int worker_route_id) { | 141 int worker_route_id) { |
147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
148 const WorkerId id(worker_process_id, worker_route_id); | 143 const WorkerId id(worker_process_id, worker_route_id); |
149 AgentHostMap::iterator it = workers_.find(id); | 144 AgentHostMap::iterator it = workers_.find(id); |
150 DCHECK(it != workers_.end()); | 145 DCHECK(it != workers_.end()); |
151 it->second->WorkerReadyForInspection(); | 146 it->second->WorkerReadyForInspection(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 return result; | 194 return result; |
200 } | 195 } |
201 | 196 |
202 void EmbeddedWorkerDevToolsManager::WorkerRestarted( | 197 void EmbeddedWorkerDevToolsManager::WorkerRestarted( |
203 const WorkerId& id, | 198 const WorkerId& id, |
204 const AgentHostMap::iterator& it) { | 199 const AgentHostMap::iterator& it) { |
205 EmbeddedWorkerDevToolsAgentHost* agent_host = it->second; | 200 EmbeddedWorkerDevToolsAgentHost* agent_host = it->second; |
206 agent_host->WorkerRestarted(id); | 201 agent_host->WorkerRestarted(id); |
207 workers_.erase(it); | 202 workers_.erase(it); |
208 workers_[id] = agent_host; | 203 workers_[id] = agent_host; |
209 DevToolsManager::GetInstance()->AgentHostChanged(agent_host); | |
210 } | 204 } |
211 | 205 |
212 void EmbeddedWorkerDevToolsManager::ResetForTesting() { | 206 void EmbeddedWorkerDevToolsManager::ResetForTesting() { |
213 workers_.clear(); | 207 workers_.clear(); |
214 } | 208 } |
215 | 209 |
216 } // namespace content | 210 } // namespace content |
OLD | NEW |