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