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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
212 const WorkerId id(worker_process_id, worker_route_id); | 212 const WorkerId id(worker_process_id, worker_route_id); |
213 WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo( | 213 WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo( |
214 storage_partition_path, service_worker_scope); | 214 storage_partition_path, service_worker_scope); |
215 if (it == workers_.end()) { | 215 if (it == workers_.end()) { |
216 scoped_ptr<WorkerInfo> info( | 216 scoped_ptr<WorkerInfo> info( |
217 new WorkerInfo(storage_partition_path, service_worker_scope)); | 217 new WorkerInfo(storage_partition_path, service_worker_scope)); |
218 workers_.set(id, info.Pass()); | 218 workers_.set(id, info.Pass()); |
219 return false; | 219 return false; |
220 } | 220 } |
221 if (WORKER_TERMINATED != it->second->state()) { | |
222 // WorkerDestroyed is called when EmbeddedWorkerInstance is deleted. But in | |
223 // current code ServiceWorkerStorage::DeleteRegistration doesn't remove the | |
224 // instance. So WorkerDestroyed could not be called correctly. | |
225 // TODO(horo): Remove this if statement when it becomes unnecessary. | |
kinuko
2014/05/13 05:45:19
Um... looks like this is another undesirable effec
horo
2014/05/13 09:11:21
I think so too.
This is a work around code.
In cur
| |
226 DLOG(ERROR) << "WorkerDestroyed has not been called correctly."; | |
227 WorkerDestroyed(it->first.first, it->first.second); | |
228 return ServiceWorkerCreated(worker_process_id, | |
229 worker_route_id, | |
230 storage_partition_path, | |
231 service_worker_scope); | |
232 } | |
221 MoveToPausedState(id, it); | 233 MoveToPausedState(id, it); |
222 return true; | 234 return true; |
223 } | 235 } |
224 | 236 |
225 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id, | 237 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id, |
226 int worker_route_id) { | 238 int worker_route_id) { |
227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 239 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
228 const WorkerId id(worker_process_id, worker_route_id); | 240 const WorkerId id(worker_process_id, worker_route_id); |
229 WorkerInfoMap::iterator it = workers_.find(id); | 241 WorkerInfoMap::iterator it = workers_.find(id); |
230 DCHECK(it != workers_.end()); | 242 DCHECK(it != workers_.end()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 for (; it != workers_.end(); ++it) { | 331 for (; it != workers_.end(); ++it) { |
320 if (it->second->Matches(storage_partition_path, service_worker_scope)) | 332 if (it->second->Matches(storage_partition_path, service_worker_scope)) |
321 break; | 333 break; |
322 } | 334 } |
323 return it; | 335 return it; |
324 } | 336 } |
325 | 337 |
326 void EmbeddedWorkerDevToolsManager::MoveToPausedState( | 338 void EmbeddedWorkerDevToolsManager::MoveToPausedState( |
327 const WorkerId& id, | 339 const WorkerId& id, |
328 const WorkerInfoMap::iterator& it) { | 340 const WorkerInfoMap::iterator& it) { |
329 DCHECK_EQ(WORKER_TERMINATED, it->second->state()); | 341 DCHECK_EQ(WORKER_TERMINATED, it->second->state()); |
330 scoped_ptr<WorkerInfo> info = workers_.take_and_erase(it); | 342 scoped_ptr<WorkerInfo> info = workers_.take_and_erase(it); |
331 info->set_state(WORKER_PAUSED); | 343 info->set_state(WORKER_PAUSED); |
332 workers_.set(id, info.Pass()); | 344 workers_.set(id, info.Pass()); |
333 } | 345 } |
334 | 346 |
335 void EmbeddedWorkerDevToolsManager::ResetForTesting() { | 347 void EmbeddedWorkerDevToolsManager::ResetForTesting() { |
336 workers_.clear(); | 348 workers_.clear(); |
337 } | 349 } |
338 | 350 |
339 } // namespace content | 351 } // namespace content |
OLD | NEW |