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