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.
35 #include "InspectorInstrumentation.h"
38 #include "CSSStyleRule.h"
39 #include "DOMWindow.h"
41 #include "DocumentLoader.h"
43 #include "EventContext.h"
44 #include "InspectorAgent.h"
45 #include "InspectorApplicationCacheAgent.h"
46 #include "InspectorDOMDebuggerAgent.h"
47 #include "InspectorCSSAgent.h"
48 #include "InspectorConsoleAgent.h"
49 #include "InspectorController.h"
50 #include "WorkerInspectorController.h"
51 #include "InspectorDatabaseAgent.h"
52 #include "InspectorDOMAgent.h"
53 #include "InspectorDOMStorageAgent.h"
54 #include "InspectorDebuggerAgent.h"
55 #include "InspectorPageAgent.h"
56 #include "InspectorProfilerAgent.h"
57 #include "InspectorResourceAgent.h"
58 #include "InspectorRuntimeAgent.h"
59 #include "InspectorTimelineAgent.h"
60 #include "InspectorWorkerAgent.h"
61 #include "InstrumentingAgents.h"
62 #include "PageRuntimeAgent.h"
63 #include "ScriptArguments.h"
64 #include "ScriptCallStack.h"
65 #include "ScriptProfile.h"
66 #include "StyleRule.h"
67 #include "WorkerContext.h"
68 #include "WorkerThread.h"
69 #include "XMLHttpRequest.h"
70 #include <wtf/StdLibExtras.h>
71 #include <wtf/ThreadSpecific.h>
72 #include <wtf/text/CString.h>
76 static const char* const requestAnimationFrameEventName = "requestAnimationFrame";
77 static const char* const cancelAnimationFrameEventName = "cancelAnimationFrame";
78 static const char* const animationFrameFiredEventName = "animationFrameFired";
79 static const char* const setTimerEventName = "setTimer";
80 static const char* const clearTimerEventName = "clearTimer";
81 static const char* const timerFiredEventName = "timerFired";
83 int InspectorInstrumentation::s_frontendCounter = 0;
85 static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors)
87 if (window && window->hasEventListeners(eventType))
90 if (node->hasEventListeners(eventType))
93 for (size_t i = 0; i < ancestors.size(); i++) {
94 Node* ancestor = ancestors[i].node();
95 if (ancestor->hasEventListeners(eventType))
102 static Frame* frameForScriptExecutionContext(ScriptExecutionContext* context)
105 if (context->isDocument())
106 frame = static_cast<Document*>(context)->frame();
110 void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, DOMWrapperWorld* world)
112 InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent();
114 pageAgent->didClearWindowObjectInWorld(frame, world);
115 if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
116 inspectorAgent->didClearWindowObjectInWorld(frame, world);
117 #if ENABLE(JAVASCRIPT_DEBUGGER)
118 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent()) {
119 if (pageAgent && world == mainThreadNormalWorld() && frame == pageAgent->mainFrame())
120 debuggerAgent->didClearMainFrameWindowObject();
123 if (PageRuntimeAgent* pageRuntimeAgent = instrumentingAgents->pageRuntimeAgent()) {
124 if (world == mainThreadNormalWorld())
125 pageRuntimeAgent->didClearWindowObject(frame);
129 bool InspectorInstrumentation::isDebuggerPausedImpl(InstrumentingAgents* instrumentingAgents)
131 #if ENABLE(JAVASCRIPT_DEBUGGER)
132 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent())
133 return debuggerAgent->isPaused();
138 void InspectorInstrumentation::willInsertDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* parent)
140 #if ENABLE(JAVASCRIPT_DEBUGGER)
141 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
142 domDebuggerAgent->willInsertDOMNode(parent);
146 void InspectorInstrumentation::didInsertDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node)
148 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
149 domAgent->didInsertDOMNode(node);
150 #if ENABLE(JAVASCRIPT_DEBUGGER)
151 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
152 domDebuggerAgent->didInsertDOMNode(node);
156 void InspectorInstrumentation::willRemoveDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node)
158 #if ENABLE(JAVASCRIPT_DEBUGGER)
159 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
160 domDebuggerAgent->willRemoveDOMNode(node);
164 void InspectorInstrumentation::didRemoveDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node)
166 #if ENABLE(JAVASCRIPT_DEBUGGER)
167 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
168 domDebuggerAgent->didRemoveDOMNode(node);
170 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
171 domAgent->didRemoveDOMNode(node);
174 void InspectorInstrumentation::willModifyDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element, const AtomicString& oldValue, const AtomicString& newValue)
176 #if ENABLE(JAVASCRIPT_DEBUGGER)
177 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
178 domDebuggerAgent->willModifyDOMAttr(element);
179 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
180 domAgent->willModifyDOMAttr(element, oldValue, newValue);
184 void InspectorInstrumentation::didModifyDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element, const AtomicString& name, const AtomicString& value)
186 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
187 domAgent->didModifyDOMAttr(element, name, value);
190 void InspectorInstrumentation::didRemoveDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element, const AtomicString& name)
192 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
193 domAgent->didRemoveDOMAttr(element, name);
196 void InspectorInstrumentation::didInvalidateStyleAttrImpl(InstrumentingAgents* instrumentingAgents, Node* node)
198 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
199 domAgent->didInvalidateStyleAttr(node);
200 #if ENABLE(JAVASCRIPT_DEBUGGER)
201 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
202 domDebuggerAgent->didInvalidateStyleAttr(node);
206 void InspectorInstrumentation::frameWindowDiscardedImpl(InstrumentingAgents* instrumentingAgents, DOMWindow* window)
208 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
209 consoleAgent->frameWindowDiscarded(window);
212 void InspectorInstrumentation::mediaQueryResultChangedImpl(InstrumentingAgents* instrumentingAgents)
214 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
215 cssAgent->mediaQueryResultChanged();
218 void InspectorInstrumentation::didPushShadowRootImpl(InstrumentingAgents* instrumentingAgents, Element* host, ShadowRoot* root)
220 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
221 domAgent->didPushShadowRoot(host, root);
224 void InspectorInstrumentation::willPopShadowRootImpl(InstrumentingAgents* instrumentingAgents, Element* host, ShadowRoot* root)
226 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
227 domAgent->willPopShadowRoot(host, root);
230 void InspectorInstrumentation::mouseDidMoveOverElementImpl(InstrumentingAgents* instrumentingAgents, const HitTestResult& result, unsigned modifierFlags)
232 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
233 domAgent->mouseDidMoveOverElement(result, modifierFlags);
236 bool InspectorInstrumentation::handleMousePressImpl(InstrumentingAgents* instrumentingAgents)
238 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
239 return domAgent->handleMousePress();
243 bool InspectorInstrumentation::forcePseudoStateImpl(InstrumentingAgents* instrumentingAgents, Element* element, CSSSelector::PseudoType pseudoState)
245 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
246 return cssAgent->forcePseudoState(element, pseudoState);
250 void InspectorInstrumentation::characterDataModifiedImpl(InstrumentingAgents* instrumentingAgents, CharacterData* characterData)
252 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
253 domAgent->characterDataModified(characterData);
256 void InspectorInstrumentation::willSendXMLHttpRequestImpl(InstrumentingAgents* instrumentingAgents, const String& url)
258 #if ENABLE(JAVASCRIPT_DEBUGGER)
259 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
260 domDebuggerAgent->willSendXMLHttpRequest(url);
264 void InspectorInstrumentation::didScheduleResourceRequestImpl(InstrumentingAgents* instrumentingAgents, const String& url, Frame* frame)
266 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
267 timelineAgent->didScheduleResourceRequest(url, frame);
270 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents* instrumentingAgents, int timerId, int timeout, bool singleShot, ScriptExecutionContext* context)
272 pauseOnNativeEventIfNeeded(instrumentingAgents, false, setTimerEventName, true);
273 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
274 timelineAgent->didInstallTimer(timerId, timeout, singleShot, frameForScriptExecutionContext(context));
277 void InspectorInstrumentation::didRemoveTimerImpl(InstrumentingAgents* instrumentingAgents, int timerId, ScriptExecutionContext* context)
279 pauseOnNativeEventIfNeeded(instrumentingAgents, false, clearTimerEventName, true);
280 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
281 timelineAgent->didRemoveTimer(timerId, frameForScriptExecutionContext(context));
284 InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(InstrumentingAgents* instrumentingAgents, const String& scriptName, int scriptLine, ScriptExecutionContext* context)
286 int timelineAgentId = 0;
287 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
288 timelineAgent->willCallFunction(scriptName, scriptLine, frameForScriptExecutionContext(context));
289 timelineAgentId = timelineAgent->id();
291 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
294 void InspectorInstrumentation::didCallFunctionImpl(const InspectorInstrumentationCookie& cookie)
296 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
297 timelineAgent->didCallFunction();
300 InspectorInstrumentationCookie InspectorInstrumentation::willChangeXHRReadyStateImpl(InstrumentingAgents* instrumentingAgents, XMLHttpRequest* request, ScriptExecutionContext* context)
302 int timelineAgentId = 0;
303 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
304 if (timelineAgent && request->hasEventListeners(eventNames().readystatechangeEvent)) {
305 timelineAgent->willChangeXHRReadyState(request->url().string(), request->readyState(), frameForScriptExecutionContext(context));
306 timelineAgentId = timelineAgent->id();
308 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
311 void InspectorInstrumentation::didChangeXHRReadyStateImpl(const InspectorInstrumentationCookie& cookie)
313 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
314 timelineAgent->didChangeXHRReadyState();
317 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InstrumentingAgents* instrumentingAgents, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors, Document* document)
319 int timelineAgentId = 0;
320 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
321 if (timelineAgent && eventHasListeners(event.type(), window, node, ancestors)) {
322 timelineAgent->willDispatchEvent(event, document->frame());
323 timelineAgentId = timelineAgent->id();
325 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
328 InspectorInstrumentationCookie InspectorInstrumentation::willHandleEventImpl(InstrumentingAgents* instrumentingAgents, Event* event)
330 pauseOnNativeEventIfNeeded(instrumentingAgents, true, event->type(), false);
331 return InspectorInstrumentationCookie(instrumentingAgents, 0);
334 void InspectorInstrumentation::didHandleEventImpl(const InspectorInstrumentationCookie& cookie)
336 cancelPauseOnNativeEvent(cookie.first);
339 void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie)
341 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
342 timelineAgent->didDispatchEvent();
345 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindowImpl(InstrumentingAgents* instrumentingAgents, const Event& event, DOMWindow* window)
347 int timelineAgentId = 0;
348 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
349 if (timelineAgent && window->hasEventListeners(event.type())) {
350 timelineAgent->willDispatchEvent(event, window ? window->frame() : 0);
351 timelineAgentId = timelineAgent->id();
353 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
356 void InspectorInstrumentation::didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie& cookie)
358 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
359 timelineAgent->didDispatchEvent();
362 InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScriptImpl(InstrumentingAgents* instrumentingAgents, const String& url, int lineNumber, Frame* frame)
364 int timelineAgentId = 0;
365 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
366 timelineAgent->willEvaluateScript(url, lineNumber, frame);
367 timelineAgentId = timelineAgent->id();
369 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
372 void InspectorInstrumentation::didEvaluateScriptImpl(const InspectorInstrumentationCookie& cookie)
374 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
375 timelineAgent->didEvaluateScript();
378 void InspectorInstrumentation::didCreateIsolatedContextImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, ScriptState* scriptState, SecurityOrigin* origin)
380 if (PageRuntimeAgent* runtimeAgent = instrumentingAgents->pageRuntimeAgent())
381 runtimeAgent->didCreateIsolatedContext(frame, scriptState, origin);
384 InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(InstrumentingAgents* instrumentingAgents, int timerId, ScriptExecutionContext* context)
386 pauseOnNativeEventIfNeeded(instrumentingAgents, false, timerFiredEventName, false);
388 int timelineAgentId = 0;
389 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
390 timelineAgent->willFireTimer(timerId, frameForScriptExecutionContext(context));
391 timelineAgentId = timelineAgent->id();
393 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
396 void InspectorInstrumentation::didFireTimerImpl(const InspectorInstrumentationCookie& cookie)
398 cancelPauseOnNativeEvent(cookie.first);
400 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
401 timelineAgent->didFireTimer();
404 void InspectorInstrumentation::didBeginFrameImpl(InstrumentingAgents* instrumentingAgents)
406 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
407 timelineAgent->didBeginFrame();
410 void InspectorInstrumentation::didCancelFrameImpl(InstrumentingAgents* instrumentingAgents)
412 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
413 timelineAgent->didCancelFrame();
416 InspectorInstrumentationCookie InspectorInstrumentation::willLayoutImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
418 int timelineAgentId = 0;
419 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
420 timelineAgent->willLayout(frame);
421 timelineAgentId = timelineAgent->id();
423 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
426 void InspectorInstrumentation::didLayoutImpl(const InspectorInstrumentationCookie& cookie)
431 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
432 timelineAgent->didLayout();
434 if (InspectorPageAgent* pageAgent = cookie.first->inspectorPageAgent())
435 pageAgent->didLayout();
438 InspectorInstrumentationCookie InspectorInstrumentation::willLoadXHRImpl(InstrumentingAgents* instrumentingAgents, XMLHttpRequest* request, ScriptExecutionContext* context)
440 int timelineAgentId = 0;
441 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
442 if (timelineAgent && request->hasEventListeners(eventNames().loadEvent)) {
443 timelineAgent->willLoadXHR(request->url(), frameForScriptExecutionContext(context));
444 timelineAgentId = timelineAgent->id();
446 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
449 void InspectorInstrumentation::didLoadXHRImpl(const InspectorInstrumentationCookie& cookie)
451 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
452 timelineAgent->didLoadXHR();
455 InspectorInstrumentationCookie InspectorInstrumentation::willPaintImpl(InstrumentingAgents* instrumentingAgents, GraphicsContext* context, const LayoutRect& rect, Frame* frame)
457 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
458 pageAgent->willPaint(context, rect);
460 int timelineAgentId = 0;
461 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
462 timelineAgent->willPaint(rect, frame);
463 timelineAgentId = timelineAgent->id();
465 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
468 void InspectorInstrumentation::didPaintImpl(const InspectorInstrumentationCookie& cookie)
470 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
471 timelineAgent->didPaint();
472 if (InspectorPageAgent* pageAgent = cookie.first ? cookie.first->inspectorPageAgent() : 0)
473 pageAgent->didPaint();
476 void InspectorInstrumentation::willCompositeImpl(InstrumentingAgents* instrumentingAgents)
478 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
479 timelineAgent->willComposite();
482 void InspectorInstrumentation::didCompositeImpl(InstrumentingAgents* instrumentingAgents)
484 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
485 timelineAgent->didComposite();
488 InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyleImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
490 int timelineAgentId = 0;
491 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
492 timelineAgent->willRecalculateStyle(frame);
493 timelineAgentId = timelineAgent->id();
495 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
496 resourceAgent->willRecalculateStyle();
497 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
500 void InspectorInstrumentation::didRecalculateStyleImpl(const InspectorInstrumentationCookie& cookie)
502 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
503 timelineAgent->didRecalculateStyle();
504 InstrumentingAgents* instrumentingAgents = cookie.first;
505 if (!instrumentingAgents)
507 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
508 resourceAgent->didRecalculateStyle();
511 void InspectorInstrumentation::didScheduleStyleRecalculationImpl(InstrumentingAgents* instrumentingAgents, Document* document)
513 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
514 resourceAgent->didScheduleStyleRecalculation(document);
517 InspectorInstrumentationCookie InspectorInstrumentation::willMatchRuleImpl(InstrumentingAgents* instrumentingAgents, const StyleRule* rule)
519 InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent();
521 RefPtr<CSSRule> cssRule = rule->createCSSOMWrapper();
522 cssAgent->willMatchRule(static_cast<CSSStyleRule*>(cssRule.get()));
523 return InspectorInstrumentationCookie(instrumentingAgents, 1);
526 return InspectorInstrumentationCookie();
529 void InspectorInstrumentation::didMatchRuleImpl(const InspectorInstrumentationCookie& cookie, bool matched)
531 InspectorCSSAgent* cssAgent = cookie.first->inspectorCSSAgent();
533 cssAgent->didMatchRule(matched);
536 InspectorInstrumentationCookie InspectorInstrumentation::willProcessRuleImpl(InstrumentingAgents* instrumentingAgents, const StyleRule* rule)
538 InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent();
540 RefPtr<CSSRule> cssRule = rule->createCSSOMWrapper();
541 cssAgent->willProcessRule(static_cast<CSSStyleRule*>(cssRule.get()));
542 return InspectorInstrumentationCookie(instrumentingAgents, 1);
545 return InspectorInstrumentationCookie();
548 void InspectorInstrumentation::didProcessRuleImpl(const InspectorInstrumentationCookie& cookie)
550 InspectorCSSAgent* cssAgent = cookie.first->inspectorCSSAgent();
552 cssAgent->didProcessRule();
555 void InspectorInstrumentation::willProcessTaskImpl(InstrumentingAgents* instrumentingAgents)
557 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
558 timelineAgent->willProcessTask();
561 void InspectorInstrumentation::didProcessTaskImpl(InstrumentingAgents* instrumentingAgents)
563 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
564 timelineAgent->didProcessTask();
567 void InspectorInstrumentation::applyUserAgentOverrideImpl(InstrumentingAgents* instrumentingAgents, String* userAgent)
569 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
570 resourceAgent->applyUserAgentOverride(userAgent);
573 void InspectorInstrumentation::applyScreenWidthOverrideImpl(InstrumentingAgents* instrumentingAgents, long* width)
575 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
576 pageAgent->applyScreenWidthOverride(width);
579 void InspectorInstrumentation::applyScreenHeightOverrideImpl(InstrumentingAgents* instrumentingAgents, long* height)
581 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
582 pageAgent->applyScreenHeightOverride(height);
585 bool InspectorInstrumentation::shouldApplyScreenWidthOverrideImpl(InstrumentingAgents* instrumentingAgents)
587 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent()) {
589 pageAgent->applyScreenWidthOverride(&width);
595 bool InspectorInstrumentation::shouldApplyScreenHeightOverrideImpl(InstrumentingAgents* instrumentingAgents)
597 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent()) {
599 pageAgent->applyScreenHeightOverride(&height);
605 void InspectorInstrumentation::willSendRequestImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
607 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
608 timelineAgent->willSendResourceRequest(identifier, request, loader->frame());
609 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
610 resourceAgent->willSendRequest(identifier, loader, request, redirectResponse);
613 void InspectorInstrumentation::continueAfterPingLoaderImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& response)
615 willSendRequestImpl(instrumentingAgents, identifier, loader, request, response);
618 void InspectorInstrumentation::markResourceAsCachedImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
620 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
621 resourceAgent->markResourceAsCached(identifier);
624 void InspectorInstrumentation::didLoadResourceFromMemoryCacheImpl(InstrumentingAgents* instrumentingAgents, DocumentLoader* loader, CachedResource* cachedResource)
626 InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
627 if (!inspectorAgent || !inspectorAgent->developerExtrasEnabled())
629 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
630 resourceAgent->didLoadResourceFromMemoryCache(loader, cachedResource);
633 InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceDataImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, Frame* frame, int length)
635 int timelineAgentId = 0;
636 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
637 timelineAgent->willReceiveResourceData(identifier, frame, length);
638 timelineAgentId = timelineAgent->id();
640 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
643 void InspectorInstrumentation::didReceiveResourceDataImpl(const InspectorInstrumentationCookie& cookie)
645 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
646 timelineAgent->didReceiveResourceData();
649 InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const ResourceResponse& response, Frame* frame)
651 int timelineAgentId = 0;
652 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
654 timelineAgent->willReceiveResourceResponse(identifier, response, frame);
655 timelineAgentId = timelineAgent->id();
657 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
660 void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
662 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
663 timelineAgent->didReceiveResourceResponse();
666 InstrumentingAgents* instrumentingAgents = cookie.first;
667 if (!instrumentingAgents)
669 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
670 resourceAgent->didReceiveResponse(identifier, loader, response);
671 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
672 consoleAgent->didReceiveResponse(identifier, response); // This should come AFTER resource notification, front-end relies on this.
675 void InspectorInstrumentation::didReceiveResourceResponseButCanceledImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
677 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(frame, identifier, r);
678 InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r);
681 void InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
683 didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
686 void InspectorInstrumentation::continueWithPolicyDownloadImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
688 didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
691 void InspectorInstrumentation::continueWithPolicyIgnoreImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
693 didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
696 void InspectorInstrumentation::didReceiveDataImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
698 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
699 resourceAgent->didReceiveData(identifier, data, dataLength, encodedDataLength);
702 void InspectorInstrumentation::didFinishLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, double monotonicFinishTime)
704 InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
705 InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent();
706 if (!timelineAgent && !resourceAgent)
709 double finishTime = 0.0;
710 // FIXME: Expose all of the timing details to inspector and have it calculate finishTime.
711 if (monotonicFinishTime)
712 finishTime = loader->timing()->convertMonotonicTimeToDocumentTime(monotonicFinishTime);
715 timelineAgent->didFinishLoadingResource(identifier, false, finishTime, loader->frame());
717 resourceAgent->didFinishLoading(identifier, loader, finishTime);
720 void InspectorInstrumentation::didFailLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, const ResourceError& error)
722 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
723 timelineAgent->didFinishLoadingResource(identifier, true, 0, loader->frame());
724 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
725 resourceAgent->didFailLoading(identifier, loader, error);
726 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
727 consoleAgent->didFailLoading(identifier, error); // This should come AFTER resource notification, front-end relies on this.
730 void InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
732 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
733 consoleAgent->resourceRetrievedByXMLHttpRequest(identifier, url, sendURL, sendLineNumber);
734 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
735 resourceAgent->setInitialXHRContent(identifier, sourceString);
738 void InspectorInstrumentation::didReceiveXHRResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
740 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
741 resourceAgent->didReceiveXHRResponse(identifier);
744 void InspectorInstrumentation::willLoadXHRSynchronouslyImpl(InstrumentingAgents* instrumentingAgents)
746 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
747 resourceAgent->willLoadXHRSynchronously();
750 void InspectorInstrumentation::didLoadXHRSynchronouslyImpl(InstrumentingAgents* instrumentingAgents)
752 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
753 resourceAgent->didLoadXHRSynchronously();
756 void InspectorInstrumentation::scriptImportedImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const String& sourceString)
758 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
759 resourceAgent->setInitialScriptContent(identifier, sourceString);
762 void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
764 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
765 resourceAgent->didReceiveScriptResponse(identifier);
768 void InspectorInstrumentation::domContentLoadedEventFiredImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
770 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
771 timelineAgent->didMarkDOMContentEvent(frame);
773 if (frame->page()->mainFrame() != frame)
776 if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
777 inspectorAgent->domContentLoadedEventFired();
779 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
780 domAgent->mainFrameDOMContentLoaded();
782 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
783 pageAgent->domContentEventFired();
786 void InspectorInstrumentation::loadEventFiredImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
788 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
789 domAgent->loadEventFired(frame->document());
791 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
792 timelineAgent->didMarkLoadEvent(frame);
794 if (frame->page()->mainFrame() != frame)
797 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
798 pageAgent->loadEventFired();
801 void InspectorInstrumentation::frameDetachedFromParentImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
803 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
804 pageAgent->frameDetached(frame);
807 void InspectorInstrumentation::didCommitLoadImpl(InstrumentingAgents* instrumentingAgents, Page* page, DocumentLoader* loader)
809 InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
810 if (!inspectorAgent || !inspectorAgent->developerExtrasEnabled())
813 Frame* mainFrame = page->mainFrame();
814 if (loader->frame() == mainFrame) {
815 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
816 consoleAgent->reset();
818 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
819 resourceAgent->mainFrameNavigated(loader);
820 #if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
821 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
822 profilerAgent->resetState();
824 if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
826 #if ENABLE(SQL_DATABASE)
827 if (InspectorDatabaseAgent* databaseAgent = instrumentingAgents->inspectorDatabaseAgent())
828 databaseAgent->clearResources();
830 if (InspectorDOMStorageAgent* domStorageAgent = instrumentingAgents->inspectorDOMStorageAgent())
831 domStorageAgent->clearResources();
832 if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
833 domAgent->setDocument(mainFrame->document());
835 inspectorAgent->didCommitLoad();
837 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
838 pageAgent->frameNavigated(loader);
841 void InspectorInstrumentation::loaderDetachedFromFrameImpl(InstrumentingAgents* instrumentingAgents, DocumentLoader* loader)
843 if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
844 inspectorPageAgent->loaderDetachedFromFrame(loader);
847 InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTMLImpl(InstrumentingAgents* instrumentingAgents, unsigned int length, unsigned int startLine, Frame* frame)
849 int timelineAgentId = 0;
850 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
851 timelineAgent->willWriteHTML(length, startLine, frame);
852 timelineAgentId = timelineAgent->id();
854 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
857 void InspectorInstrumentation::didWriteHTMLImpl(const InspectorInstrumentationCookie& cookie, unsigned int endLine)
859 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
860 timelineAgent->didWriteHTML(endLine);
863 void InspectorInstrumentation::addMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
865 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
866 consoleAgent->addMessageToConsole(source, type, level, message, arguments, callStack);
869 void InspectorInstrumentation::addMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber)
871 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
872 consoleAgent->addMessageToConsole(source, type, level, message, scriptId, lineNumber);
875 void InspectorInstrumentation::consoleCountImpl(InstrumentingAgents* instrumentingAgents, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> stack)
877 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
878 consoleAgent->count(arguments, stack);
881 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents* instrumentingAgents, const String& title)
883 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
884 timelineAgent->time(title);
885 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
886 consoleAgent->startTiming(title);
889 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents* instrumentingAgents, const String& title, PassRefPtr<ScriptCallStack> stack)
891 if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
892 consoleAgent->stopTiming(title, stack);
893 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
894 timelineAgent->timeEnd(title);
897 void InspectorInstrumentation::consoleTimeStampImpl(InstrumentingAgents* instrumentingAgents, PassRefPtr<ScriptArguments> arguments)
899 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
901 arguments->getFirstArgumentAsString(message);
902 timelineAgent->didTimeStamp(message);
906 #if ENABLE(JAVASCRIPT_DEBUGGER)
907 void InspectorInstrumentation::addStartProfilingMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, const String& title, unsigned lineNumber, const String& sourceURL)
909 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
910 profilerAgent->addStartProfilingMessageToConsole(title, lineNumber, sourceURL);
913 void InspectorInstrumentation::addProfileImpl(InstrumentingAgents* instrumentingAgents, RefPtr<ScriptProfile> profile, PassRefPtr<ScriptCallStack> callStack)
915 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent()) {
916 const ScriptCallFrame& lastCaller = callStack->at(0);
917 profilerAgent->addProfile(profile, lastCaller.lineNumber(), lastCaller.sourceURL());
921 String InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl(InstrumentingAgents* instrumentingAgents, bool incrementProfileNumber)
923 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
924 return profilerAgent->getCurrentUserInitiatedProfileName(incrementProfileNumber);
928 bool InspectorInstrumentation::profilerEnabledImpl(InstrumentingAgents* instrumentingAgents)
930 if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
931 return profilerAgent->enabled();
936 #if ENABLE(SQL_DATABASE)
937 void InspectorInstrumentation::didOpenDatabaseImpl(InstrumentingAgents* instrumentingAgents, PassRefPtr<Database> database, const String& domain, const String& name, const String& version)
939 InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
940 if (!inspectorAgent || !inspectorAgent->developerExtrasEnabled())
942 if (InspectorDatabaseAgent* dbAgent = instrumentingAgents->inspectorDatabaseAgent())
943 dbAgent->didOpenDatabase(database, domain, name, version);
947 void InspectorInstrumentation::didUseDOMStorageImpl(InstrumentingAgents* instrumentingAgents, StorageArea* storageArea, bool isLocalStorage, Frame* frame)
949 InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
950 if (!inspectorAgent || !inspectorAgent->developerExtrasEnabled())
952 if (InspectorDOMStorageAgent* domStorageAgent = instrumentingAgents->inspectorDOMStorageAgent())
953 domStorageAgent->didUseDOMStorage(storageArea, isLocalStorage, frame);
956 void InspectorInstrumentation::didDispatchDOMStorageEventImpl(InstrumentingAgents* instrumentingAgents, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin, Page* page)
958 if (InspectorDOMStorageAgent* domStorageAgent = instrumentingAgents->inspectorDOMStorageAgent())
959 domStorageAgent->didDispatchDOMStorageEvent(key, oldValue, newValue, storageType, securityOrigin, page);
963 bool InspectorInstrumentation::shouldPauseDedicatedWorkerOnStartImpl(InstrumentingAgents* instrumentingAgents)
965 if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent())
966 return workerAgent->shouldPauseDedicatedWorkerOnStart();
970 void InspectorInstrumentation::didStartWorkerContextImpl(InstrumentingAgents* instrumentingAgents, WorkerContextProxy* workerContextProxy, const KURL& url)
972 if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent())
973 workerAgent->didStartWorkerContext(workerContextProxy, url);
976 void InspectorInstrumentation::willEvaluateWorkerScript(WorkerContext* workerContext, int workerThreadStartMode)
978 if (workerThreadStartMode != PauseWorkerContextOnStart)
980 InstrumentingAgents* instrumentingAgents = instrumentationForWorkerContext(workerContext);
981 if (!instrumentingAgents)
983 #if ENABLE(JAVASCRIPT_DEBUGGER)
984 if (InspectorRuntimeAgent* runtimeAgent = instrumentingAgents->inspectorRuntimeAgent())
985 runtimeAgent->pauseWorkerContext(workerContext);
989 void InspectorInstrumentation::workerContextTerminatedImpl(InstrumentingAgents* instrumentingAgents, WorkerContextProxy* proxy)
991 if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent())
992 workerAgent->workerContextTerminated(proxy);
996 #if ENABLE(WEB_SOCKETS)
997 void InspectorInstrumentation::didCreateWebSocketImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const KURL& requestURL, const KURL&)
999 InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
1000 if (!inspectorAgent || !inspectorAgent->developerExtrasEnabled())
1002 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1003 resourceAgent->didCreateWebSocket(identifier, requestURL);
1006 void InspectorInstrumentation::willSendWebSocketHandshakeRequestImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const WebSocketHandshakeRequest& request)
1008 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1009 resourceAgent->willSendWebSocketHandshakeRequest(identifier, request);
1012 void InspectorInstrumentation::didReceiveWebSocketHandshakeResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const WebSocketHandshakeResponse& response)
1014 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1015 resourceAgent->didReceiveWebSocketHandshakeResponse(identifier, response);
1018 void InspectorInstrumentation::didCloseWebSocketImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
1020 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1021 resourceAgent->didCloseWebSocket(identifier);
1023 void InspectorInstrumentation::didReceiveWebSocketFrameImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const WebSocketFrame& frame)
1025 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1026 resourceAgent->didReceiveWebSocketFrame(identifier, frame);
1028 void InspectorInstrumentation::didReceiveWebSocketFrameErrorImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const String& errorMessage)
1030 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1031 resourceAgent->didReceiveWebSocketFrameError(identifier, errorMessage);
1033 void InspectorInstrumentation::didSendWebSocketFrameImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const WebSocketFrame& frame)
1035 if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
1036 resourceAgent->didSendWebSocketFrame(identifier, frame);
1040 void InspectorInstrumentation::networkStateChangedImpl(InstrumentingAgents* instrumentingAgents)
1042 if (InspectorApplicationCacheAgent* applicationCacheAgent = instrumentingAgents->inspectorApplicationCacheAgent())
1043 applicationCacheAgent->networkStateChanged();
1046 void InspectorInstrumentation::updateApplicationCacheStatusImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
1048 if (InspectorApplicationCacheAgent* applicationCacheAgent = instrumentingAgents->inspectorApplicationCacheAgent())
1049 applicationCacheAgent->updateApplicationCacheStatus(frame);
1052 bool InspectorInstrumentation::collectingHTMLParseErrors(InstrumentingAgents* instrumentingAgents)
1054 if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
1055 return inspectorAgent->hasFrontend();
1059 bool InspectorInstrumentation::hasFrontendForScriptContext(ScriptExecutionContext* scriptExecutionContext)
1061 if (!scriptExecutionContext)
1065 if (scriptExecutionContext->isWorkerContext()) {
1066 WorkerContext* workerContext = static_cast<WorkerContext*>(scriptExecutionContext);
1067 WorkerInspectorController* workerInspectorController = workerContext->workerInspectorController();
1068 return workerInspectorController && workerInspectorController->hasFrontend();
1072 ASSERT(scriptExecutionContext->isDocument());
1073 Document* document = static_cast<Document*>(scriptExecutionContext);
1074 Page* page = document->page();
1075 return page && page->inspectorController()->hasFrontend();
1078 void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InstrumentingAgents* instrumentingAgents, bool isDOMEvent, const String& eventName, bool synchronous)
1080 #if ENABLE(JAVASCRIPT_DEBUGGER)
1081 if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
1082 domDebuggerAgent->pauseOnNativeEventIfNeeded(isDOMEvent, eventName, synchronous);
1086 void InspectorInstrumentation::cancelPauseOnNativeEvent(InstrumentingAgents* instrumentingAgents)
1088 #if ENABLE(JAVASCRIPT_DEBUGGER)
1089 if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent())
1090 debuggerAgent->cancelPauseOnNextStatement();
1094 void InspectorInstrumentation::didRequestAnimationFrameImpl(InstrumentingAgents* instrumentingAgents, int callbackId, Frame* frame)
1096 pauseOnNativeEventIfNeeded(instrumentingAgents, false, requestAnimationFrameEventName, true);
1098 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
1099 timelineAgent->didRequestAnimationFrame(callbackId, frame);
1102 void InspectorInstrumentation::didCancelAnimationFrameImpl(InstrumentingAgents* instrumentingAgents, int callbackId, Frame* frame)
1104 pauseOnNativeEventIfNeeded(instrumentingAgents, false, cancelAnimationFrameEventName, true);
1106 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
1107 timelineAgent->didCancelAnimationFrame(callbackId, frame);
1110 InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrameImpl(InstrumentingAgents* instrumentingAgents, int callbackId, Frame* frame)
1112 pauseOnNativeEventIfNeeded(instrumentingAgents, false, animationFrameFiredEventName, false);
1114 int timelineAgentId = 0;
1115 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
1116 timelineAgent->willFireAnimationFrame(callbackId, frame);
1117 timelineAgentId = timelineAgent->id();
1119 return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
1122 void InspectorInstrumentation::didFireAnimationFrameImpl(const InspectorInstrumentationCookie& cookie)
1124 if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
1125 timelineAgent->didFireAnimationFrame();
1128 InspectorTimelineAgent* InspectorInstrumentation::timelineAgentForOrphanEvents()
1130 return *threadSpecificTimelineAgentForOrphanEvents();
1133 void InspectorInstrumentation::setTimelineAgentForOrphanEvents(InspectorTimelineAgent* inspectorTimelineAgent)
1135 *threadSpecificTimelineAgentForOrphanEvents() = inspectorTimelineAgent;
1138 WTF::ThreadSpecific<InspectorTimelineAgent*>& InspectorInstrumentation::threadSpecificTimelineAgentForOrphanEvents()
1140 AtomicallyInitializedStatic(WTF::ThreadSpecific<InspectorTimelineAgent*>*, instance = new WTF::ThreadSpecific<InspectorTimelineAgent*>());
1144 InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(const InspectorInstrumentationCookie& cookie)
1148 InspectorTimelineAgent* timelineAgent = cookie.first->inspectorTimelineAgent();
1149 if (timelineAgent && timelineAgent->id() == cookie.second)
1150 return timelineAgent;
1154 InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForPage(Page* page)
1158 return instrumentationForPage(page);
1162 InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForWorkerContext(WorkerContext* workerContext)
1166 return instrumentationForWorkerContext(workerContext);
1169 InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForNonDocumentContext(ScriptExecutionContext* context)
1171 if (context->isWorkerContext())
1172 return instrumentationForWorkerContext(static_cast<WorkerContext*>(context));
1177 #if ENABLE(GEOLOCATION)
1178 GeolocationPosition* InspectorInstrumentation::overrideGeolocationPositionImpl(InstrumentingAgents* instrumentingAgents, GeolocationPosition* position)
1180 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
1181 position = pageAgent->overrideGeolocationPosition(position);
1186 } // namespace WebCore
1188 #endif // !ENABLE(INSPECTOR)