f975343578ddc224a7d62a9de2836cb8b620b873
[WebKit-https.git] / Source / WebCore / inspector / InspectorInstrumentation.h
1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2014 Apple Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 *     * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *     * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 *     * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef InspectorInstrumentation_h
33 #define InspectorInstrumentation_h
34
35 #include "CSSSelector.h"
36 #include "Element.h"
37 #include "FormData.h"
38 #include "Frame.h"
39 #include "HTMLCanvasElement.h"
40 #include "HitTestResult.h"
41 #include "InspectorInstrumentationCookie.h"
42 #include "Page.h"
43 #include "ScriptExecutionContext.h"
44 #include "ScriptState.h"
45 #include "StorageArea.h"
46 #include "WebSocketFrame.h"
47 #include <runtime/ConsoleTypes.h>
48 #include <wtf/RefPtr.h>
49
50 #if ENABLE(WEB_REPLAY)
51 #include "ReplaySession.h"
52 #include "ReplaySessionSegment.h"
53 #endif
54
55
56 namespace Deprecated {
57 class ScriptObject;
58 }
59
60 namespace Inspector {
61 class ConsoleMessage;
62 class ScriptArguments;
63 class ScriptCallStack;
64 }
65
66 namespace JSC {
67 class Profile;
68 }
69
70 namespace WebCore {
71
72 class CSSRule;
73 class CachedResource;
74 class CharacterData;
75 class DOMWindow;
76 class DOMWrapperWorld;
77 class Database;
78 class Document;
79 class DocumentLoader;
80 class DocumentStyleSheetCollection;
81 class GraphicsContext;
82 class HTTPHeaderMap;
83 class InspectorCSSAgent;
84 class InspectorCSSOMWrappers;
85 class InspectorInstrumentation;
86 class InspectorTimelineAgent;
87 class InstrumentingAgents;
88 class URL;
89 class Node;
90 class PseudoElement;
91 class RenderLayer;
92 class RenderLayerBacking;
93 class RenderObject;
94 class ResourceRequest;
95 class ResourceResponse;
96 class SecurityOrigin;
97 class ShadowRoot;
98 class StorageArea;
99 class StyleResolver;
100 class StyleRule;
101 class ThreadableLoaderClient;
102 class WebGLShader;
103 class WebGLProgram;
104 class WebGLRenderingContextBase;
105 class WorkerGlobalScope;
106 class WorkerGlobalScopeProxy;
107 class XMLHttpRequest;
108
109 struct ReplayPosition;
110
111 #define FAST_RETURN_IF_NO_FRONTENDS(value) if (LIKELY(!hasFrontends())) return value;
112
113 class InspectorInstrumentation {
114 public:
115     static void didClearWindowObjectInWorld(Frame&, DOMWrapperWorld&);
116     static bool isDebuggerPaused(Frame*);
117
118     static void willInsertDOMNode(Document&, Node& parent);
119     static void didInsertDOMNode(Document&, Node&);
120     static void willRemoveDOMNode(Document&, Node&);
121     static void didRemoveDOMNode(Document&, Node&);
122     static void willModifyDOMAttr(Document&, Element&, const AtomicString& oldValue, const AtomicString& newValue);
123     static void didModifyDOMAttr(Document&, Element&, const AtomicString& name, const AtomicString& value);
124     static void didRemoveDOMAttr(Document&, Element&, const AtomicString& name);
125     static void characterDataModified(Document&, CharacterData&);
126     static void didInvalidateStyleAttr(Document&, Node&);
127     static void frameWindowDiscarded(Frame*, DOMWindow*);
128     static void mediaQueryResultChanged(Document&);
129     static void didPushShadowRoot(Element& host, ShadowRoot&);
130     static void willPopShadowRoot(Element& host, ShadowRoot&);
131     static void didCreateNamedFlow(Document*, WebKitNamedFlow&);
132     static void willRemoveNamedFlow(Document*, WebKitNamedFlow&);
133     static void didChangeRegionOverset(Document&, WebKitNamedFlow&);
134     static void didRegisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
135     static void didUnregisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement);
136
137     static void mouseDidMoveOverElement(Page&, const HitTestResult&, unsigned modifierFlags);
138     static bool handleMousePress(Frame&);
139     static bool handleTouchEvent(Frame&, Node&);
140     static bool forcePseudoState(Element&, CSSSelector::PseudoClassType);
141
142     static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
143     static void didInstallTimer(ScriptExecutionContext*, int timerId, int timeout, bool singleShot);
144     static void didRemoveTimer(ScriptExecutionContext*, int timerId);
145
146     static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine);
147     static void didCallFunction(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
148     static InspectorInstrumentationCookie willDispatchXHRReadyStateChangeEvent(ScriptExecutionContext*, XMLHttpRequest&);
149     static void didDispatchXHRReadyStateChangeEvent(const InspectorInstrumentationCookie&);
150     static InspectorInstrumentationCookie willDispatchEvent(Document&, const Event&, bool hasEventListeners);
151     static void didDispatchEvent(const InspectorInstrumentationCookie&);
152     static InspectorInstrumentationCookie willHandleEvent(ScriptExecutionContext*, const Event&);
153     static void didHandleEvent(const InspectorInstrumentationCookie&);
154     static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event&, DOMWindow&);
155     static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&);
156     static InspectorInstrumentationCookie willEvaluateScript(Frame&, const String& url, int lineNumber);
157     static void didEvaluateScript(const InspectorInstrumentationCookie&, Frame&);
158     static void scriptsEnabled(Page&, bool isEnabled);
159     static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext*, int timerId);
160     static void didFireTimer(const InspectorInstrumentationCookie&);
161     static void didInvalidateLayout(Frame&);
162     static InspectorInstrumentationCookie willLayout(Frame&);
163     static void didLayout(const InspectorInstrumentationCookie&, RenderObject*);
164     static void didScroll(Page&);
165     static InspectorInstrumentationCookie willDispatchXHRLoadEvent(ScriptExecutionContext*, XMLHttpRequest&);
166     static void didDispatchXHRLoadEvent(const InspectorInstrumentationCookie&);
167     static void willScrollLayer(Frame&);
168     static void didScrollLayer(Frame&);
169     static void willPaint(RenderObject*);
170     static void didPaint(RenderObject*, const LayoutRect&);
171     static InspectorInstrumentationCookie willRecalculateStyle(Document&);
172     static void didRecalculateStyle(const InspectorInstrumentationCookie&);
173     static void didScheduleStyleRecalculation(Document&);
174
175     static void applyEmulatedMedia(Frame&, String&);
176     static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
177     static void continueAfterPingLoader(Frame&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
178     static void markResourceAsCached(Page&, unsigned long identifier);
179     static void didLoadResourceFromMemoryCache(Page&, DocumentLoader*, CachedResource*);
180     static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*);
181     static void didReceiveResourceResponse(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
182     static void continueAfterXFrameOptionsDenied(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
183     static void continueWithPolicyDownload(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
184     static void continueWithPolicyIgnore(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
185     static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
186     static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, double finishTime);
187     static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
188     static void didFinishXHRLoading(ScriptExecutionContext*, ThreadableLoaderClient*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber);
189     static void didReceiveXHRResponse(ScriptExecutionContext*, unsigned long identifier);
190     static void willLoadXHRSynchronously(ScriptExecutionContext*);
191     static void didLoadXHRSynchronously(ScriptExecutionContext*);
192     static void scriptImported(ScriptExecutionContext*, unsigned long identifier, const String& sourceString);
193     static void scriptExecutionBlockedByCSP(ScriptExecutionContext*, const String& directiveText);
194     static void didReceiveScriptResponse(ScriptExecutionContext*, unsigned long identifier);
195     static void domContentLoadedEventFired(Frame&);
196     static void loadEventFired(Frame*);
197     static void frameDetachedFromParent(Frame&);
198     static void didCommitLoad(Frame&, DocumentLoader*);
199     static void frameDocumentUpdated(Frame*);
200     static void loaderDetachedFromFrame(Frame&, DocumentLoader&);
201     static void frameStartedLoading(Frame&);
202     static void frameStoppedLoading(Frame&);
203     static void frameScheduledNavigation(Frame&, double delay);
204     static void frameClearedScheduledNavigation(Frame&);
205     static InspectorInstrumentationCookie willRunJavaScriptDialog(Page&, const String& message);
206     static void didRunJavaScriptDialog(const InspectorInstrumentationCookie&);
207     static void willDestroyCachedResource(CachedResource&);
208
209     static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned startLine);
210     static void didWriteHTML(const InspectorInstrumentationCookie&, unsigned endLine);
211
212     static void addMessageToConsole(Page&, std::unique_ptr<Inspector::ConsoleMessage>);
213
214     // FIXME: Convert to ScriptArguments to match non-worker context.
215     static void addMessageToConsole(WorkerGlobalScope*, std::unique_ptr<Inspector::ConsoleMessage>);
216
217     static void consoleCount(Page&, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&);
218     static void startConsoleTiming(Frame&, const String& title);
219     static void stopConsoleTiming(Frame&, const String& title, RefPtr<Inspector::ScriptCallStack>&&);
220     static void consoleTimeStamp(Frame&, RefPtr<Inspector::ScriptArguments>&&);
221
222     static void didRequestAnimationFrame(Document*, int callbackId);
223     static void didCancelAnimationFrame(Document*, int callbackId);
224     static InspectorInstrumentationCookie willFireAnimationFrame(Document*, int callbackId);
225     static void didFireAnimationFrame(const InspectorInstrumentationCookie&);
226
227     static void startProfiling(Page&, JSC::ExecState*, const String& title);
228     static RefPtr<JSC::Profile> stopProfiling(Page&, JSC::ExecState*, const String& title);
229
230     static void didOpenDatabase(ScriptExecutionContext*, RefPtr<Database>&&, const String& domain, const String& name, const String& version);
231
232     static void didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Page*);
233
234     static bool shouldPauseDedicatedWorkerOnStart(ScriptExecutionContext*);
235     static void didStartWorkerGlobalScope(ScriptExecutionContext*, WorkerGlobalScopeProxy*, const URL&);
236     static void workerGlobalScopeTerminated(ScriptExecutionContext*, WorkerGlobalScopeProxy*);
237     static void willEvaluateWorkerScript(WorkerGlobalScope*, int workerThreadStartMode);
238
239 #if ENABLE(WEB_REPLAY)
240     static void sessionCreated(Page&, RefPtr<ReplaySession>&&);
241     static void sessionLoaded(Page&, RefPtr<ReplaySession>&&);
242     static void sessionModified(Page&, RefPtr<ReplaySession>&&);
243
244     static void segmentCreated(Page&, RefPtr<ReplaySessionSegment>&&);
245     static void segmentCompleted(Page&, RefPtr<ReplaySessionSegment>&&);
246     static void segmentLoaded(Page&, RefPtr<ReplaySessionSegment>&&);
247     static void segmentUnloaded(Page&);
248
249     static void captureStarted(Page&);
250     static void captureStopped(Page&);
251
252     static void playbackStarted(Page&);
253     static void playbackPaused(Page&, const ReplayPosition&);
254     static void playbackHitPosition(Page&, const ReplayPosition&);
255     static void playbackFinished(Page&);
256 #endif
257
258 #if ENABLE(WEB_SOCKETS)
259     static void didCreateWebSocket(Document*, unsigned long identifier, const URL& requestURL, const URL& documentURL, const String& protocol);
260     static void willSendWebSocketHandshakeRequest(Document*, unsigned long identifier, const ResourceRequest&);
261     static void didReceiveWebSocketHandshakeResponse(Document*, unsigned long identifier, const ResourceResponse&);
262     static void didCloseWebSocket(Document*, unsigned long identifier);
263     static void didReceiveWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
264     static void didSendWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
265     static void didReceiveWebSocketFrameError(Document*, unsigned long identifier, const String& errorMessage);
266 #endif
267
268     static void didCreateCSSCanvas(HTMLCanvasElement&, const String&);
269     static void didCreateCanvasRenderingContext(HTMLCanvasElement&);
270 #if ENABLE(WEBGL)
271     static void didAttachShader(WebGLRenderingContextBase&, WebGLProgram&, WebGLShader&);
272     static void didDetachShader(WebGLRenderingContextBase&, WebGLProgram&, WebGLShader&);
273     static void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
274     static void didDeleteProgram(WebGLRenderingContextBase&, WebGLProgram&);
275 #endif
276
277     static void networkStateChanged(Page*);
278     static void updateApplicationCacheStatus(Frame*);
279
280     static void layerTreeDidChange(Page*);
281     static void renderLayerDestroyed(Page*, const RenderLayer&);
282     static void pseudoElementDestroyed(Page*, PseudoElement&);
283
284     static void frontendCreated() { s_frontendCounter += 1; }
285     static void frontendDeleted() { s_frontendCounter -= 1; }
286     static bool hasFrontends() { return s_frontendCounter; }
287     static bool consoleAgentEnabled(ScriptExecutionContext*);
288     static bool timelineAgentEnabled(ScriptExecutionContext*);
289     static bool replayAgentEnabled(ScriptExecutionContext*);
290
291     WEBCORE_EXPORT static InstrumentingAgents* instrumentingAgentsForPage(Page*);
292
293     static void registerInstrumentingAgents(InstrumentingAgents&);
294     static void unregisterInstrumentingAgents(InstrumentingAgents&);
295
296 private:
297     static void didClearWindowObjectInWorldImpl(InstrumentingAgents&, Frame&, DOMWrapperWorld&);
298     static bool isDebuggerPausedImpl(InstrumentingAgents&);
299
300     static void willInsertDOMNodeImpl(InstrumentingAgents&, Node& parent);
301     static void didInsertDOMNodeImpl(InstrumentingAgents&, Node&);
302     static void willRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
303     static void didRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
304     static void willModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomicString& oldValue, const AtomicString& newValue);
305     static void didModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomicString& name, const AtomicString& value);
306     static void didRemoveDOMAttrImpl(InstrumentingAgents&, Element&, const AtomicString& name);
307     static void characterDataModifiedImpl(InstrumentingAgents&, CharacterData&);
308     static void didInvalidateStyleAttrImpl(InstrumentingAgents&, Node&);
309     static void frameWindowDiscardedImpl(InstrumentingAgents&, DOMWindow*);
310     static void mediaQueryResultChangedImpl(InstrumentingAgents&);
311     static void didPushShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
312     static void willPopShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
313     static void didCreateNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
314     static void willRemoveNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
315     static void didChangeRegionOversetImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&);
316     static void didRegisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
317     static void didUnregisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement);
318
319     static void mouseDidMoveOverElementImpl(InstrumentingAgents&, const HitTestResult&, unsigned modifierFlags);
320     static bool handleTouchEventImpl(InstrumentingAgents&, Node&);
321     static bool handleMousePressImpl(InstrumentingAgents&);
322     static bool forcePseudoStateImpl(InstrumentingAgents&, Element&, CSSSelector::PseudoClassType);
323
324     static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url);
325     static void didInstallTimerImpl(InstrumentingAgents&, int timerId, int timeout, bool singleShot, ScriptExecutionContext*);
326     static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext*);
327
328     static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents&, const String& scriptName, int scriptLine, ScriptExecutionContext*);
329     static void didCallFunctionImpl(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
330     static InspectorInstrumentationCookie willDispatchXHRReadyStateChangeEventImpl(InstrumentingAgents&, XMLHttpRequest&, ScriptExecutionContext*);
331     static void didDispatchXHRReadyStateChangeEventImpl(const InspectorInstrumentationCookie&);
332     static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents&, Document&, const Event&, bool hasEventListeners);
333     static InspectorInstrumentationCookie willHandleEventImpl(InstrumentingAgents&, const Event&);
334     static void didHandleEventImpl(const InspectorInstrumentationCookie&);
335     static void didDispatchEventImpl(const InspectorInstrumentationCookie&);
336     static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InstrumentingAgents&, const Event&, DOMWindow&);
337     static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&);
338     static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents&, Frame&, const String& url, int lineNumber);
339     static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&, Frame&);
340     static void scriptsEnabledImpl(InstrumentingAgents&, bool isEnabled);
341     static InspectorInstrumentationCookie willFireTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext*);
342     static void didFireTimerImpl(const InspectorInstrumentationCookie&);
343     static void didInvalidateLayoutImpl(InstrumentingAgents&, Frame&);
344     static InspectorInstrumentationCookie willLayoutImpl(InstrumentingAgents&, Frame&);
345     static void didLayoutImpl(const InspectorInstrumentationCookie&, RenderObject*);
346     static void didScrollImpl(InstrumentingAgents&);
347     static InspectorInstrumentationCookie willDispatchXHRLoadEventImpl(InstrumentingAgents&, XMLHttpRequest&, ScriptExecutionContext*);
348     static void didDispatchXHRLoadEventImpl(const InspectorInstrumentationCookie&);
349     static void willScrollLayerImpl(InstrumentingAgents&, Frame&);
350     static void didScrollLayerImpl(InstrumentingAgents&);
351     static void willPaintImpl(InstrumentingAgents&, RenderObject*);
352     static void didPaintImpl(InstrumentingAgents&, RenderObject*, const LayoutRect&);
353     static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents&, Document&);
354     static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
355     static void didScheduleStyleRecalculationImpl(InstrumentingAgents&, Document&);
356
357     static void applyEmulatedMediaImpl(InstrumentingAgents&, String&);
358     static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
359     static void continueAfterPingLoaderImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
360     static void markResourceAsCachedImpl(InstrumentingAgents&, unsigned long identifier);
361     static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents&, DocumentLoader*, CachedResource*);
362     static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InstrumentingAgents&);
363     static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
364     static void didReceiveResourceResponseButCanceledImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
365     static void continueAfterXFrameOptionsDeniedImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
366     static void continueWithPolicyDownloadImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
367     static void continueWithPolicyIgnoreImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
368     static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
369     static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, double finishTime);
370     static void didFailLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceError&);
371     static void willLoadXHRImpl(InstrumentingAgents&, ThreadableLoaderClient*, const String&, const URL&, bool, RefPtr<FormData>&&, const HTTPHeaderMap&, bool);
372     static void didFailXHRLoadingImpl(InstrumentingAgents&, ThreadableLoaderClient*);
373     static void didFinishXHRLoadingImpl(InstrumentingAgents&, ThreadableLoaderClient*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber);
374     static void didReceiveXHRResponseImpl(InstrumentingAgents&, unsigned long identifier);
375     static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&);
376     static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&);
377     static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString);
378     static void scriptExecutionBlockedByCSPImpl(InstrumentingAgents&, const String& directiveText);
379     static void didReceiveScriptResponseImpl(InstrumentingAgents&, unsigned long identifier);
380     static void domContentLoadedEventFiredImpl(InstrumentingAgents&, Frame&);
381     static void loadEventFiredImpl(InstrumentingAgents&, Frame*);
382     static void frameDetachedFromParentImpl(InstrumentingAgents&, Frame&);
383     static void didCommitLoadImpl(InstrumentingAgents&, Page*, DocumentLoader*);
384     static void frameDocumentUpdatedImpl(InstrumentingAgents&, Frame*);
385     static void loaderDetachedFromFrameImpl(InstrumentingAgents&, DocumentLoader&);
386     static void frameStartedLoadingImpl(InstrumentingAgents&, Frame&);
387     static void frameStoppedLoadingImpl(InstrumentingAgents&, Frame&);
388     static void frameScheduledNavigationImpl(InstrumentingAgents&, Frame&, double delay);
389     static void frameClearedScheduledNavigationImpl(InstrumentingAgents&, Frame&);
390     static InspectorInstrumentationCookie willRunJavaScriptDialogImpl(InstrumentingAgents&, const String& message);
391     static void didRunJavaScriptDialogImpl(const InspectorInstrumentationCookie&);
392     static void willDestroyCachedResourceImpl(CachedResource&);
393
394     static InspectorInstrumentationCookie willWriteHTMLImpl(InstrumentingAgents&, unsigned startLine, Frame*);
395     static void didWriteHTMLImpl(const InspectorInstrumentationCookie&, unsigned endLine);
396
397     static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>);
398
399     static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&);
400     static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title);
401     static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title, RefPtr<Inspector::ScriptCallStack>&&);
402     static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, RefPtr<Inspector::ScriptArguments>&&);
403
404     static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Frame*);
405     static void didCancelAnimationFrameImpl(InstrumentingAgents&, int callbackId, Frame*);
406     static InspectorInstrumentationCookie willFireAnimationFrameImpl(InstrumentingAgents&, int callbackId, Frame*);
407     static void didFireAnimationFrameImpl(const InspectorInstrumentationCookie&);
408
409     static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
410     static RefPtr<JSC::Profile> stopProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
411
412     static void didOpenDatabaseImpl(InstrumentingAgents&, RefPtr<Database>&&, const String& domain, const String& name, const String& version);
413
414     static void didDispatchDOMStorageEventImpl(InstrumentingAgents&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Page*);
415
416     static bool shouldPauseDedicatedWorkerOnStartImpl(InstrumentingAgents&);
417     static void didStartWorkerGlobalScopeImpl(InstrumentingAgents&, WorkerGlobalScopeProxy*, const URL&);
418     static void workerGlobalScopeTerminatedImpl(InstrumentingAgents&, WorkerGlobalScopeProxy*);
419
420 #if ENABLE(WEB_REPLAY)
421     static void sessionCreatedImpl(InstrumentingAgents&, RefPtr<ReplaySession>&&);
422     static void sessionLoadedImpl(InstrumentingAgents&, RefPtr<ReplaySession>&&);
423     static void sessionModifiedImpl(InstrumentingAgents&, RefPtr<ReplaySession>&&);
424
425     static void segmentCreatedImpl(InstrumentingAgents&, RefPtr<ReplaySessionSegment>&&);
426     static void segmentCompletedImpl(InstrumentingAgents&, RefPtr<ReplaySessionSegment>&&);
427     static void segmentLoadedImpl(InstrumentingAgents&, RefPtr<ReplaySessionSegment>&&);
428     static void segmentUnloadedImpl(InstrumentingAgents&);
429
430     static void captureStartedImpl(InstrumentingAgents&);
431     static void captureStoppedImpl(InstrumentingAgents&);
432
433     static void playbackStartedImpl(InstrumentingAgents&);
434     static void playbackPausedImpl(InstrumentingAgents&, const ReplayPosition&);
435     static void playbackHitPositionImpl(InstrumentingAgents&, const ReplayPosition&);
436     static void playbackFinishedImpl(InstrumentingAgents&);
437 #endif
438
439 #if ENABLE(WEB_SOCKETS)
440     static void didCreateWebSocketImpl(InstrumentingAgents&, unsigned long identifier, const URL& requestURL, const URL& documentURL, const String& protocol, Document*);
441     static void willSendWebSocketHandshakeRequestImpl(InstrumentingAgents&, unsigned long identifier, const ResourceRequest&, Document*);
442     static void didReceiveWebSocketHandshakeResponseImpl(InstrumentingAgents&, unsigned long identifier, const ResourceResponse&, Document*);
443     static void didCloseWebSocketImpl(InstrumentingAgents&, unsigned long identifier, Document*);
444     static void didReceiveWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
445     static void didSendWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
446     static void didReceiveWebSocketFrameErrorImpl(InstrumentingAgents&, unsigned long identifier, const String&);
447 #endif
448
449     static void networkStateChangedImpl(InstrumentingAgents&);
450     static void updateApplicationCacheStatusImpl(InstrumentingAgents&, Frame*);
451     static void didCreateCSSCanvasImpl(InstrumentingAgents*, HTMLCanvasElement&, const String&);
452     static void didCreateCanvasRenderingContextImpl(InstrumentingAgents*, HTMLCanvasElement&);
453
454 #if ENABLE(WEBGL)
455     static void didAttachShaderImpl(InstrumentingAgents*, WebGLRenderingContextBase&, WebGLProgram&, WebGLShader&);
456     static void didDetachShaderImpl(InstrumentingAgents*, WebGLRenderingContextBase&, WebGLProgram&, WebGLShader&);
457     static void didCreateProgramImpl(InstrumentingAgents*, WebGLRenderingContextBase&, WebGLProgram&);
458     static void didDeleteProgramImpl(InstrumentingAgents*, WebGLRenderingContextBase&, WebGLProgram&);
459 #endif
460
461     static void layerTreeDidChangeImpl(InstrumentingAgents&);
462     static void renderLayerDestroyedImpl(InstrumentingAgents&, const RenderLayer&);
463     static void pseudoElementDestroyedImpl(InstrumentingAgents&, PseudoElement&);
464
465     static InstrumentingAgents* instrumentingAgentsForPage(Page&);
466     static InstrumentingAgents* instrumentingAgentsForFrame(Frame&);
467     static InstrumentingAgents* instrumentingAgentsForFrame(Frame*);
468     static InstrumentingAgents* instrumentingAgentsForRenderingContext(WebGLRenderingContextBase*);
469     static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext*);
470     static InstrumentingAgents* instrumentingAgentsForDocument(Document&);
471     static InstrumentingAgents* instrumentingAgentsForDocument(Document*);
472     static InstrumentingAgents* instrumentingAgentsForRenderer(RenderObject*);
473
474     static InstrumentingAgents* instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope*);
475     static InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ScriptExecutionContext*);
476
477     static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
478
479     static void pauseOnNativeEventIfNeeded(InstrumentingAgents&, bool isDOMEvent, const String& eventName, bool synchronous);
480     static void cancelPauseOnNativeEvent(InstrumentingAgents&);
481
482     WEBCORE_EXPORT static int s_frontendCounter;
483 };
484
485 inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld& world)
486 {
487     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
488         didClearWindowObjectInWorldImpl(*instrumentingAgents, frame, world);
489 }
490
491 inline bool InspectorInstrumentation::isDebuggerPaused(Frame* frame)
492 {
493     FAST_RETURN_IF_NO_FRONTENDS(false);
494     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
495         return isDebuggerPausedImpl(*instrumentingAgents);
496     return false;
497 }
498
499 inline void InspectorInstrumentation::willInsertDOMNode(Document& document, Node& parent)
500 {
501     FAST_RETURN_IF_NO_FRONTENDS(void());
502     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
503         willInsertDOMNodeImpl(*instrumentingAgents, parent);
504 }
505
506 inline void InspectorInstrumentation::didInsertDOMNode(Document& document, Node& node)
507 {
508     FAST_RETURN_IF_NO_FRONTENDS(void());
509     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
510         didInsertDOMNodeImpl(*instrumentingAgents, node);
511 }
512
513 inline void InspectorInstrumentation::willRemoveDOMNode(Document& document, Node& node)
514 {
515     FAST_RETURN_IF_NO_FRONTENDS(void());
516     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
517         willRemoveDOMNodeImpl(*instrumentingAgents, node);
518 }
519
520 inline void InspectorInstrumentation::didRemoveDOMNode(Document& document, Node& node)
521 {
522     FAST_RETURN_IF_NO_FRONTENDS(void());
523     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
524         didRemoveDOMNodeImpl(*instrumentingAgents, node);
525 }
526
527 inline void InspectorInstrumentation::willModifyDOMAttr(Document& document, Element& element, const AtomicString& oldValue, const AtomicString& newValue)
528 {
529     FAST_RETURN_IF_NO_FRONTENDS(void());
530     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
531         willModifyDOMAttrImpl(*instrumentingAgents, element, oldValue, newValue);
532 }
533
534 inline void InspectorInstrumentation::didModifyDOMAttr(Document& document, Element& element, const AtomicString& name, const AtomicString& value)
535 {
536     FAST_RETURN_IF_NO_FRONTENDS(void());
537     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
538         didModifyDOMAttrImpl(*instrumentingAgents, element, name, value);
539 }
540
541 inline void InspectorInstrumentation::didRemoveDOMAttr(Document& document, Element& element, const AtomicString& name)
542 {
543     FAST_RETURN_IF_NO_FRONTENDS(void());
544     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
545         didRemoveDOMAttrImpl(*instrumentingAgents, element, name);
546 }
547
548 inline void InspectorInstrumentation::didInvalidateStyleAttr(Document& document, Node& node)
549 {
550     FAST_RETURN_IF_NO_FRONTENDS(void());
551     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
552         didInvalidateStyleAttrImpl(*instrumentingAgents, node);
553 }
554
555 inline void InspectorInstrumentation::frameWindowDiscarded(Frame* frame, DOMWindow* domWindow)
556 {
557     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
558         frameWindowDiscardedImpl(*instrumentingAgents, domWindow);
559 }
560
561 inline void InspectorInstrumentation::mediaQueryResultChanged(Document& document)
562 {
563     FAST_RETURN_IF_NO_FRONTENDS(void());
564     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
565         mediaQueryResultChangedImpl(*instrumentingAgents);
566 }
567
568 inline void InspectorInstrumentation::didPushShadowRoot(Element& host, ShadowRoot& root)
569 {
570     FAST_RETURN_IF_NO_FRONTENDS(void());
571     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
572         didPushShadowRootImpl(*instrumentingAgents, host, root);
573 }
574
575 inline void InspectorInstrumentation::willPopShadowRoot(Element& host, ShadowRoot& root)
576 {
577     FAST_RETURN_IF_NO_FRONTENDS(void());
578     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
579         willPopShadowRootImpl(*instrumentingAgents, host, root);
580 }
581
582 inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
583 {
584     FAST_RETURN_IF_NO_FRONTENDS(void());
585     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
586         didCreateNamedFlowImpl(*instrumentingAgents, document, namedFlow);
587 }
588
589 inline void InspectorInstrumentation::willRemoveNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
590 {
591     FAST_RETURN_IF_NO_FRONTENDS(void());
592     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
593         willRemoveNamedFlowImpl(*instrumentingAgents, document, namedFlow);
594 }
595
596 inline void InspectorInstrumentation::didChangeRegionOverset(Document& document, WebKitNamedFlow& namedFlow)
597 {
598     FAST_RETURN_IF_NO_FRONTENDS(void());
599     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
600         didChangeRegionOversetImpl(*instrumentingAgents, document, namedFlow);
601 }
602
603 inline void InspectorInstrumentation::didRegisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement, Node* nextContentElement)
604 {
605     FAST_RETURN_IF_NO_FRONTENDS(void());
606     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
607         didRegisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement, nextContentElement);
608 }
609
610 inline void InspectorInstrumentation::didUnregisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement)
611 {
612     FAST_RETURN_IF_NO_FRONTENDS(void());
613     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
614         didUnregisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement);
615 }
616
617 inline void InspectorInstrumentation::mouseDidMoveOverElement(Page& page, const HitTestResult& result, unsigned modifierFlags)
618 {
619     FAST_RETURN_IF_NO_FRONTENDS(void());
620     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
621         mouseDidMoveOverElementImpl(*instrumentingAgents, result, modifierFlags);
622 }
623
624 inline bool InspectorInstrumentation::handleTouchEvent(Frame& frame, Node& node)
625 {
626     FAST_RETURN_IF_NO_FRONTENDS(false);
627     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
628         return handleTouchEventImpl(*instrumentingAgents, node);
629     return false;
630 }
631
632 inline bool InspectorInstrumentation::handleMousePress(Frame& frame)
633 {
634     FAST_RETURN_IF_NO_FRONTENDS(false);
635     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
636         return handleMousePressImpl(*instrumentingAgents);
637     return false;
638 }
639
640 inline bool InspectorInstrumentation::forcePseudoState(Element& element, CSSSelector::PseudoClassType pseudoState)
641 {
642     FAST_RETURN_IF_NO_FRONTENDS(false);
643     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
644         return forcePseudoStateImpl(*instrumentingAgents, element, pseudoState);
645     return false;
646 }
647
648 inline void InspectorInstrumentation::characterDataModified(Document& document, CharacterData& characterData)
649 {
650     FAST_RETURN_IF_NO_FRONTENDS(void());
651     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
652         characterDataModifiedImpl(*instrumentingAgents, characterData);
653 }
654
655 inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url)
656 {
657     FAST_RETURN_IF_NO_FRONTENDS(void());
658     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
659         willSendXMLHttpRequestImpl(*instrumentingAgents, url);
660 }
661
662 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, int timeout, bool singleShot)
663 {
664     FAST_RETURN_IF_NO_FRONTENDS(void());
665     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
666         didInstallTimerImpl(*instrumentingAgents, timerId, timeout, singleShot, context);
667 }
668
669 inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext* context, int timerId)
670 {
671     FAST_RETURN_IF_NO_FRONTENDS(void());
672     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
673         didRemoveTimerImpl(*instrumentingAgents, timerId, context);
674 }
675
676 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(ScriptExecutionContext* context, const String& scriptName, int scriptLine)
677 {
678     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
679     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
680         return willCallFunctionImpl(*instrumentingAgents, scriptName, scriptLine, context);
681     return InspectorInstrumentationCookie();
682 }
683
684
685 inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie, ScriptExecutionContext* context)
686 {
687     FAST_RETURN_IF_NO_FRONTENDS(void());
688     if (cookie.isValid())
689         didCallFunctionImpl(cookie, context);
690 }
691
692 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchXHRReadyStateChangeEvent(ScriptExecutionContext* context, XMLHttpRequest& request)
693 {
694     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
695     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
696         return willDispatchXHRReadyStateChangeEventImpl(*instrumentingAgents, request, context);
697     return InspectorInstrumentationCookie();
698 }
699
700 inline void InspectorInstrumentation::didDispatchXHRReadyStateChangeEvent(const InspectorInstrumentationCookie& cookie)
701 {
702     FAST_RETURN_IF_NO_FRONTENDS(void());
703     if (cookie.isValid())
704         didDispatchXHRReadyStateChangeEventImpl(cookie);
705 }
706
707 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document& document, const Event& event, bool hasEventListeners)
708 {
709     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
710     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
711         return willDispatchEventImpl(*instrumentingAgents, document, event, hasEventListeners);
712     return InspectorInstrumentationCookie();
713 }
714
715 inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie)
716 {
717     FAST_RETURN_IF_NO_FRONTENDS(void());
718     if (cookie.isValid())
719         didDispatchEventImpl(cookie);
720 }
721
722 inline InspectorInstrumentationCookie InspectorInstrumentation::willHandleEvent(ScriptExecutionContext* context, const Event& event)
723 {
724     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
725     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
726         return willHandleEventImpl(*instrumentingAgents, event);
727     return InspectorInstrumentationCookie();
728 }
729
730 inline void InspectorInstrumentation::didHandleEvent(const InspectorInstrumentationCookie& cookie)
731 {
732     FAST_RETURN_IF_NO_FRONTENDS(void());
733     if (cookie.isValid())
734         didHandleEventImpl(cookie);
735 }
736
737 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindow(Frame* frame, const Event& event, DOMWindow& window)
738 {
739     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
740     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
741         return willDispatchEventOnWindowImpl(*instrumentingAgents, event, window);
742     return InspectorInstrumentationCookie();
743 }
744
745 inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie)
746 {
747     FAST_RETURN_IF_NO_FRONTENDS(void());
748     if (cookie.isValid())
749         didDispatchEventOnWindowImpl(cookie);
750 }
751
752 inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame& frame, const String& url, int lineNumber)
753 {
754     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
755     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
756         return willEvaluateScriptImpl(*instrumentingAgents, frame, url, lineNumber);
757     return InspectorInstrumentationCookie();
758 }
759
760 inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumentationCookie& cookie, Frame& frame)
761 {
762     FAST_RETURN_IF_NO_FRONTENDS(void());
763     if (cookie.isValid())
764         didEvaluateScriptImpl(cookie, frame);
765 }
766
767 inline void InspectorInstrumentation::scriptsEnabled(Page& page, bool isEnabled)
768 {
769     FAST_RETURN_IF_NO_FRONTENDS(void());
770     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
771         return scriptsEnabledImpl(*instrumentingAgents, isEnabled);
772 }
773
774 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext* context, int timerId)
775 {
776     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
777     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
778         return willFireTimerImpl(*instrumentingAgents, timerId, context);
779     return InspectorInstrumentationCookie();
780 }
781
782 inline void InspectorInstrumentation::didFireTimer(const InspectorInstrumentationCookie& cookie)
783 {
784     FAST_RETURN_IF_NO_FRONTENDS(void());
785     if (cookie.isValid())
786         didFireTimerImpl(cookie);
787 }
788
789 inline void InspectorInstrumentation::didInvalidateLayout(Frame& frame)
790 {
791     FAST_RETURN_IF_NO_FRONTENDS(void());
792     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
793         didInvalidateLayoutImpl(*instrumentingAgents, frame);
794 }
795
796 inline InspectorInstrumentationCookie InspectorInstrumentation::willLayout(Frame& frame)
797 {
798     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
799     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
800         return willLayoutImpl(*instrumentingAgents, frame);
801     return InspectorInstrumentationCookie();
802 }
803
804 inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCookie& cookie, RenderObject* root)
805 {
806     FAST_RETURN_IF_NO_FRONTENDS(void());
807     if (cookie.isValid())
808         didLayoutImpl(cookie, root);
809 }
810
811 inline void InspectorInstrumentation::didScroll(Page& page)
812 {
813     FAST_RETURN_IF_NO_FRONTENDS(void());
814     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
815         didScrollImpl(*instrumentingAgents);
816 }
817
818 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchXHRLoadEvent(ScriptExecutionContext* context, XMLHttpRequest& request)
819 {
820     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
821     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
822         return willDispatchXHRLoadEventImpl(*instrumentingAgents, request, context);
823     return InspectorInstrumentationCookie();
824 }
825
826 inline void InspectorInstrumentation::didDispatchXHRLoadEvent(const InspectorInstrumentationCookie& cookie)
827 {
828     FAST_RETURN_IF_NO_FRONTENDS(void());
829     if (cookie.isValid())
830         didDispatchXHRLoadEventImpl(cookie);
831 }
832
833 inline void InspectorInstrumentation::willPaint(RenderObject* renderer)
834 {
835     FAST_RETURN_IF_NO_FRONTENDS(void());
836     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
837         return willPaintImpl(*instrumentingAgents, renderer);
838 }
839
840 inline void InspectorInstrumentation::didPaint(RenderObject* renderer, const LayoutRect& rect)
841 {
842     FAST_RETURN_IF_NO_FRONTENDS(void());
843     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
844         didPaintImpl(*instrumentingAgents, renderer, rect);
845 }
846
847 inline void InspectorInstrumentation::willScrollLayer(Frame& frame)
848 {
849     FAST_RETURN_IF_NO_FRONTENDS(void());
850     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
851         willScrollLayerImpl(*instrumentingAgents, frame);
852 }
853
854 inline void InspectorInstrumentation::didScrollLayer(Frame& frame)
855 {
856     FAST_RETURN_IF_NO_FRONTENDS(void());
857     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
858         didScrollLayerImpl(*instrumentingAgents);
859 }
860
861 inline InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyle(Document& document)
862 {
863     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
864     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
865         return willRecalculateStyleImpl(*instrumentingAgents, document);
866     return InspectorInstrumentationCookie();
867 }
868
869 inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrumentationCookie& cookie)
870 {
871     FAST_RETURN_IF_NO_FRONTENDS(void());
872     if (cookie.isValid())
873         didRecalculateStyleImpl(cookie);
874 }
875
876 inline void InspectorInstrumentation::didScheduleStyleRecalculation(Document& document)
877 {
878     FAST_RETURN_IF_NO_FRONTENDS(void());
879     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
880         didScheduleStyleRecalculationImpl(*instrumentingAgents, document);
881 }
882
883 inline void InspectorInstrumentation::applyEmulatedMedia(Frame& frame, String& media)
884 {
885     FAST_RETURN_IF_NO_FRONTENDS(void());
886     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
887         applyEmulatedMediaImpl(*instrumentingAgents, media);
888 }
889
890 inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
891 {
892     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
893         willSendRequestImpl(*instrumentingAgents, identifier, loader, request, redirectResponse);
894 }
895
896 inline void InspectorInstrumentation::continueAfterPingLoader(Frame& frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& response)
897 {
898     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(&frame))
899         InspectorInstrumentation::continueAfterPingLoaderImpl(*instrumentingAgents, identifier, loader, request, response);
900 }
901
902 inline void InspectorInstrumentation::markResourceAsCached(Page& page, unsigned long identifier)
903 {
904     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
905         markResourceAsCachedImpl(*instrumentingAgents, identifier);
906 }
907
908 inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page& page, DocumentLoader* loader, CachedResource* resource)
909 {
910     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
911         didLoadResourceFromMemoryCacheImpl(*instrumentingAgents, loader, resource);
912 }
913
914 inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponse(Frame* frame)
915 {
916     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
917         return willReceiveResourceResponseImpl(*instrumentingAgents);
918     return InspectorInstrumentationCookie();
919 }
920
921 inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
922 {
923     // Call this unconditionally so that we're able to log to console with no front-end attached.
924     if (cookie.isValid())
925         didReceiveResourceResponseImpl(cookie, identifier, loader, response, resourceLoader);
926 }
927
928 inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
929 {
930     FAST_RETURN_IF_NO_FRONTENDS(void());
931     InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl(frame, loader, identifier, r);
932 }
933
934 inline void InspectorInstrumentation::continueWithPolicyDownload(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
935 {
936     FAST_RETURN_IF_NO_FRONTENDS(void());
937     InspectorInstrumentation::continueWithPolicyDownloadImpl(frame, loader, identifier, r);
938 }
939
940 inline void InspectorInstrumentation::continueWithPolicyIgnore(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
941 {
942     FAST_RETURN_IF_NO_FRONTENDS(void());
943     InspectorInstrumentation::continueWithPolicyIgnoreImpl(frame, loader, identifier, r);
944 }
945
946 inline void InspectorInstrumentation::didReceiveData(Frame* frame, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
947 {
948     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
949         didReceiveDataImpl(*instrumentingAgents, identifier, data, dataLength, encodedDataLength);
950 }
951
952 inline void InspectorInstrumentation::didFinishLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, double finishTime)
953 {
954     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
955         didFinishLoadingImpl(*instrumentingAgents, identifier, loader, finishTime);
956 }
957
958 inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
959 {
960     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
961         didFailLoadingImpl(*instrumentingAgents, identifier, loader, error);
962 }
963
964 inline void InspectorInstrumentation::didFinishXHRLoading(ScriptExecutionContext* context, ThreadableLoaderClient* client, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber)
965 {
966     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
967         didFinishXHRLoadingImpl(*instrumentingAgents, client, identifier, sourceString, url, sendURL, sendLineNumber, sendColumnNumber);
968 }
969
970 inline void InspectorInstrumentation::didReceiveXHRResponse(ScriptExecutionContext* context, unsigned long identifier)
971 {
972     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
973         didReceiveXHRResponseImpl(*instrumentingAgents, identifier);
974 }
975
976 inline void InspectorInstrumentation::willLoadXHRSynchronously(ScriptExecutionContext* context)
977 {
978     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
979         willLoadXHRSynchronouslyImpl(*instrumentingAgents);
980 }
981
982 inline void InspectorInstrumentation::didLoadXHRSynchronously(ScriptExecutionContext* context)
983 {
984     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
985         didLoadXHRSynchronouslyImpl(*instrumentingAgents);
986 }
987
988 inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext* context, unsigned long identifier, const String& sourceString)
989 {
990     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
991         scriptImportedImpl(*instrumentingAgents, identifier, sourceString);
992 }
993
994 inline void InspectorInstrumentation::scriptExecutionBlockedByCSP(ScriptExecutionContext* context, const String& directiveText)
995 {
996     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
997         scriptExecutionBlockedByCSPImpl(*instrumentingAgents, directiveText);
998 }
999
1000 inline void InspectorInstrumentation::didReceiveScriptResponse(ScriptExecutionContext* context, unsigned long identifier)
1001 {
1002     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1003         didReceiveScriptResponseImpl(*instrumentingAgents, identifier);
1004 }
1005
1006 inline void InspectorInstrumentation::domContentLoadedEventFired(Frame& frame)
1007 {
1008     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1009         domContentLoadedEventFiredImpl(*instrumentingAgents, frame);
1010 }
1011
1012 inline void InspectorInstrumentation::loadEventFired(Frame* frame)
1013 {
1014     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1015         loadEventFiredImpl(*instrumentingAgents, frame);
1016 }
1017
1018 inline void InspectorInstrumentation::frameDetachedFromParent(Frame& frame)
1019 {
1020     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1021         frameDetachedFromParentImpl(*instrumentingAgents, frame);
1022 }
1023
1024 inline void InspectorInstrumentation::didCommitLoad(Frame& frame, DocumentLoader* loader)
1025 {
1026     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1027         didCommitLoadImpl(*instrumentingAgents, frame.page(), loader);
1028 }
1029
1030 inline void InspectorInstrumentation::frameDocumentUpdated(Frame* frame)
1031 {
1032     FAST_RETURN_IF_NO_FRONTENDS(void());
1033     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1034         frameDocumentUpdatedImpl(*instrumentingAgents, frame);
1035 }
1036
1037 inline void InspectorInstrumentation::loaderDetachedFromFrame(Frame& frame, DocumentLoader& loader)
1038 {
1039     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1040         loaderDetachedFromFrameImpl(*instrumentingAgents, loader);
1041 }
1042
1043 inline void InspectorInstrumentation::frameStartedLoading(Frame& frame)
1044 {
1045     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(&frame))
1046         frameStartedLoadingImpl(*instrumentingAgents, frame);
1047 }
1048
1049 inline void InspectorInstrumentation::frameStoppedLoading(Frame& frame)
1050 {
1051     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(&frame))
1052         frameStoppedLoadingImpl(*instrumentingAgents, frame);
1053 }
1054
1055 inline void InspectorInstrumentation::frameScheduledNavigation(Frame& frame, double delay)
1056 {
1057     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(&frame))
1058         frameScheduledNavigationImpl(*instrumentingAgents, frame, delay);
1059 }
1060
1061 inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame& frame)
1062 {
1063     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(&frame))
1064         frameClearedScheduledNavigationImpl(*instrumentingAgents, frame);
1065 }
1066
1067 inline InspectorInstrumentationCookie InspectorInstrumentation::willRunJavaScriptDialog(Page& page, const String& message)
1068 {
1069     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1070     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1071         return willRunJavaScriptDialogImpl(*instrumentingAgents, message);
1072     return InspectorInstrumentationCookie();
1073 }
1074
1075 inline void InspectorInstrumentation::didRunJavaScriptDialog(const InspectorInstrumentationCookie& cookie)
1076 {
1077     FAST_RETURN_IF_NO_FRONTENDS(void());
1078     if (cookie.isValid())
1079         didRunJavaScriptDialogImpl(cookie);
1080 }
1081
1082 inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource& cachedResource)
1083 {
1084     FAST_RETURN_IF_NO_FRONTENDS(void());
1085     willDestroyCachedResourceImpl(cachedResource);
1086 }
1087
1088 inline InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTML(Document* document, unsigned startLine)
1089 {
1090     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1091     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1092         return willWriteHTMLImpl(*instrumentingAgents, startLine, document->frame());
1093     return InspectorInstrumentationCookie();
1094 }
1095
1096 inline void InspectorInstrumentation::didWriteHTML(const InspectorInstrumentationCookie& cookie, unsigned endLine)
1097 {
1098     FAST_RETURN_IF_NO_FRONTENDS(void());
1099     if (cookie.isValid())
1100         didWriteHTMLImpl(cookie, endLine);
1101 }
1102
1103 inline void InspectorInstrumentation::didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin, Page* page)
1104 {
1105     FAST_RETURN_IF_NO_FRONTENDS(void());
1106     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1107         didDispatchDOMStorageEventImpl(*instrumentingAgents, key, oldValue, newValue, storageType, securityOrigin, page);
1108 }
1109
1110 inline bool InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(ScriptExecutionContext* context)
1111 {
1112     FAST_RETURN_IF_NO_FRONTENDS(false);
1113     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1114         return shouldPauseDedicatedWorkerOnStartImpl(*instrumentingAgents);
1115     return false;
1116 }
1117
1118 inline void InspectorInstrumentation::didStartWorkerGlobalScope(ScriptExecutionContext* context, WorkerGlobalScopeProxy* proxy, const URL& url)
1119 {
1120     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1121         didStartWorkerGlobalScopeImpl(*instrumentingAgents, proxy, url);
1122 }
1123
1124 inline void InspectorInstrumentation::workerGlobalScopeTerminated(ScriptExecutionContext* context, WorkerGlobalScopeProxy* proxy)
1125 {
1126     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1127         workerGlobalScopeTerminatedImpl(*instrumentingAgents, proxy);
1128 }
1129
1130 #if ENABLE(WEB_SOCKETS)
1131 inline void InspectorInstrumentation::didCreateWebSocket(Document* document, unsigned long identifier, const URL& requestURL, const URL& documentURL, const String& protocol)
1132 {
1133     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1134         didCreateWebSocketImpl(*instrumentingAgents, identifier, requestURL, documentURL, protocol, document);
1135 }
1136
1137 inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(Document* document, unsigned long identifier, const ResourceRequest& request)
1138 {
1139     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1140         willSendWebSocketHandshakeRequestImpl(*instrumentingAgents, identifier, request, document);
1141 }
1142
1143 inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(Document* document, unsigned long identifier, const ResourceResponse& response)
1144 {
1145     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1146         didReceiveWebSocketHandshakeResponseImpl(*instrumentingAgents, identifier, response, document);
1147 }
1148
1149 inline void InspectorInstrumentation::didCloseWebSocket(Document* document, unsigned long identifier)
1150 {
1151     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1152         didCloseWebSocketImpl(*instrumentingAgents, identifier, document);
1153 }
1154
1155 inline void InspectorInstrumentation::didReceiveWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1156 {
1157     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1158         didReceiveWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1159 }
1160
1161 inline void InspectorInstrumentation::didReceiveWebSocketFrameError(Document* document, unsigned long identifier, const String& errorMessage)
1162 {
1163     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1164         didReceiveWebSocketFrameErrorImpl(*instrumentingAgents, identifier, errorMessage);
1165 }
1166
1167 inline void InspectorInstrumentation::didSendWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1168 {
1169     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1170         didSendWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1171 }
1172 #endif // ENABLE(WEB_SOCKETS)
1173
1174 inline void InspectorInstrumentation::didCreateCSSCanvas(HTMLCanvasElement& canvasElement, const String& name)
1175 {
1176 #if ENABLE(INSPECTOR)
1177     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document()))
1178         didCreateCSSCanvasImpl(instrumentingAgents, canvasElement, name);
1179 #else
1180     UNUSED_PARAM(canvasElement);
1181     UNUSED_PARAM(name);
1182 #endif
1183 }
1184
1185 inline void InspectorInstrumentation::didCreateCanvasRenderingContext(HTMLCanvasElement& canvasElement)
1186 {
1187 #if ENABLE(INSPECTOR)
1188     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document()))
1189         didCreateCanvasRenderingContextImpl(instrumentingAgents, canvasElement);
1190 #else
1191     UNUSED_PARAM(canvasElement);
1192 #endif
1193 }
1194
1195 #if ENABLE(WEBGL)
1196 inline void InspectorInstrumentation::didAttachShader(WebGLRenderingContextBase& context, WebGLProgram& program, WebGLShader& shader)
1197 {
1198 #if ENABLE(INSPECTOR)
1199     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderingContext(&context))
1200         didAttachShaderImpl(instrumentingAgents, context, program, shader);
1201 #else
1202     UNUSED_PARAM(context);
1203     UNUSED_PARAM(program);
1204     UNUSED_PARAM(shader);
1205 #endif
1206 }
1207
1208 inline void InspectorInstrumentation::didDetachShader(WebGLRenderingContextBase& context, WebGLProgram& program, WebGLShader& shader)
1209 {
1210 #if ENABLE(INSPECTOR)
1211     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderingContext(&context))
1212         didDetachShaderImpl(instrumentingAgents, context, program, shader);
1213 #else
1214     UNUSED_PARAM(context);
1215     UNUSED_PARAM(program);
1216     UNUSED_PARAM(shader);
1217 #endif
1218 }
1219
1220 inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
1221 {
1222 #if ENABLE(INSPECTOR)
1223     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderingContext(&context))
1224         didCreateProgramImpl(instrumentingAgents, context, program);
1225 #else
1226     UNUSED_PARAM(context);
1227     UNUSED_PARAM(program);
1228 #endif
1229 }
1230
1231 inline void InspectorInstrumentation::didDeleteProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
1232 {
1233 #if ENABLE(INSPECTOR)
1234     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderingContext(&context))
1235         didDeleteProgramImpl(instrumentingAgents, context, program);
1236 #else
1237     UNUSED_PARAM(context);
1238     UNUSED_PARAM(program);
1239 #endif
1240 }
1241 #endif
1242
1243 #if ENABLE(WEB_REPLAY)
1244 inline void InspectorInstrumentation::sessionCreated(Page& page, RefPtr<ReplaySession>&& session)
1245 {
1246     FAST_RETURN_IF_NO_FRONTENDS(void());
1247     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1248         sessionCreatedImpl(*instrumentingAgents, WTF::move(session));
1249 }
1250
1251 inline void InspectorInstrumentation::sessionLoaded(Page& page, RefPtr<ReplaySession>&& session)
1252 {
1253     FAST_RETURN_IF_NO_FRONTENDS(void());
1254     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1255         sessionLoadedImpl(*instrumentingAgents, WTF::move(session));
1256 }
1257
1258 inline void InspectorInstrumentation::sessionModified(Page& page, RefPtr<ReplaySession>&& session)
1259 {
1260     FAST_RETURN_IF_NO_FRONTENDS(void());
1261     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1262         sessionModifiedImpl(*instrumentingAgents, WTF::move(session));
1263 }
1264
1265 inline void InspectorInstrumentation::segmentCreated(Page& page, RefPtr<ReplaySessionSegment>&& segment)
1266 {
1267     FAST_RETURN_IF_NO_FRONTENDS(void());
1268     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1269         segmentCreatedImpl(*instrumentingAgents, WTF::move(segment));
1270 }
1271
1272 inline void InspectorInstrumentation::segmentCompleted(Page& page, RefPtr<ReplaySessionSegment>&& segment)
1273 {
1274     FAST_RETURN_IF_NO_FRONTENDS(void());
1275     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1276         segmentCompletedImpl(*instrumentingAgents, WTF::move(segment));
1277 }
1278
1279 inline void InspectorInstrumentation::segmentLoaded(Page& page, RefPtr<ReplaySessionSegment>&& segment)
1280 {
1281     FAST_RETURN_IF_NO_FRONTENDS(void());
1282     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1283         segmentLoadedImpl(*instrumentingAgents, WTF::move(segment));
1284 }
1285
1286 inline void InspectorInstrumentation::segmentUnloaded(Page& page)
1287 {
1288     FAST_RETURN_IF_NO_FRONTENDS(void());
1289     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1290         segmentUnloadedImpl(*instrumentingAgents);
1291 }
1292
1293 inline void InspectorInstrumentation::captureStarted(Page& page)
1294 {
1295     FAST_RETURN_IF_NO_FRONTENDS(void());
1296     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1297         captureStartedImpl(*instrumentingAgents);
1298 }
1299
1300 inline void InspectorInstrumentation::captureStopped(Page& page)
1301 {
1302     FAST_RETURN_IF_NO_FRONTENDS(void());
1303     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1304         captureStoppedImpl(*instrumentingAgents);
1305 }
1306
1307 inline void InspectorInstrumentation::playbackStarted(Page& page)
1308 {
1309     FAST_RETURN_IF_NO_FRONTENDS(void());
1310     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1311         playbackStartedImpl(*instrumentingAgents);
1312 }
1313
1314 inline void InspectorInstrumentation::playbackPaused(Page& page, const ReplayPosition& position)
1315 {
1316     FAST_RETURN_IF_NO_FRONTENDS(void());
1317     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1318         playbackPausedImpl(*instrumentingAgents, position);
1319 }
1320
1321 inline void InspectorInstrumentation::playbackFinished(Page& page)
1322 {
1323     FAST_RETURN_IF_NO_FRONTENDS(void());
1324     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1325         playbackFinishedImpl(*instrumentingAgents);
1326 }
1327
1328 inline void InspectorInstrumentation::playbackHitPosition(Page& page, const ReplayPosition& position)
1329 {
1330     FAST_RETURN_IF_NO_FRONTENDS(void());
1331     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1332         playbackHitPositionImpl(*instrumentingAgents, position);
1333 }
1334 #endif // ENABLE(WEB_REPLAY)
1335
1336 inline void InspectorInstrumentation::networkStateChanged(Page* page)
1337 {
1338     FAST_RETURN_IF_NO_FRONTENDS(void());
1339     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1340         networkStateChangedImpl(*instrumentingAgents);
1341 }
1342
1343 inline void InspectorInstrumentation::updateApplicationCacheStatus(Frame* frame)
1344 {
1345     FAST_RETURN_IF_NO_FRONTENDS(void());
1346     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1347         updateApplicationCacheStatusImpl(*instrumentingAgents, frame);
1348 }
1349
1350 inline void InspectorInstrumentation::didRequestAnimationFrame(Document* document, int callbackId)
1351 {
1352     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1353         didRequestAnimationFrameImpl(*instrumentingAgents, callbackId, document->frame());
1354 }
1355
1356 inline void InspectorInstrumentation::didCancelAnimationFrame(Document* document, int callbackId)
1357 {
1358     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1359         didCancelAnimationFrameImpl(*instrumentingAgents, callbackId, document->frame());
1360 }
1361
1362 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrame(Document* document, int callbackId)
1363 {
1364     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1365         return willFireAnimationFrameImpl(*instrumentingAgents, callbackId, document->frame());
1366     return InspectorInstrumentationCookie();
1367 }
1368
1369 inline void InspectorInstrumentation::didFireAnimationFrame(const InspectorInstrumentationCookie& cookie)
1370 {
1371     FAST_RETURN_IF_NO_FRONTENDS(void());
1372     if (cookie.isValid())
1373         didFireAnimationFrameImpl(cookie);
1374 }
1375
1376 inline void InspectorInstrumentation::layerTreeDidChange(Page* page)
1377 {
1378     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1379         layerTreeDidChangeImpl(*instrumentingAgents);
1380 }
1381
1382 inline void InspectorInstrumentation::renderLayerDestroyed(Page* page, const RenderLayer& renderLayer)
1383 {
1384     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1385         renderLayerDestroyedImpl(*instrumentingAgents, renderLayer);
1386 }
1387
1388 inline void InspectorInstrumentation::pseudoElementDestroyed(Page* page, PseudoElement& pseudoElement)
1389 {
1390     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1391         pseudoElementDestroyedImpl(*instrumentingAgents, pseudoElement);
1392 }
1393
1394 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext* context)
1395 {
1396     if (!context)
1397         return nullptr;
1398     if (is<Document>(*context))
1399         return instrumentingAgentsForPage(downcast<Document>(context)->page());
1400     return instrumentingAgentsForNonDocumentContext(context);
1401 }
1402
1403 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(Frame* frame)
1404 {
1405     return frame ? instrumentingAgentsForFrame(*frame) : nullptr;
1406 }
1407
1408 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(Frame& frame)
1409 {
1410     return instrumentingAgentsForPage(frame.page());
1411 }
1412
1413 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document* document)
1414 {
1415     return document ? instrumentingAgentsForDocument(*document) : nullptr;
1416 }
1417
1418 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document& document)
1419 {
1420     Page* page = document.page();
1421 #if ENABLE(TEMPLATE_ELEMENT)
1422     if (!page && document.templateDocumentHost())
1423         page = document.templateDocumentHost()->page();
1424 #endif
1425     return instrumentingAgentsForPage(page);
1426 }
1427
1428 } // namespace WebCore
1429
1430 #endif // !defined(InspectorInstrumentation_h)