2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
32 #include "InspectorInstrumentation.h"
37 #include "CSSStyleRule.h"
38 #include "ConsoleAPITypes.h"
39 #include "ConsoleTypes.h"
40 #include "DOMWindow.h"
41 #include "DOMWrapperWorld.h"
43 #include "DocumentLoader.h"
45 #include "EventDispatcher.h"
46 #include "InspectorApplicationCacheAgent.h"
47 #include "InspectorCSSAgent.h"
48 #include "InspectorCanvasAgent.h"
49 #include "InspectorConsoleAgent.h"
50 #include "InspectorDOMAgent.h"
51 #include "InspectorDOMDebuggerAgent.h"
52 #include "InspectorDOMStorageAgent.h"
53 #include "InspectorDatabaseAgent.h"
54 #include "InspectorHeapProfilerAgent.h"
55 #include "InspectorLayerTreeAgent.h"
56 #include "InspectorPageAgent.h"
57 #include "InspectorProfilerAgent.h"
58 #include "InspectorResourceAgent.h"
59 #include "InspectorTimelineAgent.h"
60 #include "InspectorWorkerAgent.h"
61 #include "InstrumentingAgents.h"
62 #include "MainFrame.h"
63 #include "PageDebuggerAgent.h"
64 #include "PageRuntimeAgent.h"
65 #include "RenderObject.h"
66 #include "RenderView.h"
67 #include "ScriptArguments.h"
68 #include "ScriptCallStack.h"
69 #include "ScriptController.h"
70 #include "ScriptProfile.h"
71 #include "StyleResolver.h"
72 #include "StyleRule.h"
73 #include "WorkerGlobalScope.h"
74 #include "WorkerRuntimeAgent.h"
75 #include "WorkerThread.h"
76 #include "XMLHttpRequest.h"
77 #include <inspector/agents/InspectorDebuggerAgent.h>
78 #include <wtf/StdLibExtras.h>
79 #include <wtf/text/CString.h>
81 using namespace Inspector;
85 static const char* const requestAnimationFrameEventName = "requestAnimationFrame";
86 static const char* const cancelAnimationFrameEventName = "cancelAnimationFrame";
87 static const char* const animationFrameFiredEventName = "animationFrameFired";
88 static const char* const setTimerEventName = "setTimer";
89 static const char* const clearTimerEventName = "clearTimer";
90 static const char* const timerFiredEventName = "timerFired";
93 static HashSet<InstrumentingAgents*>* instrumentingAgentsSet = nullptr;
96 int InspectorInstrumentation::s_frontendCounter = 0;
98 static Frame* frameForScriptExecutionContext(ScriptExecutionContext* context)
100 Frame* frame = nullptr;
101 if (context->isDocument())
102 frame = toDocument(context)->frame();
106 void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, DOMWrapperWorld& world)
108 InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent();
110 pageAgent->didClearWindowObjectInWorld(frame, world);
111 if (PageDebuggerAgent* debuggerAgent = instrumentingAgents->pageDebuggerAgent()) {
112 if (pageAgent && &world == &mainThreadNormalWorld() && frame == pageAgent->mainFrame())
113 debuggerAgent->didClearMainFrameWindowObject();
115 if (PageRuntimeAgent* pageRuntimeAgent = instrumentingAgents->pageRuntimeAgent()) {
116 if (&world == &mainThreadNormalWorld())
117 pageRuntimeAgent->didCreateMainWorldContext(frame);
121 bool InspectorInstrumentation::isDebuggerPausedImpl(InstrumentingAgents* instrumentingAgents)
123 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent())
124 return debuggerAgent->isPaused();
128 void InspectorInstrumentation::willInsertDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* parent)
130 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
131 domDebuggerAgent->willInsertDOMNode(parent);
134 void InspectorInstrumentation::didInsertDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node)
136 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
137 domAgent->didInsertDOMNode(node);
138 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
139 domDebuggerAgent->didInsertDOMNode(node);
142 void InspectorInstrumentation::willRemoveDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node)
144 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
145 domDebuggerAgent->willRemoveDOMNode(node);
148 void InspectorInstrumentation::didRemoveDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node)
150 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
151 domDebuggerAgent->didRemoveDOMNode(node);
152 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
153 domAgent->didRemoveDOMNode(node);
156 void InspectorInstrumentation::willModifyDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element, const AtomicString& oldValue, const AtomicString& newValue)
158 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
159 domDebuggerAgent->willModifyDOMAttr(element);
160 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
161 domAgent->willModifyDOMAttr(element, oldValue, newValue);
164 void InspectorInstrumentation::didModifyDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element, const AtomicString& name, const AtomicString& value)
166 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
167 domAgent->didModifyDOMAttr(element, name, value);
170 void InspectorInstrumentation::didRemoveDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element, const AtomicString& name)
172 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
173 domAgent->didRemoveDOMAttr(element, name);
176 void InspectorInstrumentation::didInvalidateStyleAttrImpl(InstrumentingAgents* instrumentingAgents, Node* node)
178 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
179 domAgent->didInvalidateStyleAttr(node);
180 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
181 domDebuggerAgent->didInvalidateStyleAttr(node);
184 void InspectorInstrumentation::frameWindowDiscardedImpl(InstrumentingAgents* instrumentingAgents, DOMWindow* window)
186 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
187 consoleAgent->frameWindowDiscarded(window);
190 void InspectorInstrumentation::mediaQueryResultChangedImpl(InstrumentingAgents* instrumentingAgents)
192 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
193 cssAgent->mediaQueryResultChanged();
196 void InspectorInstrumentation::didPushShadowRootImpl(InstrumentingAgents* instrumentingAgents, Element* host, ShadowRoot* root)
198 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
199 domAgent->didPushShadowRoot(host, root);
202 void InspectorInstrumentation::willPopShadowRootImpl(InstrumentingAgents* instrumentingAgents, Element* host, ShadowRoot* root)
204 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
205 domAgent->willPopShadowRoot(host, root);
208 void InspectorInstrumentation::didCreateNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow)
210 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
211 cssAgent->didCreateNamedFlow(document, namedFlow);
214 void InspectorInstrumentation::willRemoveNamedFlowImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow)
216 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
217 cssAgent->willRemoveNamedFlow(document, namedFlow);
220 void InspectorInstrumentation::didUpdateRegionLayoutImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow)
222 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
223 cssAgent->didUpdateRegionLayout(document, namedFlow);
226 void InspectorInstrumentation::didChangeRegionOversetImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow)
228 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
229 cssAgent->didChangeRegionOverset(document, namedFlow);
232 void InspectorInstrumentation::didRegisterNamedFlowContentElementImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow, Node* contentElement, Node* nextContentElement)
234 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
235 cssAgent->didRegisterNamedFlowContentElement(document, namedFlow, contentElement, nextContentElement);
238 void InspectorInstrumentation::didUnregisterNamedFlowContentElementImpl(InstrumentingAgents* instrumentingAgents, Document* document, WebKitNamedFlow* namedFlow, Node* contentElement)
240 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
241 cssAgent->didUnregisterNamedFlowContentElement(document, namedFlow, contentElement);
244 void InspectorInstrumentation::mouseDidMoveOverElementImpl(InstrumentingAgents* instrumentingAgents, const HitTestResult& result, unsigned modifierFlags)
246 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
247 domAgent->mouseDidMoveOverElement(result, modifierFlags);
250 void InspectorInstrumentation::didScrollImpl(InstrumentingAgents* instrumentingAgents)
252 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
253 pageAgent->didScroll();
256 bool InspectorInstrumentation::handleTouchEventImpl(InstrumentingAgents* instrumentingAgents, Node* node)
258 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
259 return domAgent->handleTouchEvent(node);
263 bool InspectorInstrumentation::handleMousePressImpl(InstrumentingAgents* instrumentingAgents)
265 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
266 return domAgent->handleMousePress();
270 bool InspectorInstrumentation::forcePseudoStateImpl(InstrumentingAgents* instrumentingAgents, Element* element, CSSSelector::PseudoType pseudoState)
272 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
273 return cssAgent->forcePseudoState(element, pseudoState);
277 void InspectorInstrumentation::characterDataModifiedImpl(InstrumentingAgents* instrumentingAgents, CharacterData* characterData)
279 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
280 domAgent->characterDataModified(characterData);
283 void InspectorInstrumentation::willSendXMLHttpRequestImpl(InstrumentingAgents* instrumentingAgents, const String& url)
285 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
286 domDebuggerAgent->willSendXMLHttpRequest(url);
289 void InspectorInstrumentation::didScheduleResourceRequestImpl(InstrumentingAgents* instrumentingAgents, const String& url, Frame* frame)
291 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
292 timelineAgent->didScheduleResourceRequest(url, frame);
295 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents* instrumentingAgents, int timerId, int timeout, bool singleShot, ScriptExecutionContext* context)
297 pauseOnNativeEventIfNeeded(instrumentingAgents, false, setTimerEventName, true);
298 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
299 timelineAgent->didInstallTimer(timerId, timeout, singleShot, frameForScriptExecutionContext(context));
302 void InspectorInstrumentation::didRemoveTimerImpl(InstrumentingAgents* instrumentingAgents, int timerId, ScriptExecutionContext* context)
304 pauseOnNativeEventIfNeeded(instrumentingAgents, false, clearTimerEventName, true);
305 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
306 timelineAgent->didRemoveTimer(timerId, frameForScriptExecutionContext(context));
309 InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(InstrumentingAgents* instrumentingAgents, const String& scriptName, int scriptLine, ScriptExecutionContext* context)
311 int timelineAgentId = 0;
312 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
313 timelineAgent->willCallFunction(scriptName, scriptLine, frameForScriptExecutionContext(context));
314 timelineAgentId = timelineAgent->id();
316 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
319 void InspectorInstrumentation::didCallFunctionImpl(const InspectorInstrumentationCookie& cookie)
321 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
322 timelineAgent->didCallFunction();
325 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchXHRReadyStateChangeEventImpl(InstrumentingAgents* instrumentingAgents, XMLHttpRequest* request, ScriptExecutionContext* context)
327 int timelineAgentId = 0;
328 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
329 if (timelineAgent && request->hasEventListeners(eventNames().readystatechangeEvent)) {
330 timelineAgent->willDispatchXHRReadyStateChangeEvent(request->url().string(), request->readyState(), frameForScriptExecutionContext(context));
331 timelineAgentId = timelineAgent->id();
333 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
336 void InspectorInstrumentation::didDispatchXHRReadyStateChangeEventImpl(const InspectorInstrumentationCookie& cookie)
338 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
339 timelineAgent->didDispatchXHRReadyStateChangeEvent();
342 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InstrumentingAgents* instrumentingAgents, const Event& event, bool hasEventListeners, Document* document)
344 int timelineAgentId = 0;
345 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
346 if (timelineAgent && hasEventListeners) {
347 timelineAgent->willDispatchEvent(event, document->frame());
348 timelineAgentId = timelineAgent->id();
350 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
353 InspectorInstrumentationCookie InspectorInstrumentation::willHandleEventImpl(InstrumentingAgents* instrumentingAgents, Event* event)
355 pauseOnNativeEventIfNeeded(instrumentingAgents, true, event->type(), false);
356 return InspectorInstrumentationCookie(instrumentingAgents, 0);
359 void InspectorInstrumentation::didHandleEventImpl(const InspectorInstrumentationCookie& cookie)
361 cancelPauseOnNativeEvent(cookie.instrumentingAgents());
364 void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie)
366 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
367 timelineAgent->didDispatchEvent();
370 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindowImpl(InstrumentingAgents* instrumentingAgents, const Event& event, DOMWindow* window)
372 int timelineAgentId = 0;
373 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
374 if (timelineAgent && window->hasEventListeners(event.type())) {
375 timelineAgent->willDispatchEvent(event, window ? window->frame() : nullptr);
376 timelineAgentId = timelineAgent->id();
378 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
381 void InspectorInstrumentation::didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie& cookie)
383 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
384 timelineAgent->didDispatchEvent();
387 InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScriptImpl(InstrumentingAgents* instrumentingAgents, const String& url, int lineNumber, Frame* frame)
389 int timelineAgentId = 0;
390 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
391 timelineAgent->willEvaluateScript(url, lineNumber, frame);
392 timelineAgentId = timelineAgent->id();
394 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
397 void InspectorInstrumentation::didEvaluateScriptImpl(const InspectorInstrumentationCookie& cookie)
399 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
400 timelineAgent->didEvaluateScript();
403 void InspectorInstrumentation::scriptsEnabledImpl(InstrumentingAgents* instrumentingAgents, bool isEnabled)
405 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
406 pageAgent->scriptsEnabled(isEnabled);
409 void InspectorInstrumentation::didCreateIsolatedContextImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, JSC::ExecState* scriptState, SecurityOrigin* origin)
411 if (PageRuntimeAgent* runtimeAgent = instrumentingAgents->pageRuntimeAgent())
412 runtimeAgent->didCreateIsolatedContext(frame, scriptState, origin);
415 InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(InstrumentingAgents* instrumentingAgents, int timerId, ScriptExecutionContext* context)
417 pauseOnNativeEventIfNeeded(instrumentingAgents, false, timerFiredEventName, false);
419 int timelineAgentId = 0;
420 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
421 timelineAgent->willFireTimer(timerId, frameForScriptExecutionContext(context));
422 timelineAgentId = timelineAgent->id();
424 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
427 void InspectorInstrumentation::didFireTimerImpl(const InspectorInstrumentationCookie& cookie)
429 cancelPauseOnNativeEvent(cookie.instrumentingAgents());
431 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
432 timelineAgent->didFireTimer();
435 void InspectorInstrumentation::didInvalidateLayoutImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
437 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
438 timelineAgent->didInvalidateLayout(frame);
441 InspectorInstrumentationCookie InspectorInstrumentation::willLayoutImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
443 int timelineAgentId = 0;
444 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
445 timelineAgent->willLayout(frame);
446 timelineAgentId = timelineAgent->id();
448 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
451 void InspectorInstrumentation::didLayoutImpl(const InspectorInstrumentationCookie& cookie, RenderObject* root)
453 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
454 timelineAgent->didLayout(root);
456 if (InspectorPageAgent* pageAgent = cookie.instrumentingAgents()->inspectorPageAgent())
457 pageAgent->didLayout();
460 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchXHRLoadEventImpl(InstrumentingAgents* instrumentingAgents, XMLHttpRequest* request, ScriptExecutionContext* context)
462 int timelineAgentId = 0;
463 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
464 if (timelineAgent && request->hasEventListeners(eventNames().loadEvent)) {
465 timelineAgent->willDispatchXHRLoadEvent(request->url(), frameForScriptExecutionContext(context));
466 timelineAgentId = timelineAgent->id();
468 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
471 void InspectorInstrumentation::didDispatchXHRLoadEventImpl(const InspectorInstrumentationCookie& cookie)
473 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
474 timelineAgent->didDispatchXHRLoadEvent();
477 void InspectorInstrumentation::willPaintImpl(InstrumentingAgents* instrumentingAgents, RenderObject* renderer)
479 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
480 timelineAgent->willPaint(&renderer->frame());
483 void InspectorInstrumentation::didPaintImpl(InstrumentingAgents* instrumentingAgents, RenderObject* renderer, GraphicsContext* context, const LayoutRect& rect)
485 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
486 timelineAgent->didPaint(renderer, rect);
487 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
488 pageAgent->didPaint(context, rect);
491 void InspectorInstrumentation::willScrollLayerImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
493 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
494 timelineAgent->willScroll(frame);
497 void InspectorInstrumentation::didScrollLayerImpl(InstrumentingAgents* instrumentingAgents)
499 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
500 timelineAgent->didScroll();
503 InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyleImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
505 int timelineAgentId = 0;
506 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
507 timelineAgent->willRecalculateStyle(frame);
508 timelineAgentId = timelineAgent->id();
510 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
511 resourceAgent->willRecalculateStyle();
512 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
515 void InspectorInstrumentation::didRecalculateStyleImpl(const InspectorInstrumentationCookie& cookie)
517 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
518 timelineAgent->didRecalculateStyle();
519 InstrumentingAgents* instrumentingAgents = cookie.instrumentingAgents();
520 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
521 resourceAgent->didRecalculateStyle();
522 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
523 pageAgent->didRecalculateStyle();
526 void InspectorInstrumentation::didScheduleStyleRecalculationImpl(InstrumentingAgents* instrumentingAgents, Document* document)
528 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
529 timelineAgent->didScheduleStyleRecalculation(document->frame());
530 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
531 resourceAgent->didScheduleStyleRecalculation(document);
534 void InspectorInstrumentation::applyEmulatedMediaImpl(InstrumentingAgents* instrumentingAgents, String* media)
536 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
537 pageAgent->applyEmulatedMedia(media);
540 void InspectorInstrumentation::willSendRequestImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
542 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
543 timelineAgent->willSendResourceRequest(identifier, request, loader->frame());
544 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
545 resourceAgent->willSendRequest(identifier, loader, request, redirectResponse);
548 void InspectorInstrumentation::continueAfterPingLoaderImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& response)
550 willSendRequestImpl(instrumentingAgents, identifier, loader, request, response);
553 void InspectorInstrumentation::markResourceAsCachedImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
555 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
556 resourceAgent->markResourceAsCached(identifier);
559 void InspectorInstrumentation::didLoadResourceFromMemoryCacheImpl(InstrumentingAgents* instrumentingAgents, DocumentLoader* loader, CachedResource* cachedResource)
561 if (!instrumentingAgents->inspectorEnvironment().developerExtrasEnabled())
563 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
564 resourceAgent->didLoadResourceFromMemoryCache(loader, cachedResource);
567 InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceDataImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, Frame* frame, int length)
569 int timelineAgentId = 0;
570 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
571 timelineAgent->willReceiveResourceData(identifier, frame, length);
572 timelineAgentId = timelineAgent->id();
574 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
577 void InspectorInstrumentation::didReceiveResourceDataImpl(const InspectorInstrumentationCookie& cookie)
579 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
580 timelineAgent->didReceiveResourceData();
583 InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const ResourceResponse& response, Frame* frame)
585 int timelineAgentId = 0;
586 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
588 timelineAgent->willReceiveResourceResponse(identifier, response, frame);
589 timelineAgentId = timelineAgent->id();
591 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
594 void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
596 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
597 timelineAgent->didReceiveResourceResponse();
600 InstrumentingAgents* instrumentingAgents = cookie.instrumentingAgents();
601 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
602 resourceAgent->didReceiveResponse(identifier, loader, response, resourceLoader);
603 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
604 consoleAgent->didReceiveResponse(identifier, response); // This should come AFTER resource notification, front-end relies on this.
607 void InspectorInstrumentation::didReceiveResourceResponseButCanceledImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
609 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(frame, identifier, r);
610 InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r, nullptr);
613 void InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
615 didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
618 void InspectorInstrumentation::continueWithPolicyDownloadImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
620 didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
623 void InspectorInstrumentation::continueWithPolicyIgnoreImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
625 didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
628 void InspectorInstrumentation::didReceiveDataImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
630 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
631 resourceAgent->didReceiveData(identifier, data, dataLength, encodedDataLength);
634 void InspectorInstrumentation::didFinishLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, double finishTime)
636 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
637 timelineAgent->didFinishLoadingResource(identifier, false, finishTime, loader->frame());
638 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
639 resourceAgent->didFinishLoading(identifier, loader, finishTime);
642 void InspectorInstrumentation::didFailLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, const ResourceError& error)
644 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
645 timelineAgent->didFinishLoadingResource(identifier, true, 0, loader->frame());
646 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
647 resourceAgent->didFailLoading(identifier, loader, error);
648 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
649 consoleAgent->didFailLoading(identifier, error); // This should come AFTER resource notification, front-end relies on this.
652 void InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClientImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, ThreadableLoaderClient* client)
654 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
655 resourceAgent->documentThreadableLoaderStartedLoadingForClient(identifier, client);
658 void InspectorInstrumentation::willLoadXHRImpl(InstrumentingAgents* instrumentingAgents, ThreadableLoaderClient* client, const String& method, const URL& url, bool async, PassRefPtr<FormData> formData, const HTTPHeaderMap& headers, bool includeCredentials)
660 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
661 resourceAgent->willLoadXHR(client, method, url, async, formData, headers, includeCredentials);
664 void InspectorInstrumentation::didFailXHRLoadingImpl(InstrumentingAgents* instrumentingAgents, ThreadableLoaderClient* client)
666 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
667 resourceAgent->didFailXHRLoading(client);
670 void InspectorInstrumentation::didFinishXHRLoadingImpl(InstrumentingAgents* instrumentingAgents, ThreadableLoaderClient* client, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber)
672 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
673 consoleAgent->didFinishXHRLoading(identifier, url, sendURL, sendLineNumber, sendColumnNumber);
674 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
675 resourceAgent->didFinishXHRLoading(client, identifier, sourceString);
678 void InspectorInstrumentation::didReceiveXHRResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
680 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
681 resourceAgent->didReceiveXHRResponse(identifier);
684 void InspectorInstrumentation::willLoadXHRSynchronouslyImpl(InstrumentingAgents* instrumentingAgents)
686 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
687 resourceAgent->willLoadXHRSynchronously();
690 void InspectorInstrumentation::didLoadXHRSynchronouslyImpl(InstrumentingAgents* instrumentingAgents)
692 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
693 resourceAgent->didLoadXHRSynchronously();
696 void InspectorInstrumentation::scriptImportedImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const String& sourceString)
698 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
699 resourceAgent->setInitialScriptContent(identifier, sourceString);
702 void InspectorInstrumentation::scriptExecutionBlockedByCSPImpl(InstrumentingAgents* instrumentingAgents, const String& directiveText)
704 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent())
705 debuggerAgent->scriptExecutionBlockedByCSP(directiveText);
708 void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
710 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
711 resourceAgent->didReceiveScriptResponse(identifier);
714 void InspectorInstrumentation::domContentLoadedEventFiredImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
716 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
717 timelineAgent->didMarkDOMContentEvent(frame);
719 if (&frame->page()->mainFrame() != frame)
722 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
723 domAgent->mainFrameDOMContentLoaded();
725 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
726 pageAgent->domContentEventFired();
729 void InspectorInstrumentation::loadEventFiredImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
731 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
732 timelineAgent->didMarkLoadEvent(frame);
734 if (&frame->page()->mainFrame() != frame)
737 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
738 pageAgent->loadEventFired();
741 void InspectorInstrumentation::frameDetachedFromParentImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
743 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
744 canvasAgent->frameDetached(frame);
745 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
746 pageAgent->frameDetached(frame);
749 void InspectorInstrumentation::didCommitLoadImpl(InstrumentingAgents* instrumentingAgents, Page* page, DocumentLoader* loader)
751 if (!instrumentingAgents->inspectorEnvironment().developerExtrasEnabled())
754 if (loader->frame()->isMainFrame()) {
755 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
756 consoleAgent->reset();
758 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
759 resourceAgent->mainFrameNavigated(loader);
760 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
761 profilerAgent->resetState();
762 if (InspectorHeapProfilerAgent* heapProfilerAgent = instrumentingAgents->inspectorHeapProfilerAgent())
763 heapProfilerAgent->resetState();
764 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
766 #if ENABLE(SQL_DATABASE)
767 if (InspectorDatabaseAgent* databaseAgent = instrumentingAgents->inspectorDatabaseAgent())
768 databaseAgent->clearResources();
770 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
771 domAgent->setDocument(page->mainFrame().document());
772 #if USE(ACCELERATED_COMPOSITING)
773 if (InspectorLayerTreeAgent* layerTreeAgent = instrumentingAgents->inspectorLayerTreeAgent())
774 layerTreeAgent->reset();
777 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
778 domAgent->didCommitLoad(loader->frame()->document());
779 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
780 canvasAgent->frameNavigated(loader->frame());
781 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
782 pageAgent->frameNavigated(loader);
785 void InspectorInstrumentation::frameDocumentUpdatedImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
787 if (!instrumentingAgents->inspectorEnvironment().developerExtrasEnabled())
789 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
790 domAgent->frameDocumentUpdated(frame);
793 void InspectorInstrumentation::loaderDetachedFromFrameImpl(InstrumentingAgents* instrumentingAgents, DocumentLoader* loader)
795 if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
796 inspectorPageAgent->loaderDetachedFromFrame(loader);
799 void InspectorInstrumentation::frameStartedLoadingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
801 if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())
802 inspectorPageAgent->frameStartedLoading(frame);
805 void InspectorInstrumentation::frameStoppedLoadingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
807 if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())
808 inspectorPageAgent->frameStoppedLoading(frame);
811 void InspectorInstrumentation::frameScheduledNavigationImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, double delay)
813 if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())
814 inspectorPageAgent->frameScheduledNavigation(frame, delay);
817 void InspectorInstrumentation::frameClearedScheduledNavigationImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
819 if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents.inspectorPageAgent())
820 inspectorPageAgent->frameClearedScheduledNavigation(frame);
823 InspectorInstrumentationCookie InspectorInstrumentation::willRunJavaScriptDialogImpl(InstrumentingAgents* instrumentingAgents, const String& message)
825 if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
826 inspectorPageAgent->willRunJavaScriptDialog(message);
827 return InspectorInstrumentationCookie(instrumentingAgents, 0);
830 void InspectorInstrumentation::didRunJavaScriptDialogImpl(const InspectorInstrumentationCookie& cookie)
832 if (InspectorPageAgent* inspectorPageAgent = cookie.instrumentingAgents()->inspectorPageAgent())
833 inspectorPageAgent->didRunJavaScriptDialog();
836 void InspectorInstrumentation::willDestroyCachedResourceImpl(CachedResource* cachedResource)
838 if (!instrumentingAgentsSet)
840 HashSet<InstrumentingAgents*>::iterator end = instrumentingAgentsSet->end();
841 for (HashSet<InstrumentingAgents*>::iterator it = instrumentingAgentsSet->begin(); it != end; ++it) {
842 InstrumentingAgents* instrumentingAgents = *it;
843 if (InspectorResourceAgent* inspectorResourceAgent = instrumentingAgents->inspectorResourceAgent())
844 inspectorResourceAgent->willDestroyCachedResource(cachedResource);
848 InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTMLImpl(InstrumentingAgents* instrumentingAgents, unsigned startLine, Frame* frame)
850 int timelineAgentId = 0;
851 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
852 timelineAgent->willWriteHTML(startLine, frame);
853 timelineAgentId = timelineAgent->id();
855 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
858 void InspectorInstrumentation::didWriteHTMLImpl(const InspectorInstrumentationCookie& cookie, unsigned endLine)
860 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
861 timelineAgent->didWriteHTML(endLine);
864 // JavaScriptCore InspectorDebuggerAgent should know Console MessageTypes.
865 static bool isConsoleAssertMessage(MessageSource source, MessageType type)
867 return source == ConsoleAPIMessageSource && type == AssertMessageType;
870 // FIXME: Drop this once we no longer generate stacks outside of Inspector.
871 void InspectorInstrumentation::addMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier)
873 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
874 consoleAgent->addMessageToConsole(source, type, level, message, callStack, requestIdentifier);
875 // FIXME: This should just pass the message on to the debugger agent. JavaScriptCore InspectorDebuggerAgent should know Console MessageTypes.
876 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent()) {
877 if (isConsoleAssertMessage(source, type))
878 debuggerAgent->handleConsoleAssert();
882 void InspectorInstrumentation::addMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, MessageSource source, MessageType type, MessageLevel level, const String& message, JSC::ExecState* state, PassRefPtr<ScriptArguments> arguments, unsigned long requestIdentifier)
884 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
885 consoleAgent->addMessageToConsole(source, type, level, message, state, arguments, requestIdentifier);
886 // FIXME: This should just pass the message on to the debugger agent. JavaScriptCore InspectorDebuggerAgent should know Console MessageTypes.
887 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent()) {
888 if (isConsoleAssertMessage(source, type))
889 debuggerAgent->handleConsoleAssert();
893 void InspectorInstrumentation::addMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptID, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* state, unsigned long requestIdentifier)
895 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
896 consoleAgent->addMessageToConsole(source, type, level, message, scriptID, lineNumber, columnNumber, state, requestIdentifier);
899 void InspectorInstrumentation::consoleCountImpl(InstrumentingAgents* instrumentingAgents, JSC::ExecState* state, PassRefPtr<ScriptArguments> arguments)
901 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
902 consoleAgent->count(state, arguments);
905 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, const String& title)
907 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
908 timelineAgent->time(frame, title);
909 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
910 consoleAgent->startTiming(title);
913 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, const String& title, PassRefPtr<ScriptCallStack> stack)
915 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
916 consoleAgent->stopTiming(title, stack);
917 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
918 timelineAgent->timeEnd(frame, title);
921 void InspectorInstrumentation::consoleTimeStampImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, PassRefPtr<ScriptArguments> arguments)
923 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
925 arguments->getFirstArgumentAsString(message);
926 timelineAgent->didTimeStamp(frame, message);
930 void InspectorInstrumentation::addStartProfilingMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, const String& title, unsigned lineNumber, unsigned columnNumber, const String& sourceURL)
932 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
933 profilerAgent->addStartProfilingMessageToConsole(title, lineNumber, columnNumber, sourceURL);
936 void InspectorInstrumentation::addProfileImpl(InstrumentingAgents* instrumentingAgents, RefPtr<ScriptProfile> profile, PassRefPtr<ScriptCallStack> callStack)
938 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent()) {
939 const ScriptCallFrame& lastCaller = callStack->at(0);
940 profilerAgent->addProfile(profile, lastCaller.lineNumber(), lastCaller.columnNumber(), lastCaller.sourceURL());
944 String InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl(InstrumentingAgents* instrumentingAgents, bool incrementProfileNumber)
946 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
947 return profilerAgent->getCurrentUserInitiatedProfileName(incrementProfileNumber);
951 bool InspectorInstrumentation::profilerEnabledImpl(InstrumentingAgents* instrumentingAgents)
953 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
954 return profilerAgent->enabled();
958 #if ENABLE(SQL_DATABASE)
959 void InspectorInstrumentation::didOpenDatabaseImpl(InstrumentingAgents* instrumentingAgents, PassRefPtr<Database> database, const String& domain, const String& name, const String& version)
961 if (!instrumentingAgents->inspectorEnvironment().developerExtrasEnabled())
963 if (InspectorDatabaseAgent* dbAgent = instrumentingAgents->inspectorDatabaseAgent())
964 dbAgent->didOpenDatabase(database, domain, name, version);
968 void InspectorInstrumentation::didDispatchDOMStorageEventImpl(InstrumentingAgents* instrumentingAgents, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin, Page* page)
970 if (InspectorDOMStorageAgent* domStorageAgent = instrumentingAgents->inspectorDOMStorageAgent())
971 domStorageAgent->didDispatchDOMStorageEvent(key, oldValue, newValue, storageType, securityOrigin, page);
974 bool InspectorInstrumentation::shouldPauseDedicatedWorkerOnStartImpl(InstrumentingAgents* instrumentingAgents)
976 if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent())
977 return workerAgent->shouldPauseDedicatedWorkerOnStart();
981 void InspectorInstrumentation::didStartWorkerGlobalScopeImpl(InstrumentingAgents* instrumentingAgents, WorkerGlobalScopeProxy* workerGlobalScopeProxy, const URL& url)
983 if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent())
984 workerAgent->didStartWorkerGlobalScope(workerGlobalScopeProxy, url);
987 void InspectorInstrumentation::willEvaluateWorkerScript(WorkerGlobalScope* workerGlobalScope, int workerThreadStartMode)
989 if (workerThreadStartMode != PauseWorkerGlobalScopeOnStart)
991 InstrumentingAgents* instrumentingAgents = instrumentationForWorkerGlobalScope(workerGlobalScope);
992 if (!instrumentingAgents)
994 if (WorkerRuntimeAgent* runtimeAgent = instrumentingAgents->workerRuntimeAgent())
995 runtimeAgent->pauseWorkerGlobalScope(workerGlobalScope);
998 void InspectorInstrumentation::workerGlobalScopeTerminatedImpl(InstrumentingAgents* instrumentingAgents, WorkerGlobalScopeProxy* proxy)
1000 if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent())
1001 workerAgent->workerGlobalScopeTerminated(proxy);
1004 #if ENABLE(WEB_SOCKETS)
1005 void InspectorInstrumentation::didCreateWebSocketImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const URL& requestURL, const URL&, const String& protocol, Document* document)
1007 if (!instrumentingAgents->inspectorEnvironment().developerExtrasEnabled())
1009 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1010 resourceAgent->didCreateWebSocket(identifier, requestURL);
1011 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
1012 timelineAgent->didCreateWebSocket(identifier, requestURL, protocol, document->frame());
1015 void InspectorInstrumentation::willSendWebSocketHandshakeRequestImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const ResourceRequest& request, Document* document)
1017 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1018 resourceAgent->willSendWebSocketHandshakeRequest(identifier, request);
1019 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
1020 timelineAgent->willSendWebSocketHandshakeRequest(identifier, document->frame());
1023 void InspectorInstrumentation::didReceiveWebSocketHandshakeResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const ResourceResponse& response, Document* document)
1025 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1026 resourceAgent->didReceiveWebSocketHandshakeResponse(identifier, response);
1027 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
1028 timelineAgent->didReceiveWebSocketHandshakeResponse(identifier, document->frame());
1031 void InspectorInstrumentation::didCloseWebSocketImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, Document* document)
1033 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1034 resourceAgent->didCloseWebSocket(identifier);
1035 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
1036 timelineAgent->didDestroyWebSocket(identifier, document->frame());
1039 void InspectorInstrumentation::didReceiveWebSocketFrameImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const WebSocketFrame& frame)
1041 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1042 resourceAgent->didReceiveWebSocketFrame(identifier, frame);
1044 void InspectorInstrumentation::didReceiveWebSocketFrameErrorImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const String& errorMessage)
1046 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1047 resourceAgent->didReceiveWebSocketFrameError(identifier, errorMessage);
1049 void InspectorInstrumentation::didSendWebSocketFrameImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const WebSocketFrame& frame)
1051 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1052 resourceAgent->didSendWebSocketFrame(identifier, frame);
1056 void InspectorInstrumentation::networkStateChangedImpl(InstrumentingAgents* instrumentingAgents)
1058 if (InspectorApplicationCacheAgent* applicationCacheAgent = instrumentingAgents->inspectorApplicationCacheAgent())
1059 applicationCacheAgent->networkStateChanged();
1062 void InspectorInstrumentation::updateApplicationCacheStatusImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
1064 if (InspectorApplicationCacheAgent* applicationCacheAgent = instrumentingAgents->inspectorApplicationCacheAgent())
1065 applicationCacheAgent->updateApplicationCacheStatus(frame);
1068 bool InspectorInstrumentation::canvasAgentEnabled(ScriptExecutionContext* scriptExecutionContext)
1070 InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(scriptExecutionContext);
1071 return instrumentingAgents && instrumentingAgents->inspectorCanvasAgent();
1074 bool InspectorInstrumentation::consoleAgentEnabled(ScriptExecutionContext* scriptExecutionContext)
1076 InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(scriptExecutionContext);
1077 InspectorConsoleAgent* consoleAgent = instrumentingAgents ? instrumentingAgents->inspectorConsoleAgent() : nullptr;
1078 return consoleAgent && consoleAgent->enabled();
1081 bool InspectorInstrumentation::timelineAgentEnabled(ScriptExecutionContext* scriptExecutionContext)
1083 InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(scriptExecutionContext);
1084 return instrumentingAgents && instrumentingAgents->inspectorTimelineAgent();
1087 void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InstrumentingAgents* instrumentingAgents, bool isDOMEvent, const String& eventName, bool synchronous)
1089 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
1090 domDebuggerAgent->pauseOnNativeEventIfNeeded(isDOMEvent, eventName, synchronous);
1093 void InspectorInstrumentation::cancelPauseOnNativeEvent(InstrumentingAgents* instrumentingAgents)
1095 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent())
1096 debuggerAgent->cancelPauseOnNextStatement();
1099 void InspectorInstrumentation::didRequestAnimationFrameImpl(InstrumentingAgents* instrumentingAgents, int callbackId, Frame* frame)
1101 pauseOnNativeEventIfNeeded(instrumentingAgents, false, requestAnimationFrameEventName, true);
1103 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
1104 timelineAgent->didRequestAnimationFrame(callbackId, frame);
1107 void InspectorInstrumentation::didCancelAnimationFrameImpl(InstrumentingAgents* instrumentingAgents, int callbackId, Frame* frame)
1109 pauseOnNativeEventIfNeeded(instrumentingAgents, false, cancelAnimationFrameEventName, true);
1111 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
1112 timelineAgent->didCancelAnimationFrame(callbackId, frame);
1115 InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrameImpl(InstrumentingAgents* instrumentingAgents, int callbackId, Frame* frame)
1117 pauseOnNativeEventIfNeeded(instrumentingAgents, false, animationFrameFiredEventName, false);
1119 int timelineAgentId = 0;
1120 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
1121 timelineAgent->willFireAnimationFrame(callbackId, frame);
1122 timelineAgentId = timelineAgent->id();
1124 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
1127 void InspectorInstrumentation::didFireAnimationFrameImpl(const InspectorInstrumentationCookie& cookie)
1129 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
1130 timelineAgent->didFireAnimationFrame();
1133 void InspectorInstrumentation::registerInstrumentingAgents(InstrumentingAgents* instrumentingAgents)
1135 if (!instrumentingAgentsSet)
1136 instrumentingAgentsSet = new HashSet<InstrumentingAgents*>();
1137 instrumentingAgentsSet->add(instrumentingAgents);
1140 void InspectorInstrumentation::unregisterInstrumentingAgents(InstrumentingAgents* instrumentingAgents)
1142 if (!instrumentingAgentsSet)
1144 instrumentingAgentsSet->remove(instrumentingAgents);
1145 if (instrumentingAgentsSet->isEmpty()) {
1146 delete instrumentingAgentsSet;
1147 instrumentingAgentsSet = nullptr;
1151 InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(const InspectorInstrumentationCookie& cookie)
1153 if (!cookie.instrumentingAgents())
1155 InspectorTimelineAgent* timelineAgent = cookie.instrumentingAgents()->inspectorTimelineAgent();
1156 if (timelineAgent && cookie.hasMatchingTimelineAgentId(timelineAgent->id()))
1157 return timelineAgent;
1161 InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForPage(Page* page)
1165 return instrumentationForPage(page);
1168 InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForRenderer(RenderObject* renderer)
1170 return instrumentingAgentsForFrame(&renderer->frame());
1173 InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope* workerGlobalScope)
1175 if (!workerGlobalScope)
1177 return instrumentationForWorkerGlobalScope(workerGlobalScope);
1180 InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForNonDocumentContext(ScriptExecutionContext* context)
1182 if (context->isWorkerGlobalScope())
1183 return instrumentationForWorkerGlobalScope(static_cast<WorkerGlobalScope*>(context));
1187 #if USE(ACCELERATED_COMPOSITING)
1188 void InspectorInstrumentation::layerTreeDidChangeImpl(InstrumentingAgents* instrumentingAgents)
1190 if (InspectorLayerTreeAgent* layerTreeAgent = instrumentingAgents->inspectorLayerTreeAgent())
1191 layerTreeAgent->layerTreeDidChange();
1194 void InspectorInstrumentation::renderLayerDestroyedImpl(InstrumentingAgents* instrumentingAgents, const RenderLayer* renderLayer)
1196 if (InspectorLayerTreeAgent* layerTreeAgent = instrumentingAgents->inspectorLayerTreeAgent())
1197 layerTreeAgent->renderLayerDestroyed(renderLayer);
1200 void InspectorInstrumentation::pseudoElementDestroyedImpl(InstrumentingAgents* instrumentingAgents, PseudoElement* pseudoElement)
1202 if (InspectorLayerTreeAgent* layerTreeAgent = instrumentingAgents->inspectorLayerTreeAgent())
1203 layerTreeAgent->pseudoElementDestroyed(pseudoElement);
1207 } // namespace WebCore
1209 #endif // !ENABLE(INSPECTOR)