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