OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2010-2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "web/WebDevToolsAgentImpl.h" | 31 #include "web/WebDevToolsAgentImpl.h" |
32 | 32 |
33 #include "bindings/core/v8/ScriptController.h" | 33 #include "bindings/core/v8/ScriptController.h" |
34 #include "bindings/core/v8/V8Binding.h" | 34 #include "bindings/core/v8/V8Binding.h" |
| 35 #include "core/InstrumentingAgents.h" |
35 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
36 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
37 #include "core/frame/Settings.h" | 38 #include "core/frame/Settings.h" |
38 #include "core/inspector/InspectedFrames.h" | 39 #include "core/inspector/InspectedFrames.h" |
39 #include "core/inspector/InspectorAnimationAgent.h" | 40 #include "core/inspector/InspectorAnimationAgent.h" |
40 #include "core/inspector/InspectorApplicationCacheAgent.h" | 41 #include "core/inspector/InspectorApplicationCacheAgent.h" |
41 #include "core/inspector/InspectorCSSAgent.h" | 42 #include "core/inspector/InspectorCSSAgent.h" |
42 #include "core/inspector/InspectorDOMAgent.h" | 43 #include "core/inspector/InspectorDOMAgent.h" |
43 #include "core/inspector/InspectorDOMDebuggerAgent.h" | 44 #include "core/inspector/InspectorDOMDebuggerAgent.h" |
44 #include "core/inspector/InspectorDebuggerAgent.h" | 45 #include "core/inspector/InspectorDebuggerAgent.h" |
45 #include "core/inspector/InspectorHeapProfilerAgent.h" | 46 #include "core/inspector/InspectorHeapProfilerAgent.h" |
46 #include "core/inspector/InspectorInputAgent.h" | 47 #include "core/inspector/InspectorInputAgent.h" |
47 #include "core/inspector/InspectorInstrumentation.h" | 48 #include "core/inspector/InspectorInstrumentation.h" |
48 #include "core/inspector/InspectorLayerTreeAgent.h" | 49 #include "core/inspector/InspectorLayerTreeAgent.h" |
49 #include "core/inspector/InspectorMemoryAgent.h" | 50 #include "core/inspector/InspectorMemoryAgent.h" |
50 #include "core/inspector/InspectorPageAgent.h" | 51 #include "core/inspector/InspectorPageAgent.h" |
51 #include "core/inspector/InspectorProfilerAgent.h" | 52 #include "core/inspector/InspectorProfilerAgent.h" |
52 #include "core/inspector/InspectorResourceAgent.h" | 53 #include "core/inspector/InspectorResourceAgent.h" |
53 #include "core/inspector/InspectorResourceContainer.h" | 54 #include "core/inspector/InspectorResourceContainer.h" |
54 #include "core/inspector/InspectorResourceContentLoader.h" | 55 #include "core/inspector/InspectorResourceContentLoader.h" |
55 #include "core/inspector/InspectorTaskRunner.h" | 56 #include "core/inspector/InspectorTaskRunner.h" |
56 #include "core/inspector/InspectorTracingAgent.h" | 57 #include "core/inspector/InspectorTracingAgent.h" |
57 #include "core/inspector/InspectorWorkerAgent.h" | 58 #include "core/inspector/InspectorWorkerAgent.h" |
58 #include "core/inspector/InstrumentingAgents.h" | |
59 #include "core/inspector/LayoutEditor.h" | 59 #include "core/inspector/LayoutEditor.h" |
60 #include "core/inspector/MainThreadDebugger.h" | 60 #include "core/inspector/MainThreadDebugger.h" |
61 #include "core/inspector/PageConsoleAgent.h" | 61 #include "core/inspector/PageConsoleAgent.h" |
62 #include "core/inspector/PageDebuggerAgent.h" | 62 #include "core/inspector/PageDebuggerAgent.h" |
63 #include "core/inspector/PageRuntimeAgent.h" | 63 #include "core/inspector/PageRuntimeAgent.h" |
64 #include "core/layout/api/LayoutViewItem.h" | 64 #include "core/layout/api/LayoutViewItem.h" |
65 #include "core/page/FocusController.h" | 65 #include "core/page/FocusController.h" |
66 #include "core/page/Page.h" | 66 #include "core/page/Page.h" |
67 #include "modules/accessibility/InspectorAccessibilityAgent.h" | 67 #include "modules/accessibility/InspectorAccessibilityAgent.h" |
68 #include "modules/cachestorage/InspectorCacheStorageAgent.h" | 68 #include "modules/cachestorage/InspectorCacheStorageAgent.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 WebDevToolsAgentImpl::WebDevToolsAgentImpl( | 296 WebDevToolsAgentImpl::WebDevToolsAgentImpl( |
297 WebLocalFrameImpl* webLocalFrameImpl, | 297 WebLocalFrameImpl* webLocalFrameImpl, |
298 WebDevToolsAgentClient* client, | 298 WebDevToolsAgentClient* client, |
299 InspectorOverlay* overlay, | 299 InspectorOverlay* overlay, |
300 bool includeViewAgents) | 300 bool includeViewAgents) |
301 : m_client(client) | 301 : m_client(client) |
302 , m_webLocalFrameImpl(webLocalFrameImpl) | 302 , m_webLocalFrameImpl(webLocalFrameImpl) |
303 #if DCHECK_IS_ON() | 303 #if DCHECK_IS_ON() |
304 , m_hasBeenDisposed(false) | 304 , m_hasBeenDisposed(false) |
305 #endif | 305 #endif |
306 , m_instrumentingAgents(m_webLocalFrameImpl->frame()->instrumentingAgents()) | 306 , m_instrumentingSessions(m_webLocalFrameImpl->frame()->instrumentingSession
s()) |
307 , m_resourceContentLoader(InspectorResourceContentLoader::create(m_webLocalF
rameImpl->frame())) | 307 , m_resourceContentLoader(InspectorResourceContentLoader::create(m_webLocalF
rameImpl->frame())) |
308 , m_overlay(overlay) | 308 , m_overlay(overlay) |
309 , m_inspectedFrames(InspectedFrames::create(m_webLocalFrameImpl->frame())) | 309 , m_inspectedFrames(InspectedFrames::create(m_webLocalFrameImpl->frame())) |
310 , m_resourceContainer(new InspectorResourceContainer(m_inspectedFrames)) | 310 , m_resourceContainer(new InspectorResourceContainer(m_inspectedFrames)) |
311 , m_domAgent(nullptr) | 311 , m_domAgent(nullptr) |
312 , m_pageAgent(nullptr) | 312 , m_pageAgent(nullptr) |
313 , m_resourceAgent(nullptr) | 313 , m_resourceAgent(nullptr) |
314 , m_layerTreeAgent(nullptr) | 314 , m_layerTreeAgent(nullptr) |
315 , m_tracingAgent(nullptr) | 315 , m_tracingAgent(nullptr) |
316 , m_includeViewAgents(includeViewAgents) | 316 , m_includeViewAgents(includeViewAgents) |
(...skipping 30 matching lines...) Expand all Loading... |
347 | 347 |
348 // static | 348 // static |
349 void WebDevToolsAgentImpl::webFrameWidgetImplClosed(WebFrameWidgetImpl* webFrame
WidgetImpl) | 349 void WebDevToolsAgentImpl::webFrameWidgetImplClosed(WebFrameWidgetImpl* webFrame
WidgetImpl) |
350 { | 350 { |
351 ClientMessageLoopAdapter::webFrameWidgetImplClosed(webFrameWidgetImpl); | 351 ClientMessageLoopAdapter::webFrameWidgetImplClosed(webFrameWidgetImpl); |
352 } | 352 } |
353 | 353 |
354 DEFINE_TRACE(WebDevToolsAgentImpl) | 354 DEFINE_TRACE(WebDevToolsAgentImpl) |
355 { | 355 { |
356 visitor->trace(m_webLocalFrameImpl); | 356 visitor->trace(m_webLocalFrameImpl); |
357 visitor->trace(m_instrumentingAgents); | 357 visitor->trace(m_instrumentingSessions); |
358 visitor->trace(m_resourceContentLoader); | 358 visitor->trace(m_resourceContentLoader); |
359 visitor->trace(m_overlay); | 359 visitor->trace(m_overlay); |
360 visitor->trace(m_inspectedFrames); | 360 visitor->trace(m_inspectedFrames); |
361 visitor->trace(m_resourceContainer); | 361 visitor->trace(m_resourceContainer); |
362 visitor->trace(m_domAgent); | 362 visitor->trace(m_domAgent); |
363 visitor->trace(m_pageAgent); | 363 visitor->trace(m_pageAgent); |
364 visitor->trace(m_resourceAgent); | 364 visitor->trace(m_resourceAgent); |
365 visitor->trace(m_layerTreeAgent); | 365 visitor->trace(m_layerTreeAgent); |
366 visitor->trace(m_tracingAgent); | 366 visitor->trace(m_tracingAgent); |
367 visitor->trace(m_session); | 367 visitor->trace(m_session); |
368 } | 368 } |
369 | 369 |
370 void WebDevToolsAgentImpl::willBeDestroyed() | 370 void WebDevToolsAgentImpl::willBeDestroyed() |
371 { | 371 { |
372 DCHECK(m_webLocalFrameImpl->frame()); | 372 DCHECK(m_webLocalFrameImpl->frame()); |
373 DCHECK(m_inspectedFrames->root()->view()); | 373 DCHECK(m_inspectedFrames->root()->view()); |
374 detach(); | 374 detach(); |
375 m_resourceContentLoader->dispose(); | 375 m_resourceContentLoader->dispose(); |
376 } | 376 } |
377 | 377 |
378 void WebDevToolsAgentImpl::initializeSession(int sessionId, const String& hostId
) | 378 void WebDevToolsAgentImpl::initializeSession(int sessionId, const String& hostId
) |
379 { | 379 { |
380 m_session = new InspectorSession(this, sessionId, m_instrumentingAgents.get(
), false /* autoFlush */); | 380 m_session = new InspectorSession(this, sessionId, false /* autoFlush */); |
381 | 381 |
382 ClientMessageLoopAdapter::ensureMainThreadDebuggerCreated(m_client); | 382 ClientMessageLoopAdapter::ensureMainThreadDebuggerCreated(m_client); |
383 MainThreadDebugger* mainThreadDebugger = MainThreadDebugger::instance(); | 383 MainThreadDebugger* mainThreadDebugger = MainThreadDebugger::instance(); |
384 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); | 384 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
385 | 385 |
386 m_v8Session = mainThreadDebugger->debugger()->connect(mainThreadDebugger->co
ntextGroupId(m_inspectedFrames->root())); | 386 m_v8Session = mainThreadDebugger->debugger()->connect(mainThreadDebugger->co
ntextGroupId(m_inspectedFrames->root())); |
387 V8RuntimeAgent* runtimeAgent = m_v8Session->runtimeAgent(); | 387 V8RuntimeAgent* runtimeAgent = m_v8Session->runtimeAgent(); |
388 | 388 |
389 m_session->append(PageRuntimeAgent::create(this, runtimeAgent, m_inspectedFr
ames.get())); | 389 m_session->append(PageRuntimeAgent::create(this, runtimeAgent, m_inspectedFr
ames.get())); |
390 | 390 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 if (m_includeViewAgents) { | 443 if (m_includeViewAgents) { |
444 // TODO(dgozman): we should actually pass the view instead of frame, but
during | 444 // TODO(dgozman): we should actually pass the view instead of frame, but
during |
445 // remote->local transition we cannot access mainFrameImpl() yet, so we
have to store the | 445 // remote->local transition we cannot access mainFrameImpl() yet, so we
have to store the |
446 // frame which will become the main frame later. | 446 // frame which will become the main frame later. |
447 m_session->append(InspectorRenderingAgent::create(m_webLocalFrameImpl, m
_overlay.get())); | 447 m_session->append(InspectorRenderingAgent::create(m_webLocalFrameImpl, m
_overlay.get())); |
448 m_session->append(InspectorEmulationAgent::create(m_webLocalFrameImpl, t
his)); | 448 m_session->append(InspectorEmulationAgent::create(m_webLocalFrameImpl, t
his)); |
449 // TODO(dgozman): migrate each of the following agents to frame once mod
ule is ready. | 449 // TODO(dgozman): migrate each of the following agents to frame once mod
ule is ready. |
450 Page* page = m_webLocalFrameImpl->viewImpl()->page(); | 450 Page* page = m_webLocalFrameImpl->viewImpl()->page(); |
451 m_session->append(InspectorDatabaseAgent::create(page)); | 451 m_session->append(InspectorDatabaseAgent::create(page)); |
452 m_session->append(DeviceOrientationInspectorAgent::create(page)); | 452 m_session->append(DeviceOrientationInspectorAgent::create(page)); |
453 m_session->append(InspectorAccessibilityAgent::create(page)); | 453 m_session->append(new InspectorAccessibilityAgent(page, m_domAgent)); |
454 m_session->append(InspectorDOMStorageAgent::create(page)); | 454 m_session->append(InspectorDOMStorageAgent::create(page)); |
455 m_session->append(InspectorCacheStorageAgent::create()); | 455 m_session->append(InspectorCacheStorageAgent::create()); |
456 } | 456 } |
457 | 457 |
458 if (m_overlay) | 458 if (m_overlay) |
459 m_overlay->init(cssAgent, debuggerAgent, m_domAgent); | 459 m_overlay->init(cssAgent, debuggerAgent, m_domAgent); |
460 | 460 |
461 Platform::current()->currentThread()->addTaskObserver(this); | 461 Platform::current()->currentThread()->addTaskObserver(this); |
462 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents.
get()); | 462 InspectorInstrumentation::registerInstrumentingSessions(m_instrumentingSessi
ons.get()); |
| 463 m_instrumentingSessions->add(m_session); |
463 } | 464 } |
464 | 465 |
465 void WebDevToolsAgentImpl::destroySession() | 466 void WebDevToolsAgentImpl::destroySession() |
466 { | 467 { |
467 if (m_overlay) | 468 if (m_overlay) |
468 m_overlay->clear(); | 469 m_overlay->clear(); |
469 | 470 |
470 m_tracingAgent.clear(); | 471 m_tracingAgent.clear(); |
471 m_layerTreeAgent.clear(); | 472 m_layerTreeAgent.clear(); |
472 m_resourceAgent.clear(); | 473 m_resourceAgent.clear(); |
473 m_pageAgent.clear(); | 474 m_pageAgent.clear(); |
474 m_domAgent.clear(); | 475 m_domAgent.clear(); |
475 | 476 |
476 m_session->detach(); | 477 m_session->detach(); |
| 478 m_instrumentingSessions->remove(m_session); |
477 m_v8Session.clear(); | 479 m_v8Session.clear(); |
478 m_session.clear(); | 480 m_session.clear(); |
479 | 481 |
480 Platform::current()->currentThread()->removeTaskObserver(this); | 482 Platform::current()->currentThread()->removeTaskObserver(this); |
481 InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgent
s.get()); | 483 InspectorInstrumentation::unregisterInstrumentingSessions(m_instrumentingSes
sions.get()); |
482 } | 484 } |
483 | 485 |
484 void WebDevToolsAgentImpl::attach(const WebString& hostId, int sessionId) | 486 void WebDevToolsAgentImpl::attach(const WebString& hostId, int sessionId) |
485 { | 487 { |
486 if (attached()) | 488 if (attached()) |
487 return; | 489 return; |
488 initializeSession(sessionId, hostId); | 490 initializeSession(sessionId, hostId); |
489 m_session->attach(nullptr); | 491 m_session->attach(nullptr); |
490 } | 492 } |
491 | 493 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 void WebDevToolsAgentImpl::flushPendingProtocolNotifications() | 647 void WebDevToolsAgentImpl::flushPendingProtocolNotifications() |
646 { | 648 { |
647 if (m_session) | 649 if (m_session) |
648 m_session->flushPendingProtocolNotifications(); | 650 m_session->flushPendingProtocolNotifications(); |
649 } | 651 } |
650 | 652 |
651 void WebDevToolsAgentImpl::willProcessTask() | 653 void WebDevToolsAgentImpl::willProcessTask() |
652 { | 654 { |
653 if (!attached()) | 655 if (!attached()) |
654 return; | 656 return; |
655 if (InspectorProfilerAgent* profilerAgent = m_instrumentingAgents->inspector
ProfilerAgent()) | 657 for (InspectorSession* session : *m_instrumentingSessions) { |
656 profilerAgent->willProcessTask(); | 658 if (InspectorProfilerAgent* profilerAgent = session->instrumentingAgents
()->inspectorProfilerAgent()) |
| 659 profilerAgent->willProcessTask(); |
| 660 } |
657 } | 661 } |
658 | 662 |
659 void WebDevToolsAgentImpl::didProcessTask() | 663 void WebDevToolsAgentImpl::didProcessTask() |
660 { | 664 { |
661 if (!attached()) | 665 if (!attached()) |
662 return; | 666 return; |
663 if (InspectorProfilerAgent* profilerAgent = m_instrumentingAgents->inspector
ProfilerAgent()) | 667 for (InspectorSession* session : *m_instrumentingSessions) { |
664 profilerAgent->didProcessTask(); | 668 if (InspectorProfilerAgent* profilerAgent = session->instrumentingAgents
()->inspectorProfilerAgent()) |
| 669 profilerAgent->didProcessTask(); |
| 670 } |
665 flushPendingProtocolNotifications(); | 671 flushPendingProtocolNotifications(); |
666 } | 672 } |
667 | 673 |
668 void WebDevToolsAgentImpl::runDebuggerTask(int sessionId, PassOwnPtr<WebDevTools
Agent::MessageDescriptor> descriptor) | 674 void WebDevToolsAgentImpl::runDebuggerTask(int sessionId, PassOwnPtr<WebDevTools
Agent::MessageDescriptor> descriptor) |
669 { | 675 { |
670 WebDevToolsAgent* webagent = descriptor->agent(); | 676 WebDevToolsAgent* webagent = descriptor->agent(); |
671 if (!webagent) | 677 if (!webagent) |
672 return; | 678 return; |
673 | 679 |
674 WebDevToolsAgentImpl* agentImpl = static_cast<WebDevToolsAgentImpl*>(webagen
t); | 680 WebDevToolsAgentImpl* agentImpl = static_cast<WebDevToolsAgentImpl*>(webagen
t); |
(...skipping 13 matching lines...) Expand all Loading... |
688 if (!protocol::Dispatcher::getCommandName(message, &commandName)) | 694 if (!protocol::Dispatcher::getCommandName(message, &commandName)) |
689 return false; | 695 return false; |
690 return commandName == "Debugger.pause" | 696 return commandName == "Debugger.pause" |
691 || commandName == "Debugger.setBreakpoint" | 697 || commandName == "Debugger.setBreakpoint" |
692 || commandName == "Debugger.setBreakpointByUrl" | 698 || commandName == "Debugger.setBreakpointByUrl" |
693 || commandName == "Debugger.removeBreakpoint" | 699 || commandName == "Debugger.removeBreakpoint" |
694 || commandName == "Debugger.setBreakpointsActive"; | 700 || commandName == "Debugger.setBreakpointsActive"; |
695 } | 701 } |
696 | 702 |
697 } // namespace blink | 703 } // namespace blink |
OLD | NEW |