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_impl.h" | 7 #include "content/browser/devtools/devtools_manager_impl.h" |
8 #include "content/browser/devtools/devtools_protocol.h" | 8 #include "content/browser/devtools/devtools_protocol.h" |
9 #include "content/browser/devtools/devtools_protocol_constants.h" | 9 #include "content/browser/devtools/devtools_protocol_constants.h" |
10 #include "content/browser/devtools/ipc_devtools_agent_host.h" | 10 #include "content/browser/devtools/ipc_devtools_agent_host.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
215 const WorkerId id(worker_process_id, worker_route_id); | 215 const WorkerId id(worker_process_id, worker_route_id); |
216 WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo( | 216 WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo( |
217 storage_partition_path, service_worker_scope); | 217 storage_partition_path, service_worker_scope); |
218 if (it == workers_.end()) { | 218 if (it == workers_.end()) { |
219 scoped_ptr<WorkerInfo> info( | 219 scoped_ptr<WorkerInfo> info( |
220 new WorkerInfo(storage_partition_path, service_worker_scope)); | 220 new WorkerInfo(storage_partition_path, service_worker_scope)); |
221 workers_.set(id, info.Pass()); | 221 workers_.set(id, info.Pass()); |
222 return false; | 222 return false; |
223 } | 223 } |
224 if (WORKER_TERMINATED != it->second->state()) { | |
225 // WorkerDestroyed is called when EmbeddedWorkerInstance is deleted. But in | |
226 // current code ServiceWorkerStorage::DeleteRegistration doesn't remove the | |
227 // instance. So WorkerDestroyed could not be called correctly. | |
228 // TODO(horo): Remove this if statement when it becomes unnecessary. | |
kinuko
2014/05/13 16:25:14
nit: You can refer to the issue for stopping worke
horo
2014/05/14 05:09:59
As we talked offline, I changed EmbeddedWorkerDevT
| |
229 DLOG(ERROR) << "WorkerDestroyed has not been called correctly."; | |
230 WorkerDestroyed(it->first.first, it->first.second); | |
231 return ServiceWorkerCreated(worker_process_id, | |
232 worker_route_id, | |
233 storage_partition_path, | |
234 service_worker_scope); | |
235 } | |
224 MoveToPausedState(id, it); | 236 MoveToPausedState(id, it); |
225 return true; | 237 return true; |
226 } | 238 } |
227 | 239 |
228 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id, | 240 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id, |
229 int worker_route_id) { | 241 int worker_route_id) { |
230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
231 const WorkerId id(worker_process_id, worker_route_id); | 243 const WorkerId id(worker_process_id, worker_route_id); |
232 WorkerInfoMap::iterator it = workers_.find(id); | 244 WorkerInfoMap::iterator it = workers_.find(id); |
233 DCHECK(it != workers_.end()); | 245 DCHECK(it != workers_.end()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 for (; it != workers_.end(); ++it) { | 334 for (; it != workers_.end(); ++it) { |
323 if (it->second->Matches(storage_partition_path, service_worker_scope)) | 335 if (it->second->Matches(storage_partition_path, service_worker_scope)) |
324 break; | 336 break; |
325 } | 337 } |
326 return it; | 338 return it; |
327 } | 339 } |
328 | 340 |
329 void EmbeddedWorkerDevToolsManager::MoveToPausedState( | 341 void EmbeddedWorkerDevToolsManager::MoveToPausedState( |
330 const WorkerId& id, | 342 const WorkerId& id, |
331 const WorkerInfoMap::iterator& it) { | 343 const WorkerInfoMap::iterator& it) { |
332 DCHECK_EQ(WORKER_TERMINATED, it->second->state()); | 344 DCHECK_EQ(WORKER_TERMINATED, it->second->state()); |
kinuko
2014/05/13 16:25:14
nit: extra space got in?
horo
2014/05/14 05:09:59
Done.
| |
333 scoped_ptr<WorkerInfo> info = workers_.take_and_erase(it); | 345 scoped_ptr<WorkerInfo> info = workers_.take_and_erase(it); |
334 info->set_state(WORKER_PAUSED); | 346 info->set_state(WORKER_PAUSED); |
335 workers_.set(id, info.Pass()); | 347 workers_.set(id, info.Pass()); |
336 } | 348 } |
337 | 349 |
338 void EmbeddedWorkerDevToolsManager::ResetForTesting() { | 350 void EmbeddedWorkerDevToolsManager::ResetForTesting() { |
339 workers_.clear(); | 351 workers_.clear(); |
340 } | 352 } |
341 | 353 |
342 } // namespace content | 354 } // namespace content |
OLD | NEW |