OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/debugger/worker_devtools_manager.h" | 5 #include "content/browser/debugger/worker_devtools_manager.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "content/browser/debugger/devtools_agent_host.h" | 11 #include "content/browser/debugger/devtools_agent_host.h" |
12 #include "content/browser/debugger/devtools_manager_impl.h" | 12 #include "content/browser/debugger/devtools_manager_impl.h" |
13 #include "content/browser/debugger/worker_devtools_message_filter.h" | 13 #include "content/browser/debugger/worker_devtools_message_filter.h" |
14 #include "content/browser/worker_host/worker_process_host.h" | 14 #include "content/browser/worker_host/worker_process_host.h" |
15 #include "content/browser/worker_host/worker_service_impl.h" | 15 #include "content/browser/worker_host/worker_service_impl.h" |
16 #include "content/common/devtools_messages.h" | 16 #include "content/common/devtools_messages.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/child_process_data.h" |
18 #include "content/public/browser/devtools_agent_host_registry.h" | 19 #include "content/public/browser/devtools_agent_host_registry.h" |
19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
23 #include "content/public/common/process_type.h" | 24 #include "content/public/common/process_type.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
27 | 28 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 286 |
286 void WorkerDevToolsManager::WorkerCreated( | 287 void WorkerDevToolsManager::WorkerCreated( |
287 WorkerProcessHost* worker, | 288 WorkerProcessHost* worker, |
288 const WorkerProcessHost::WorkerInstance& instance) { | 289 const WorkerProcessHost::WorkerInstance& instance) { |
289 for (TerminatedInspectedWorkers::iterator it = terminated_workers_.begin(); | 290 for (TerminatedInspectedWorkers::iterator it = terminated_workers_.begin(); |
290 it != terminated_workers_.end(); ++it) { | 291 it != terminated_workers_.end(); ++it) { |
291 if (instance.Matches(it->worker_url, it->worker_name, | 292 if (instance.Matches(it->worker_url, it->worker_name, |
292 instance.resource_context())) { | 293 instance.resource_context())) { |
293 worker->Send(new DevToolsAgentMsg_PauseWorkerContextOnStart( | 294 worker->Send(new DevToolsAgentMsg_PauseWorkerContextOnStart( |
294 instance.worker_route_id())); | 295 instance.worker_route_id())); |
295 WorkerId new_worker_id( | 296 WorkerId new_worker_id(worker->GetData().id, instance.worker_route_id()); |
296 worker->data().id, instance.worker_route_id()); | |
297 paused_workers_[new_worker_id] = it->old_worker_id; | 297 paused_workers_[new_worker_id] = it->old_worker_id; |
298 terminated_workers_.erase(it); | 298 terminated_workers_.erase(it); |
299 return; | 299 return; |
300 } | 300 } |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 void WorkerDevToolsManager::WorkerDestroyed( | 304 void WorkerDevToolsManager::WorkerDestroyed( |
305 WorkerProcessHost* worker, | 305 WorkerProcessHost* worker, |
306 int worker_route_id) { | 306 int worker_route_id) { |
307 InspectedWorkersList::iterator it = FindInspectedWorker( | 307 InspectedWorkersList::iterator it = FindInspectedWorker( |
308 worker->data().id, | 308 worker->GetData().id, |
309 worker_route_id); | 309 worker_route_id); |
310 if (it == inspected_workers_.end()) | 310 if (it == inspected_workers_.end()) |
311 return; | 311 return; |
312 | 312 |
313 WorkerId worker_id(worker->data().id, worker_route_id); | 313 WorkerId worker_id(worker->GetData().id, worker_route_id); |
314 terminated_workers_.push_back(TerminatedInspectedWorker( | 314 terminated_workers_.push_back(TerminatedInspectedWorker( |
315 worker_id, | 315 worker_id, |
316 it->worker_url, | 316 it->worker_url, |
317 it->worker_name)); | 317 it->worker_name)); |
318 inspected_workers_.erase(it); | 318 inspected_workers_.erase(it); |
319 BrowserThread::PostTask( | 319 BrowserThread::PostTask( |
320 BrowserThread::UI, FROM_HERE, | 320 BrowserThread::UI, FROM_HERE, |
321 base::Bind(&DetachedClientHosts::WorkerDestroyed, worker_id)); | 321 base::Bind(&DetachedClientHosts::WorkerDestroyed, worker_id)); |
322 } | 322 } |
323 | 323 |
324 void WorkerDevToolsManager::WorkerContextStarted(WorkerProcessHost* process, | 324 void WorkerDevToolsManager::WorkerContextStarted(WorkerProcessHost* process, |
325 int worker_route_id) { | 325 int worker_route_id) { |
326 WorkerId new_worker_id(process->data().id, worker_route_id); | 326 WorkerId new_worker_id(process->GetData().id, worker_route_id); |
327 PausedWorkers::iterator it = paused_workers_.find(new_worker_id); | 327 PausedWorkers::iterator it = paused_workers_.find(new_worker_id); |
328 if (it == paused_workers_.end()) | 328 if (it == paused_workers_.end()) |
329 return; | 329 return; |
330 | 330 |
331 BrowserThread::PostTask( | 331 BrowserThread::PostTask( |
332 BrowserThread::UI, FROM_HERE, | 332 BrowserThread::UI, FROM_HERE, |
333 base::Bind( | 333 base::Bind( |
334 &DetachedClientHosts::WorkerReloaded, | 334 &DetachedClientHosts::WorkerReloaded, |
335 it->second, | 335 it->second, |
336 new_worker_id)); | 336 new_worker_id)); |
(...skipping 18 matching lines...) Expand all Loading... |
355 return; | 355 return; |
356 } | 356 } |
357 } | 357 } |
358 } | 358 } |
359 | 359 |
360 WorkerDevToolsManager::InspectedWorkersList::iterator | 360 WorkerDevToolsManager::InspectedWorkersList::iterator |
361 WorkerDevToolsManager::FindInspectedWorker( | 361 WorkerDevToolsManager::FindInspectedWorker( |
362 int host_id, int route_id) { | 362 int host_id, int route_id) { |
363 InspectedWorkersList::iterator it = inspected_workers_.begin(); | 363 InspectedWorkersList::iterator it = inspected_workers_.begin(); |
364 while (it != inspected_workers_.end()) { | 364 while (it != inspected_workers_.end()) { |
365 if (it->host->data().id == host_id && it->route_id == route_id) | 365 if (it->host->GetData().id == host_id && it->route_id == route_id) |
366 break; | 366 break; |
367 ++it; | 367 ++it; |
368 } | 368 } |
369 return it; | 369 return it; |
370 } | 370 } |
371 | 371 |
372 static WorkerProcessHost* FindWorkerProcess(int worker_process_id) { | 372 static WorkerProcessHost* FindWorkerProcess(int worker_process_id) { |
373 BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER); | 373 for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { |
374 for (; !iter.Done(); ++iter) { | 374 if (iter.GetData().id == worker_process_id) |
375 if (iter->data().id == worker_process_id) | 375 return *iter; |
376 return static_cast<WorkerProcessHost*>(*iter); | |
377 } | 376 } |
378 return NULL; | 377 return NULL; |
379 } | 378 } |
380 | 379 |
381 void WorkerDevToolsManager::RegisterDevToolsAgentHostForWorker( | 380 void WorkerDevToolsManager::RegisterDevToolsAgentHostForWorker( |
382 int worker_process_id, | 381 int worker_process_id, |
383 int worker_route_id) { | 382 int worker_route_id) { |
384 if (WorkerProcessHost* process = FindWorkerProcess(worker_process_id)) { | 383 if (WorkerProcessHost* process = FindWorkerProcess(worker_process_id)) { |
385 const WorkerProcessHost::Instances& instances = process->instances(); | 384 const WorkerProcessHost::Instances& instances = process->instances(); |
386 for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); | 385 for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 host->WorkerDestroyed(); | 489 host->WorkerDestroyed(); |
491 } | 490 } |
492 | 491 |
493 // static | 492 // static |
494 void WorkerDevToolsManager::SendResumeToWorker(const WorkerId& id) { | 493 void WorkerDevToolsManager::SendResumeToWorker(const WorkerId& id) { |
495 if (WorkerProcessHost* process = FindWorkerProcess(id.first)) | 494 if (WorkerProcessHost* process = FindWorkerProcess(id.first)) |
496 process->Send(new DevToolsAgentMsg_ResumeWorkerContext(id.second)); | 495 process->Send(new DevToolsAgentMsg_ResumeWorkerContext(id.second)); |
497 } | 496 } |
498 | 497 |
499 } // namespace | 498 } // namespace |
OLD | NEW |