Web Inspector: Canvas: show WebGPU shader pipelines
[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 "CallTracerTypes.h"
36 #include "CanvasBase.h"
37 #include "CanvasRenderingContext.h"
38 #include "Database.h"
39 #include "DocumentThreadableLoader.h"
40 #include "Element.h"
41 #include "EventTarget.h"
42 #include "FormData.h"
43 #include "Frame.h"
44 #include "HitTestResult.h"
45 #include "InspectorController.h"
46 #include "InspectorInstrumentationCookie.h"
47 #include "InspectorInstrumentationPublic.h"
48 #include "OffscreenCanvas.h"
49 #include "Page.h"
50 #include "StorageArea.h"
51 #include "WorkerGlobalScope.h"
52 #include "WorkerInspectorController.h"
53 #include <JavaScriptCore/JSCInlines.h>
54 #include <initializer_list>
55 #include <wtf/CompletionHandler.h>
56 #include <wtf/MemoryPressureHandler.h>
57 #include <wtf/RefPtr.h>
58
59 #if ENABLE(WEBGL)
60 #include "WebGLRenderingContextBase.h"
61 #endif
62
63 #if ENABLE(WEBGPU)
64 #include "GPUCanvasContext.h"
65 #include "WebGPUDevice.h"
66 #include "WebGPUPipeline.h"
67 #endif
68
69 namespace Inspector {
70 class ConsoleMessage;
71 class ScriptArguments;
72 class ScriptCallStack;
73 }
74
75 namespace WebCore {
76
77 class CachedResource;
78 class CharacterData;
79 class DOMWindow;
80 class DOMWrapperWorld;
81 class Document;
82 class DocumentLoader;
83 class EventListener;
84 class HTTPHeaderMap;
85 class InspectorTimelineAgent;
86 class InstrumentingAgents;
87 class NetworkLoadMetrics;
88 class Node;
89 class PseudoElement;
90 class RegisteredEventListener;
91 class RenderLayer;
92 class RenderObject;
93 class ResourceLoader;
94 class ResourceRequest;
95 class ResourceResponse;
96 class ScriptExecutionContext;
97 class SecurityOrigin;
98 class ShadowRoot;
99 class SharedBuffer;
100 class TimerBase;
101 class WebKitNamedFlow;
102 class WorkerInspectorProxy;
103
104 #if ENABLE(WEBGL)
105 class WebGLProgram;
106 #endif
107
108 #if ENABLE(WEBGPU)
109 class WebGPUSwapChain;
110 #endif
111
112 enum class StorageType;
113
114 struct WebSocketFrame;
115
116 class InspectorInstrumentation {
117 public:
118     static void didClearWindowObjectInWorld(Frame&, DOMWrapperWorld&);
119     static bool isDebuggerPaused(Frame*);
120
121     static int identifierForNode(Node&);
122     static void addEventListenersToNode(Node&);
123     static void willInsertDOMNode(Document&, Node& parent);
124     static void didInsertDOMNode(Document&, Node&);
125     static void willRemoveDOMNode(Document&, Node&);
126     static void didRemoveDOMNode(Document&, Node&);
127     static void willModifyDOMAttr(Document&, Element&, const AtomString& oldValue, const AtomString& newValue);
128     static void didModifyDOMAttr(Document&, Element&, const AtomString& name, const AtomString& value);
129     static void didRemoveDOMAttr(Document&, Element&, const AtomString& name);
130     static void characterDataModified(Document&, CharacterData&);
131     static void willInvalidateStyleAttr(Element&);
132     static void didInvalidateStyleAttr(Element&);
133     static void documentDetached(Document&);
134     static void frameWindowDiscarded(Frame&, DOMWindow*);
135     static void mediaQueryResultChanged(Document&);
136     static void activeStyleSheetsUpdated(Document&);
137     static void didPushShadowRoot(Element& host, ShadowRoot&);
138     static void willPopShadowRoot(Element& host, ShadowRoot&);
139     static void didChangeCustomElementState(Element&);
140     static void pseudoElementCreated(Page*, PseudoElement&);
141     static void pseudoElementDestroyed(Page*, PseudoElement&);
142     static void didCreateNamedFlow(Document*, WebKitNamedFlow&);
143     static void willRemoveNamedFlow(Document*, WebKitNamedFlow&);
144     static void didChangeRegionOverset(Document&, WebKitNamedFlow&);
145     static void didRegisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
146     static void didUnregisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement);
147
148     static void mouseDidMoveOverElement(Page&, const HitTestResult&, unsigned modifierFlags);
149     static bool handleMousePress(Frame&);
150     static bool handleTouchEvent(Frame&, Node&);
151     static bool forcePseudoState(const Element&, CSSSelector::PseudoClassType);
152
153     static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
154     static void willFetch(ScriptExecutionContext&, const String& url);
155     static void didInstallTimer(ScriptExecutionContext&, int timerId, Seconds timeout, bool singleShot);
156     static void didRemoveTimer(ScriptExecutionContext&, int timerId);
157
158     static void didPostMessage(Frame&, TimerBase&, JSC::ExecState&);
159     static void didFailPostMessage(Frame&, TimerBase&);
160     static void willDispatchPostMessage(Frame&, TimerBase&);
161     static void didDispatchPostMessage(Frame&, TimerBase&);
162
163     static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine, int scriptColumn);
164     static void didCallFunction(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
165     static void didAddEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
166     static void willRemoveEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
167     static bool isEventListenerDisabled(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
168     static InspectorInstrumentationCookie willDispatchEvent(Document&, const Event&, bool hasEventListeners);
169     static void didDispatchEvent(const InspectorInstrumentationCookie&, bool defaultPrevented);
170     static void willHandleEvent(ScriptExecutionContext&, Event&, const RegisteredEventListener&);
171     static void didHandleEvent(ScriptExecutionContext&);
172     static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event&, DOMWindow&);
173     static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&, bool defaultPrevented);
174     static void eventDidResetAfterDispatch(const Event&);
175     static InspectorInstrumentationCookie willEvaluateScript(Frame&, const String& url, int lineNumber, int columnNumber);
176     static void didEvaluateScript(const InspectorInstrumentationCookie&, Frame&);
177     static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext&, int timerId, bool oneShot);
178     static void didFireTimer(const InspectorInstrumentationCookie&);
179     static void didInvalidateLayout(Frame&);
180     static InspectorInstrumentationCookie willLayout(Frame&);
181     static void didLayout(const InspectorInstrumentationCookie&, RenderObject&);
182     static void didScroll(Page&);
183     static void willComposite(Frame&);
184     static void didComposite(Frame&);
185     static void willPaint(RenderObject&);
186     static void didPaint(RenderObject&, const LayoutRect&);
187     static InspectorInstrumentationCookie willRecalculateStyle(Document&);
188     static void didRecalculateStyle(const InspectorInstrumentationCookie&);
189     static void didScheduleStyleRecalculation(Document&);
190     static void applyUserAgentOverride(Frame&, String&);
191     static void applyEmulatedMedia(Frame&, String&);
192
193     static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
194     static void didLoadResourceFromMemoryCache(Page&, DocumentLoader*, CachedResource*);
195     static void didReceiveResourceResponse(Frame&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
196     static void didReceiveThreadableLoaderResponse(DocumentThreadableLoader&, unsigned long identifier);
197     static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
198     static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, const NetworkLoadMetrics&, ResourceLoader*);
199     static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
200
201     static void willSendRequest(WorkerGlobalScope&, unsigned long identifier, ResourceRequest&);
202     static void didReceiveResourceResponse(WorkerGlobalScope&, unsigned long identifier, const ResourceResponse&);
203     static void didReceiveData(WorkerGlobalScope&, unsigned long identifier, const char* data, int dataLength);
204     static void didFinishLoading(WorkerGlobalScope&, unsigned long identifier, const NetworkLoadMetrics&);
205     static void didFailLoading(WorkerGlobalScope&, unsigned long identifier, const ResourceError&);
206
207     // Some network requests do not go through the normal network loading path.
208     // These network requests have to issue their own willSendRequest / didReceiveResponse / didFinishLoading / didFailLoading
209     // instrumentation calls. Some of these loads are for resources that lack a CachedResource::Type.
210     enum class LoadType { Ping, Beacon };
211     static void willSendRequestOfType(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
212
213     static void continueAfterXFrameOptionsDenied(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
214     static void continueWithPolicyDownload(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
215     static void continueWithPolicyIgnore(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
216     static void willLoadXHRSynchronously(ScriptExecutionContext*);
217     static void didLoadXHRSynchronously(ScriptExecutionContext*);
218     static void scriptImported(ScriptExecutionContext&, unsigned long identifier, const String& sourceString);
219     static void scriptExecutionBlockedByCSP(ScriptExecutionContext*, const String& directiveText);
220     static void didReceiveScriptResponse(ScriptExecutionContext*, unsigned long identifier);
221     static void domContentLoadedEventFired(Frame&);
222     static void loadEventFired(Frame*);
223     static void frameDetachedFromParent(Frame&);
224     static void didCommitLoad(Frame&, DocumentLoader*);
225     static void frameDocumentUpdated(Frame&);
226     static void loaderDetachedFromFrame(Frame&, DocumentLoader&);
227     static void frameStartedLoading(Frame&);
228     static void frameStoppedLoading(Frame&);
229     static void frameScheduledNavigation(Frame&, Seconds delay);
230     static void frameClearedScheduledNavigation(Frame&);
231     static void defaultAppearanceDidChange(Page&, bool useDarkAppearance);
232     static void willDestroyCachedResource(CachedResource&);
233
234     static bool willInterceptRequest(const Frame*, const ResourceRequest&);
235     static bool shouldInterceptResponse(const Frame&, const ResourceResponse&);
236     static void interceptResponse(const Frame&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
237
238     static void addMessageToConsole(Page&, std::unique_ptr<Inspector::ConsoleMessage>);
239     static void addMessageToConsole(WorkerGlobalScope&, std::unique_ptr<Inspector::ConsoleMessage>);
240
241     static void consoleCount(Page&, JSC::ExecState*, const String& label);
242     static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, const String& label);
243     static void consoleCountReset(Page&, JSC::ExecState*, const String& label);
244     static void consoleCountReset(WorkerGlobalScope&, JSC::ExecState*, const String& label);
245
246     static void takeHeapSnapshot(Frame&, const String& title);
247     static void startConsoleTiming(Frame&, JSC::ExecState*, const String& label);
248     static void startConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label);
249     static void logConsoleTiming(Frame&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
250     static void logConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
251     static void stopConsoleTiming(Frame&, JSC::ExecState*, const String& label);
252     static void stopConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label);
253     static void consoleTimeStamp(Frame&, Ref<Inspector::ScriptArguments>&&);
254     static void startProfiling(Page&, JSC::ExecState*, const String& title);
255     static void stopProfiling(Page&, JSC::ExecState*, const String& title);
256     static void consoleStartRecordingCanvas(CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
257
258     static void didRequestAnimationFrame(Document&, int callbackId);
259     static void didCancelAnimationFrame(Document&, int callbackId);
260     static InspectorInstrumentationCookie willFireAnimationFrame(Document&, int callbackId);
261     static void didFireAnimationFrame(const InspectorInstrumentationCookie&);
262
263     static InspectorInstrumentationCookie willFireObserverCallback(ScriptExecutionContext&, const String& callbackType);
264     static void didFireObserverCallback(const InspectorInstrumentationCookie&);
265
266     static void didOpenDatabase(Database&);
267
268     static void didDispatchDOMStorageEvent(Page&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
269
270     static bool shouldWaitForDebuggerOnStart(ScriptExecutionContext&);
271     static void workerStarted(ScriptExecutionContext&, WorkerInspectorProxy*, const URL&);
272     static void workerTerminated(ScriptExecutionContext&, WorkerInspectorProxy*);
273
274     static void didCreateWebSocket(Document*, unsigned long identifier, const URL& requestURL);
275     static void willSendWebSocketHandshakeRequest(Document*, unsigned long identifier, const ResourceRequest&);
276     static void didReceiveWebSocketHandshakeResponse(Document*, unsigned long identifier, const ResourceResponse&);
277     static void didCloseWebSocket(Document*, unsigned long identifier);
278     static void didReceiveWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
279     static void didSendWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
280     static void didReceiveWebSocketFrameError(Document*, unsigned long identifier, const String& errorMessage);
281
282 #if ENABLE(RESOURCE_USAGE)
283     static void didHandleMemoryPressure(Page&, Critical);
284 #endif
285
286     static void didChangeCSSCanvasClientNodes(CanvasBase&);
287     static void didCreateCanvasRenderingContext(CanvasRenderingContext&);
288     static void didChangeCanvasMemory(CanvasRenderingContext&);
289     static void recordCanvasAction(CanvasRenderingContext&, const String&, std::initializer_list<RecordCanvasActionVariant>&& = { });
290     static void didFinishRecordingCanvasFrame(CanvasRenderingContext&, bool forceDispatch = false);
291 #if ENABLE(WEBGL)
292     static void didEnableExtension(WebGLRenderingContextBase&, const String&);
293     static void didCreateWebGLProgram(WebGLRenderingContextBase&, WebGLProgram&);
294     static void willDestroyWebGLProgram(WebGLProgram&);
295     static bool isWebGLProgramDisabled(WebGLRenderingContextBase&, WebGLProgram&);
296     static bool isWebGLProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&);
297 #endif
298 #if ENABLE(WEBGPU)
299     static void didCreateWebGPUDevice(WebGPUDevice&);
300     static void willDestroyWebGPUDevice(WebGPUDevice&);
301     static void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&);
302     static void didCreateWebGPUPipeline(WebGPUDevice&, WebGPUPipeline&);
303     static void willDestroyWebGPUPipeline(WebGPUPipeline&);
304 #endif
305
306     static void networkStateChanged(Page&);
307     static void updateApplicationCacheStatus(Frame*);
308
309     static void layerTreeDidChange(Page*);
310     static void renderLayerDestroyed(Page*, const RenderLayer&);
311
312     static void frontendCreated();
313     static void frontendDeleted();
314     static bool hasFrontends() { return InspectorInstrumentationPublic::hasFrontends(); }
315
316     static void firstFrontendCreated();
317     static void lastFrontendDeleted();
318
319     static bool consoleAgentEnabled(ScriptExecutionContext*);
320     static bool timelineAgentTracking(ScriptExecutionContext*);
321
322     static InstrumentingAgents* instrumentingAgentsForPage(Page*);
323
324     static void registerInstrumentingAgents(InstrumentingAgents&);
325     static void unregisterInstrumentingAgents(InstrumentingAgents&);
326
327 private:
328     static void didClearWindowObjectInWorldImpl(InstrumentingAgents&, Frame&, DOMWrapperWorld&);
329     static bool isDebuggerPausedImpl(InstrumentingAgents&);
330
331     static int identifierForNodeImpl(InstrumentingAgents&, Node&);
332     static void addEventListenersToNodeImpl(InstrumentingAgents&, Node&);
333     static void willInsertDOMNodeImpl(InstrumentingAgents&, Node& parent);
334     static void didInsertDOMNodeImpl(InstrumentingAgents&, Node&);
335     static void willRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
336     static void didRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
337     static void willModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& oldValue, const AtomString& newValue);
338     static void didModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& name, const AtomString& value);
339     static void didRemoveDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& name);
340     static void characterDataModifiedImpl(InstrumentingAgents&, CharacterData&);
341     static void willInvalidateStyleAttrImpl(InstrumentingAgents&, Element&);
342     static void didInvalidateStyleAttrImpl(InstrumentingAgents&, Element&);
343     static void documentDetachedImpl(InstrumentingAgents&, Document&);
344     static void frameWindowDiscardedImpl(InstrumentingAgents&, DOMWindow*);
345     static void mediaQueryResultChangedImpl(InstrumentingAgents&);
346     static void activeStyleSheetsUpdatedImpl(InstrumentingAgents&, Document&);
347     static void didPushShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
348     static void willPopShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
349     static void didChangeCustomElementStateImpl(InstrumentingAgents&, Element&);
350     static void pseudoElementCreatedImpl(InstrumentingAgents&, PseudoElement&);
351     static void pseudoElementDestroyedImpl(InstrumentingAgents&, PseudoElement&);
352     static void didCreateNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
353     static void willRemoveNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
354     static void didChangeRegionOversetImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&);
355     static void didRegisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
356     static void didUnregisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement);
357
358     static void mouseDidMoveOverElementImpl(InstrumentingAgents&, const HitTestResult&, unsigned modifierFlags);
359     static bool handleMousePressImpl(InstrumentingAgents&);
360     static bool handleTouchEventImpl(InstrumentingAgents&, Node&);
361     static bool forcePseudoStateImpl(InstrumentingAgents&, const Element&, CSSSelector::PseudoClassType);
362
363     static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url);
364     static void willFetchImpl(InstrumentingAgents&, const String& url);
365     static void didInstallTimerImpl(InstrumentingAgents&, int timerId, Seconds timeout, bool singleShot, ScriptExecutionContext&);
366     static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext&);
367
368     static void didPostMessageImpl(InstrumentingAgents&, const TimerBase&, JSC::ExecState&);
369     static void didFailPostMessageImpl(InstrumentingAgents&, const TimerBase&);
370     static void willDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&);
371     static void didDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&);
372
373     static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents&, const String& scriptName, int scriptLine, int scriptColumn, ScriptExecutionContext*);
374     static void didCallFunctionImpl(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
375     static void didAddEventListenerImpl(InstrumentingAgents&, EventTarget&, const AtomString& eventType, EventListener&, bool capture);
376     static void willRemoveEventListenerImpl(InstrumentingAgents&, EventTarget&, const AtomString& eventType, EventListener&, bool capture);
377     static bool isEventListenerDisabledImpl(InstrumentingAgents&, EventTarget&, const AtomString& eventType, EventListener&, bool capture);
378     static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents&, Document&, const Event&, bool hasEventListeners);
379     static void willHandleEventImpl(InstrumentingAgents&, Event&, const RegisteredEventListener&);
380     static void didHandleEventImpl(InstrumentingAgents&);
381     static void didDispatchEventImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
382     static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InstrumentingAgents&, const Event&, DOMWindow&);
383     static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
384     static void eventDidResetAfterDispatchImpl(InstrumentingAgents&, const Event&);
385     static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents&, Frame&, const String& url, int lineNumber, int columnNumber);
386     static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&, Frame&);
387     static InspectorInstrumentationCookie willFireTimerImpl(InstrumentingAgents&, int timerId, bool oneShot, ScriptExecutionContext&);
388     static void didFireTimerImpl(const InspectorInstrumentationCookie&);
389     static void didInvalidateLayoutImpl(InstrumentingAgents&, Frame&);
390     static InspectorInstrumentationCookie willLayoutImpl(InstrumentingAgents&, Frame&);
391     static void didLayoutImpl(const InspectorInstrumentationCookie&, RenderObject&);
392     static void didScrollImpl(InstrumentingAgents&);
393     static void willCompositeImpl(InstrumentingAgents&, Frame&);
394     static void didCompositeImpl(InstrumentingAgents&);
395     static void willPaintImpl(InstrumentingAgents&, RenderObject&);
396     static void didPaintImpl(InstrumentingAgents&, RenderObject&, const LayoutRect&);
397     static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents&, Document&);
398     static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
399     static void didScheduleStyleRecalculationImpl(InstrumentingAgents&, Document&);
400     static void applyUserAgentOverrideImpl(InstrumentingAgents&, String&);
401     static void applyEmulatedMediaImpl(InstrumentingAgents&, String&);
402
403     static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
404     static void willSendRequestOfTypeImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
405     static void markResourceAsCachedImpl(InstrumentingAgents&, unsigned long identifier);
406     static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents&, DocumentLoader*, CachedResource*);
407     static void didReceiveResourceResponseImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
408     static void didReceiveThreadableLoaderResponseImpl(InstrumentingAgents&, DocumentThreadableLoader&, unsigned long identifier);
409     static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
410     static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const NetworkLoadMetrics&, ResourceLoader*);
411     static void didFailLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceError&);
412     static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&);
413     static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&);
414     static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString);
415     static void scriptExecutionBlockedByCSPImpl(InstrumentingAgents&, const String& directiveText);
416     static void didReceiveScriptResponseImpl(InstrumentingAgents&, unsigned long identifier);
417     static void domContentLoadedEventFiredImpl(InstrumentingAgents&, Frame&);
418     static void loadEventFiredImpl(InstrumentingAgents&, Frame*);
419     static void frameDetachedFromParentImpl(InstrumentingAgents&, Frame&);
420     static void didCommitLoadImpl(InstrumentingAgents&, Frame&, DocumentLoader*);
421     static void frameDocumentUpdatedImpl(InstrumentingAgents&, Frame&);
422     static void loaderDetachedFromFrameImpl(InstrumentingAgents&, DocumentLoader&);
423     static void frameStartedLoadingImpl(InstrumentingAgents&, Frame&);
424     static void frameStoppedLoadingImpl(InstrumentingAgents&, Frame&);
425     static void frameScheduledNavigationImpl(InstrumentingAgents&, Frame&, Seconds delay);
426     static void frameClearedScheduledNavigationImpl(InstrumentingAgents&, Frame&);
427     static void defaultAppearanceDidChangeImpl(InstrumentingAgents&, bool useDarkAppearance);
428     static void willDestroyCachedResourceImpl(CachedResource&);
429
430     static bool willInterceptRequestImpl(InstrumentingAgents&, const ResourceRequest&);
431     static bool shouldInterceptResponseImpl(InstrumentingAgents&, const ResourceResponse&);
432     static void interceptResponseImpl(InstrumentingAgents&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
433
434     static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>);
435
436     static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
437     static void consoleCountResetImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
438     static void takeHeapSnapshotImpl(InstrumentingAgents&, const String& title);
439     static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label);
440     static void startConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
441     static void logConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
442     static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label);
443     static void stopConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
444     static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&);
445     static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
446     static void stopProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
447     static void consoleStartRecordingCanvasImpl(InstrumentingAgents&, CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
448
449     static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
450     static void didCancelAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
451     static InspectorInstrumentationCookie willFireAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
452     static void didFireAnimationFrameImpl(const InspectorInstrumentationCookie&);
453
454     static InspectorInstrumentationCookie willFireObserverCallbackImpl(InstrumentingAgents&, const String&, ScriptExecutionContext&);
455     static void didFireObserverCallbackImpl(const InspectorInstrumentationCookie&);
456
457     static void didOpenDatabaseImpl(InstrumentingAgents&, Database&);
458
459     static void didDispatchDOMStorageEventImpl(InstrumentingAgents&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
460
461     static bool shouldWaitForDebuggerOnStartImpl(InstrumentingAgents&);
462     static void workerStartedImpl(InstrumentingAgents&, WorkerInspectorProxy*, const URL&);
463     static void workerTerminatedImpl(InstrumentingAgents&, WorkerInspectorProxy*);
464
465     static void didCreateWebSocketImpl(InstrumentingAgents&, unsigned long identifier, const URL& requestURL);
466     static void willSendWebSocketHandshakeRequestImpl(InstrumentingAgents&, unsigned long identifier, const ResourceRequest&);
467     static void didReceiveWebSocketHandshakeResponseImpl(InstrumentingAgents&, unsigned long identifier, const ResourceResponse&);
468     static void didCloseWebSocketImpl(InstrumentingAgents&, unsigned long identifier);
469     static void didReceiveWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
470     static void didSendWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
471     static void didReceiveWebSocketFrameErrorImpl(InstrumentingAgents&, unsigned long identifier, const String&);
472
473 #if ENABLE(RESOURCE_USAGE)
474     static void didHandleMemoryPressureImpl(InstrumentingAgents&, Critical);
475 #endif
476
477     static void networkStateChangedImpl(InstrumentingAgents&);
478     static void updateApplicationCacheStatusImpl(InstrumentingAgents&, Frame&);
479
480     static void didChangeCSSCanvasClientNodesImpl(InstrumentingAgents&, CanvasBase&);
481     static void didCreateCanvasRenderingContextImpl(InstrumentingAgents&, CanvasRenderingContext&);
482     static void didChangeCanvasMemoryImpl(InstrumentingAgents&, CanvasRenderingContext&);
483     static void recordCanvasActionImpl(InstrumentingAgents&, CanvasRenderingContext&, const String&, std::initializer_list<RecordCanvasActionVariant>&& = { });
484     static void didFinishRecordingCanvasFrameImpl(InstrumentingAgents&, CanvasRenderingContext&, bool forceDispatch = false);
485 #if ENABLE(WEBGL)
486     static void didEnableExtensionImpl(InstrumentingAgents&, WebGLRenderingContextBase&, const String&);
487     static void didCreateWebGLProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);
488     static void willDestroyWebGLProgramImpl(InstrumentingAgents&, WebGLProgram&);
489     static bool isWebGLProgramDisabledImpl(InstrumentingAgents&, WebGLProgram&);
490     static bool isWebGLProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&);
491 #endif
492 #if ENABLE(WEBGPU)
493     static void didCreateWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&);
494     static void willDestroyWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&);
495     static void willConfigureSwapChainImpl(InstrumentingAgents&, GPUCanvasContext&, WebGPUSwapChain&);
496     static void didCreateWebGPUPipelineImpl(InstrumentingAgents&, WebGPUDevice&, WebGPUPipeline&);
497     static void willDestroyWebGPUPipelineImpl(InstrumentingAgents&, WebGPUPipeline&);
498 #endif
499
500     static void layerTreeDidChangeImpl(InstrumentingAgents&);
501     static void renderLayerDestroyedImpl(InstrumentingAgents&, const RenderLayer&);
502
503     static InstrumentingAgents& instrumentingAgentsForPage(Page&);
504     static InstrumentingAgents& instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope&);
505
506     static InstrumentingAgents* instrumentingAgentsForFrame(const Frame&);
507     static InstrumentingAgents* instrumentingAgentsForFrame(const Frame*);
508     static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext*);
509     static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext&);
510     static InstrumentingAgents* instrumentingAgentsForDocument(Document&);
511     static InstrumentingAgents* instrumentingAgentsForDocument(Document*);
512     static InstrumentingAgents* instrumentingAgentsForRenderer(RenderObject&);
513     static InstrumentingAgents* instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope*);
514
515     static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
516 };
517
518 inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld& world)
519 {
520     FAST_RETURN_IF_NO_FRONTENDS(void());
521     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
522         didClearWindowObjectInWorldImpl(*instrumentingAgents, frame, world);
523 }
524
525 inline bool InspectorInstrumentation::isDebuggerPaused(Frame* frame)
526 {
527     FAST_RETURN_IF_NO_FRONTENDS(false);
528     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
529         return isDebuggerPausedImpl(*instrumentingAgents);
530     return false;
531 }
532
533 inline int InspectorInstrumentation::identifierForNode(Node& node)
534 {
535     FAST_RETURN_IF_NO_FRONTENDS(0);
536     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(node.document()))
537         return identifierForNodeImpl(*instrumentingAgents, node);
538     return 0;
539 }
540
541 inline void InspectorInstrumentation::addEventListenersToNode(Node& node)
542 {
543     FAST_RETURN_IF_NO_FRONTENDS(void());
544     if (auto* instrumentingAgents = instrumentingAgentsForDocument(node.document()))
545         addEventListenersToNodeImpl(*instrumentingAgents, node);
546 }
547
548 inline void InspectorInstrumentation::willInsertDOMNode(Document& document, Node& parent)
549 {
550     FAST_RETURN_IF_NO_FRONTENDS(void());
551     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
552         willInsertDOMNodeImpl(*instrumentingAgents, parent);
553 }
554
555 inline void InspectorInstrumentation::didInsertDOMNode(Document& document, Node& node)
556 {
557     FAST_RETURN_IF_NO_FRONTENDS(void());
558     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
559         didInsertDOMNodeImpl(*instrumentingAgents, node);
560 }
561
562 inline void InspectorInstrumentation::willRemoveDOMNode(Document& document, Node& node)
563 {
564     FAST_RETURN_IF_NO_FRONTENDS(void());
565     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
566         willRemoveDOMNodeImpl(*instrumentingAgents, node);
567 }
568
569 inline void InspectorInstrumentation::didRemoveDOMNode(Document& document, Node& node)
570 {
571     FAST_RETURN_IF_NO_FRONTENDS(void());
572     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
573         didRemoveDOMNodeImpl(*instrumentingAgents, node);
574 }
575
576 inline void InspectorInstrumentation::willModifyDOMAttr(Document& document, Element& element, const AtomString& oldValue, const AtomString& newValue)
577 {
578     FAST_RETURN_IF_NO_FRONTENDS(void());
579     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
580         willModifyDOMAttrImpl(*instrumentingAgents, element, oldValue, newValue);
581 }
582
583 inline void InspectorInstrumentation::didModifyDOMAttr(Document& document, Element& element, const AtomString& name, const AtomString& value)
584 {
585     FAST_RETURN_IF_NO_FRONTENDS(void());
586     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
587         didModifyDOMAttrImpl(*instrumentingAgents, element, name, value);
588 }
589
590 inline void InspectorInstrumentation::didRemoveDOMAttr(Document& document, Element& element, const AtomString& name)
591 {
592     FAST_RETURN_IF_NO_FRONTENDS(void());
593     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
594         didRemoveDOMAttrImpl(*instrumentingAgents, element, name);
595 }
596
597 inline void InspectorInstrumentation::willInvalidateStyleAttr(Element& element)
598 {
599     FAST_RETURN_IF_NO_FRONTENDS(void());
600     if (auto* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
601         willInvalidateStyleAttrImpl(*instrumentingAgents, element);
602 }
603
604 inline void InspectorInstrumentation::didInvalidateStyleAttr(Element& element)
605 {
606     FAST_RETURN_IF_NO_FRONTENDS(void());
607     if (auto* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
608         didInvalidateStyleAttrImpl(*instrumentingAgents, element);
609 }
610
611 inline void InspectorInstrumentation::documentDetached(Document& document)
612 {
613     FAST_RETURN_IF_NO_FRONTENDS(void());
614     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
615         documentDetachedImpl(*instrumentingAgents, document);
616 }
617
618 inline void InspectorInstrumentation::frameWindowDiscarded(Frame& frame, DOMWindow* domWindow)
619 {
620     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
621         frameWindowDiscardedImpl(*instrumentingAgents, domWindow);
622 }
623
624 inline void InspectorInstrumentation::mediaQueryResultChanged(Document& document)
625 {
626     FAST_RETURN_IF_NO_FRONTENDS(void());
627     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
628         mediaQueryResultChangedImpl(*instrumentingAgents);
629 }
630
631 inline void InspectorInstrumentation::activeStyleSheetsUpdated(Document& document)
632 {
633     FAST_RETURN_IF_NO_FRONTENDS(void());
634     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
635         activeStyleSheetsUpdatedImpl(*instrumentingAgents, document);
636 }
637
638 inline void InspectorInstrumentation::didPushShadowRoot(Element& host, ShadowRoot& root)
639 {
640     FAST_RETURN_IF_NO_FRONTENDS(void());
641     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
642         didPushShadowRootImpl(*instrumentingAgents, host, root);
643 }
644
645 inline void InspectorInstrumentation::willPopShadowRoot(Element& host, ShadowRoot& root)
646 {
647     FAST_RETURN_IF_NO_FRONTENDS(void());
648     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
649         willPopShadowRootImpl(*instrumentingAgents, host, root);
650 }
651
652 inline void InspectorInstrumentation::didChangeCustomElementState(Element& element)
653 {
654     FAST_RETURN_IF_NO_FRONTENDS(void());
655     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
656         didChangeCustomElementStateImpl(*instrumentingAgents, element);
657 }
658
659 inline void InspectorInstrumentation::pseudoElementCreated(Page* page, PseudoElement& pseudoElement)
660 {
661     FAST_RETURN_IF_NO_FRONTENDS(void());
662     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
663         pseudoElementCreatedImpl(*instrumentingAgents, pseudoElement);
664 }
665
666 inline void InspectorInstrumentation::pseudoElementDestroyed(Page* page, PseudoElement& pseudoElement)
667 {
668     FAST_RETURN_IF_NO_FRONTENDS(void());
669     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
670         pseudoElementDestroyedImpl(*instrumentingAgents, pseudoElement);
671 }
672
673 inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
674 {
675     FAST_RETURN_IF_NO_FRONTENDS(void());
676     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
677         didCreateNamedFlowImpl(*instrumentingAgents, document, namedFlow);
678 }
679
680 inline void InspectorInstrumentation::willRemoveNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
681 {
682     FAST_RETURN_IF_NO_FRONTENDS(void());
683     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
684         willRemoveNamedFlowImpl(*instrumentingAgents, document, namedFlow);
685 }
686
687 inline void InspectorInstrumentation::didChangeRegionOverset(Document& document, WebKitNamedFlow& namedFlow)
688 {
689     FAST_RETURN_IF_NO_FRONTENDS(void());
690     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
691         didChangeRegionOversetImpl(*instrumentingAgents, document, namedFlow);
692 }
693
694 inline void InspectorInstrumentation::didRegisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement, Node* nextContentElement)
695 {
696     FAST_RETURN_IF_NO_FRONTENDS(void());
697     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
698         didRegisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement, nextContentElement);
699 }
700
701 inline void InspectorInstrumentation::didUnregisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement)
702 {
703     FAST_RETURN_IF_NO_FRONTENDS(void());
704     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
705         didUnregisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement);
706 }
707
708 inline void InspectorInstrumentation::mouseDidMoveOverElement(Page& page, const HitTestResult& result, unsigned modifierFlags)
709 {
710     FAST_RETURN_IF_NO_FRONTENDS(void());
711     mouseDidMoveOverElementImpl(instrumentingAgentsForPage(page), result, modifierFlags);
712 }
713
714 inline bool InspectorInstrumentation::handleTouchEvent(Frame& frame, Node& node)
715 {
716     FAST_RETURN_IF_NO_FRONTENDS(false);
717     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
718         return handleTouchEventImpl(*instrumentingAgents, node);
719     return false;
720 }
721
722 inline bool InspectorInstrumentation::handleMousePress(Frame& frame)
723 {
724     FAST_RETURN_IF_NO_FRONTENDS(false);
725     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
726         return handleMousePressImpl(*instrumentingAgents);
727     return false;
728 }
729
730 inline bool InspectorInstrumentation::forcePseudoState(const Element& element, CSSSelector::PseudoClassType pseudoState)
731 {
732     FAST_RETURN_IF_NO_FRONTENDS(false);
733     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
734         return forcePseudoStateImpl(*instrumentingAgents, element, pseudoState);
735     return false;
736 }
737
738 inline void InspectorInstrumentation::characterDataModified(Document& document, CharacterData& characterData)
739 {
740     FAST_RETURN_IF_NO_FRONTENDS(void());
741     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
742         characterDataModifiedImpl(*instrumentingAgents, characterData);
743 }
744
745 inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url)
746 {
747     FAST_RETURN_IF_NO_FRONTENDS(void());
748     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
749         willSendXMLHttpRequestImpl(*instrumentingAgents, url);
750 }
751
752 inline void InspectorInstrumentation::willFetch(ScriptExecutionContext& context, const String& url)
753 {
754     FAST_RETURN_IF_NO_FRONTENDS(void());
755     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
756         willFetchImpl(*instrumentingAgents, url);
757 }
758
759 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext& context, int timerId, Seconds timeout, bool singleShot)
760 {
761     FAST_RETURN_IF_NO_FRONTENDS(void());
762     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
763         didInstallTimerImpl(*instrumentingAgents, timerId, timeout, singleShot, context);
764 }
765
766 inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext& context, int timerId)
767 {
768     FAST_RETURN_IF_NO_FRONTENDS(void());
769     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
770         didRemoveTimerImpl(*instrumentingAgents, timerId, context);
771 }
772
773 inline void InspectorInstrumentation::didAddEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
774 {
775     FAST_RETURN_IF_NO_FRONTENDS(void());
776     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
777         didAddEventListenerImpl(*instrumentingAgents, target, eventType, listener, capture);
778 }
779
780 inline void InspectorInstrumentation::willRemoveEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
781 {
782     FAST_RETURN_IF_NO_FRONTENDS(void());
783     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
784         willRemoveEventListenerImpl(*instrumentingAgents, target, eventType, listener, capture);
785 }
786
787 inline bool InspectorInstrumentation::isEventListenerDisabled(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
788 {
789     FAST_RETURN_IF_NO_FRONTENDS(false);
790     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
791         return isEventListenerDisabledImpl(*instrumentingAgents, target, eventType, listener, capture);
792     return false;
793 }
794
795 inline void InspectorInstrumentation::didPostMessage(Frame& frame, TimerBase& timer, JSC::ExecState& state)
796 {
797     FAST_RETURN_IF_NO_FRONTENDS(void());
798     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
799         didPostMessageImpl(*instrumentingAgents, timer, state);
800 }
801
802 inline void InspectorInstrumentation::didFailPostMessage(Frame& frame, TimerBase& timer)
803 {
804     FAST_RETURN_IF_NO_FRONTENDS(void());
805     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
806         didFailPostMessageImpl(*instrumentingAgents, timer);
807 }
808
809 inline void InspectorInstrumentation::willDispatchPostMessage(Frame& frame, TimerBase& timer)
810 {
811     FAST_RETURN_IF_NO_FRONTENDS(void());
812     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
813         willDispatchPostMessageImpl(*instrumentingAgents, timer);
814 }
815
816 inline void InspectorInstrumentation::didDispatchPostMessage(Frame& frame, TimerBase& timer)
817 {
818     FAST_RETURN_IF_NO_FRONTENDS(void());
819     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
820         didDispatchPostMessageImpl(*instrumentingAgents, timer);
821 }
822
823 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(ScriptExecutionContext* context, const String& scriptName, int scriptLine, int scriptColumn)
824 {
825     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
826     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
827         return willCallFunctionImpl(*instrumentingAgents, scriptName, scriptLine, scriptColumn, context);
828     return InspectorInstrumentationCookie();
829 }
830
831 inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie, ScriptExecutionContext* context)
832 {
833     FAST_RETURN_IF_NO_FRONTENDS(void());
834     if (cookie.isValid())
835         didCallFunctionImpl(cookie, context);
836 }
837
838 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document& document, const Event& event, bool hasEventListeners)
839 {
840     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
841     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
842         return willDispatchEventImpl(*instrumentingAgents, document, event, hasEventListeners);
843     return InspectorInstrumentationCookie();
844 }
845
846 inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
847 {
848     FAST_RETURN_IF_NO_FRONTENDS(void());
849     if (cookie.isValid())
850         didDispatchEventImpl(cookie, defaultPrevented);
851 }
852
853 inline void InspectorInstrumentation::willHandleEvent(ScriptExecutionContext& context, Event& event, const RegisteredEventListener& listener)
854 {
855     FAST_RETURN_IF_NO_FRONTENDS(void());
856     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
857         return willHandleEventImpl(*instrumentingAgents, event, listener);
858 }
859
860 inline void InspectorInstrumentation::didHandleEvent(ScriptExecutionContext& context)
861 {
862     FAST_RETURN_IF_NO_FRONTENDS(void());
863     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
864         return didHandleEventImpl(*instrumentingAgents);
865 }
866
867 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindow(Frame* frame, const Event& event, DOMWindow& window)
868 {
869     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
870     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
871         return willDispatchEventOnWindowImpl(*instrumentingAgents, event, window);
872     return InspectorInstrumentationCookie();
873 }
874
875 inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
876 {
877     FAST_RETURN_IF_NO_FRONTENDS(void());
878     if (cookie.isValid())
879         didDispatchEventOnWindowImpl(cookie, defaultPrevented);
880 }
881
882 inline void InspectorInstrumentation::eventDidResetAfterDispatch(const Event& event)
883 {
884     FAST_RETURN_IF_NO_FRONTENDS(void());
885
886     if (!is<Node>(event.target()))
887         return;
888
889     auto* node = downcast<Node>(event.target());
890     if (auto* instrumentingAgents = instrumentingAgentsForContext(node->scriptExecutionContext()))
891         return eventDidResetAfterDispatchImpl(*instrumentingAgents, event);
892 }
893
894 inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame& frame, const String& url, int lineNumber, int columnNumber)
895 {
896     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
897     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
898         return willEvaluateScriptImpl(*instrumentingAgents, frame, url, lineNumber, columnNumber);
899     return InspectorInstrumentationCookie();
900 }
901
902 inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumentationCookie& cookie, Frame& frame)
903 {
904     FAST_RETURN_IF_NO_FRONTENDS(void());
905     if (cookie.isValid())
906         didEvaluateScriptImpl(cookie, frame);
907 }
908
909 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext& context, int timerId, bool oneShot)
910 {
911     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
912     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
913         return willFireTimerImpl(*instrumentingAgents, timerId, oneShot, context);
914     return InspectorInstrumentationCookie();
915 }
916
917 inline void InspectorInstrumentation::didFireTimer(const InspectorInstrumentationCookie& cookie)
918 {
919     FAST_RETURN_IF_NO_FRONTENDS(void());
920     if (cookie.isValid())
921         didFireTimerImpl(cookie);
922 }
923
924 inline void InspectorInstrumentation::didInvalidateLayout(Frame& frame)
925 {
926     FAST_RETURN_IF_NO_FRONTENDS(void());
927     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
928         didInvalidateLayoutImpl(*instrumentingAgents, frame);
929 }
930
931 inline InspectorInstrumentationCookie InspectorInstrumentation::willLayout(Frame& frame)
932 {
933     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
934     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
935         return willLayoutImpl(*instrumentingAgents, frame);
936     return InspectorInstrumentationCookie();
937 }
938
939 inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCookie& cookie, RenderObject& root)
940 {
941     FAST_RETURN_IF_NO_FRONTENDS(void());
942     if (cookie.isValid())
943         didLayoutImpl(cookie, root);
944 }
945
946 inline void InspectorInstrumentation::didScroll(Page& page)
947 {
948     FAST_RETURN_IF_NO_FRONTENDS(void());
949     didScrollImpl(instrumentingAgentsForPage(page));
950 }
951
952 inline void InspectorInstrumentation::willComposite(Frame& frame)
953 {
954     FAST_RETURN_IF_NO_FRONTENDS(void());
955     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
956         willCompositeImpl(*instrumentingAgents, frame);
957 }
958
959 inline void InspectorInstrumentation::didComposite(Frame& frame)
960 {
961     FAST_RETURN_IF_NO_FRONTENDS(void());
962     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
963         didCompositeImpl(*instrumentingAgents);
964 }
965
966 inline void InspectorInstrumentation::willPaint(RenderObject& renderer)
967 {
968     FAST_RETURN_IF_NO_FRONTENDS(void());
969     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
970         return willPaintImpl(*instrumentingAgents, renderer);
971 }
972
973 inline void InspectorInstrumentation::didPaint(RenderObject& renderer, const LayoutRect& rect)
974 {
975     FAST_RETURN_IF_NO_FRONTENDS(void());
976     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
977         didPaintImpl(*instrumentingAgents, renderer, rect);
978 }
979
980 inline InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyle(Document& document)
981 {
982     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
983     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
984         return willRecalculateStyleImpl(*instrumentingAgents, document);
985     return InspectorInstrumentationCookie();
986 }
987
988 inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrumentationCookie& cookie)
989 {
990     FAST_RETURN_IF_NO_FRONTENDS(void());
991     if (cookie.isValid())
992         didRecalculateStyleImpl(cookie);
993 }
994
995 inline void InspectorInstrumentation::didScheduleStyleRecalculation(Document& document)
996 {
997     FAST_RETURN_IF_NO_FRONTENDS(void());
998     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
999         didScheduleStyleRecalculationImpl(*instrumentingAgents, document);
1000 }
1001
1002 inline void InspectorInstrumentation::applyUserAgentOverride(Frame& frame, String& userAgent)
1003 {
1004     FAST_RETURN_IF_NO_FRONTENDS(void());
1005     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1006         applyUserAgentOverrideImpl(*instrumentingAgents, userAgent);
1007 }
1008
1009 inline void InspectorInstrumentation::applyEmulatedMedia(Frame& frame, String& media)
1010 {
1011     FAST_RETURN_IF_NO_FRONTENDS(void());
1012     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1013         applyEmulatedMediaImpl(*instrumentingAgents, media);
1014 }
1015
1016 inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
1017 {
1018     FAST_RETURN_IF_NO_FRONTENDS(void());
1019     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1020         willSendRequestImpl(*instrumentingAgents, identifier, loader, request, redirectResponse);
1021 }
1022
1023 inline void InspectorInstrumentation::willSendRequest(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, ResourceRequest& request)
1024 {
1025     FAST_RETURN_IF_NO_FRONTENDS(void());
1026     willSendRequestImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, request, ResourceResponse { });
1027 }
1028
1029 inline void InspectorInstrumentation::willSendRequestOfType(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, LoadType loadType)
1030 {
1031     FAST_RETURN_IF_NO_FRONTENDS(void());
1032     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1033         willSendRequestOfTypeImpl(*instrumentingAgents, identifier, loader, request, loadType);
1034 }
1035
1036 inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page& page, DocumentLoader* loader, CachedResource* resource)
1037 {
1038     FAST_RETURN_IF_NO_FRONTENDS(void());
1039     didLoadResourceFromMemoryCacheImpl(instrumentingAgentsForPage(page), loader, resource);
1040 }
1041
1042 inline void InspectorInstrumentation::didReceiveResourceResponse(Frame& frame, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
1043 {
1044     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1045         didReceiveResourceResponseImpl(*instrumentingAgents, identifier, loader, response, resourceLoader);
1046 }
1047
1048 inline void InspectorInstrumentation::didReceiveResourceResponse(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceResponse& response)
1049 {
1050     didReceiveResourceResponseImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, response, nullptr);
1051 }
1052
1053 inline void InspectorInstrumentation::didReceiveThreadableLoaderResponse(DocumentThreadableLoader& documentThreadableLoader, unsigned long identifier)
1054 {
1055     FAST_RETURN_IF_NO_FRONTENDS(void());
1056     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(documentThreadableLoader.document()))
1057         didReceiveThreadableLoaderResponseImpl(*instrumentingAgents, documentThreadableLoader, identifier);
1058 }
1059     
1060 inline void InspectorInstrumentation::didReceiveData(Frame* frame, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
1061 {
1062     FAST_RETURN_IF_NO_FRONTENDS(void());
1063     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1064         didReceiveDataImpl(*instrumentingAgents, identifier, data, dataLength, encodedDataLength);
1065 }
1066
1067 inline void InspectorInstrumentation::didReceiveData(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const char* data, int dataLength)
1068 {
1069     FAST_RETURN_IF_NO_FRONTENDS(void());
1070     didReceiveDataImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, data, dataLength, dataLength);
1071 }
1072
1073 inline void InspectorInstrumentation::didFinishLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const NetworkLoadMetrics& networkLoadMetrics, ResourceLoader* resourceLoader)
1074 {
1075     FAST_RETURN_IF_NO_FRONTENDS(void());
1076     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1077         didFinishLoadingImpl(*instrumentingAgents, identifier, loader, networkLoadMetrics, resourceLoader);
1078 }
1079
1080 inline void InspectorInstrumentation::didFinishLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const NetworkLoadMetrics& networkLoadMetrics)
1081 {
1082     FAST_RETURN_IF_NO_FRONTENDS(void());
1083     didFinishLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, networkLoadMetrics, nullptr);
1084 }
1085
1086 inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
1087 {
1088     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1089         didFailLoadingImpl(*instrumentingAgents, identifier, loader, error);
1090 }
1091
1092 inline void InspectorInstrumentation::didFailLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceError& error)
1093 {
1094     didFailLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, error);
1095 }
1096
1097 inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1098 {
1099     // Treat the same as didReceiveResponse.
1100     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1101         didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1102 }
1103
1104 inline void InspectorInstrumentation::continueWithPolicyDownload(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1105 {
1106     // Treat the same as didReceiveResponse.
1107     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1108         didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1109 }
1110
1111 inline void InspectorInstrumentation::continueWithPolicyIgnore(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1112 {
1113     // Treat the same as didReceiveResponse.
1114     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1115         didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1116 }
1117
1118 inline void InspectorInstrumentation::willLoadXHRSynchronously(ScriptExecutionContext* context)
1119 {
1120     FAST_RETURN_IF_NO_FRONTENDS(void());
1121     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1122         willLoadXHRSynchronouslyImpl(*instrumentingAgents);
1123 }
1124
1125 inline void InspectorInstrumentation::didLoadXHRSynchronously(ScriptExecutionContext* context)
1126 {
1127     FAST_RETURN_IF_NO_FRONTENDS(void());
1128     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1129         didLoadXHRSynchronouslyImpl(*instrumentingAgents);
1130 }
1131
1132 inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext& context, unsigned long identifier, const String& sourceString)
1133 {
1134     FAST_RETURN_IF_NO_FRONTENDS(void());
1135     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1136         scriptImportedImpl(*instrumentingAgents, identifier, sourceString);
1137 }
1138
1139 inline void InspectorInstrumentation::scriptExecutionBlockedByCSP(ScriptExecutionContext* context, const String& directiveText)
1140 {
1141     FAST_RETURN_IF_NO_FRONTENDS(void());
1142     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1143         scriptExecutionBlockedByCSPImpl(*instrumentingAgents, directiveText);
1144 }
1145
1146 inline void InspectorInstrumentation::didReceiveScriptResponse(ScriptExecutionContext* context, unsigned long identifier)
1147 {
1148     FAST_RETURN_IF_NO_FRONTENDS(void());
1149     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1150         didReceiveScriptResponseImpl(*instrumentingAgents, identifier);
1151 }
1152
1153 inline void InspectorInstrumentation::domContentLoadedEventFired(Frame& frame)
1154 {
1155     FAST_RETURN_IF_NO_FRONTENDS(void());
1156     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1157         domContentLoadedEventFiredImpl(*instrumentingAgents, frame);
1158 }
1159
1160 inline void InspectorInstrumentation::loadEventFired(Frame* frame)
1161 {
1162     FAST_RETURN_IF_NO_FRONTENDS(void());
1163     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1164         loadEventFiredImpl(*instrumentingAgents, frame);
1165 }
1166
1167 inline void InspectorInstrumentation::frameDetachedFromParent(Frame& frame)
1168 {
1169     FAST_RETURN_IF_NO_FRONTENDS(void());
1170     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1171         frameDetachedFromParentImpl(*instrumentingAgents, frame);
1172 }
1173
1174 inline void InspectorInstrumentation::didCommitLoad(Frame& frame, DocumentLoader* loader)
1175 {
1176     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1177         didCommitLoadImpl(*instrumentingAgents, frame, loader);
1178 }
1179
1180 inline void InspectorInstrumentation::frameDocumentUpdated(Frame& frame)
1181 {
1182     FAST_RETURN_IF_NO_FRONTENDS(void());
1183     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1184         frameDocumentUpdatedImpl(*instrumentingAgents, frame);
1185 }
1186
1187 inline void InspectorInstrumentation::loaderDetachedFromFrame(Frame& frame, DocumentLoader& loader)
1188 {
1189     FAST_RETURN_IF_NO_FRONTENDS(void());
1190     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1191         loaderDetachedFromFrameImpl(*instrumentingAgents, loader);
1192 }
1193
1194 inline void InspectorInstrumentation::frameStartedLoading(Frame& frame)
1195 {
1196     FAST_RETURN_IF_NO_FRONTENDS(void());
1197     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1198         frameStartedLoadingImpl(*instrumentingAgents, frame);
1199 }
1200
1201 inline void InspectorInstrumentation::frameStoppedLoading(Frame& frame)
1202 {
1203     FAST_RETURN_IF_NO_FRONTENDS(void());
1204     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1205         frameStoppedLoadingImpl(*instrumentingAgents, frame);
1206 }
1207
1208 inline void InspectorInstrumentation::frameScheduledNavigation(Frame& frame, Seconds delay)
1209 {
1210     FAST_RETURN_IF_NO_FRONTENDS(void());
1211     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1212         frameScheduledNavigationImpl(*instrumentingAgents, frame, delay);
1213 }
1214
1215 inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame& frame)
1216 {
1217     FAST_RETURN_IF_NO_FRONTENDS(void());
1218     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1219         frameClearedScheduledNavigationImpl(*instrumentingAgents, frame);
1220 }
1221
1222 inline void InspectorInstrumentation::defaultAppearanceDidChange(Page& page, bool useDarkAppearance)
1223 {
1224     FAST_RETURN_IF_NO_FRONTENDS(void());
1225     defaultAppearanceDidChangeImpl(instrumentingAgentsForPage(page), useDarkAppearance);
1226 }
1227
1228 inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource& cachedResource)
1229 {
1230     FAST_RETURN_IF_NO_FRONTENDS(void());
1231     willDestroyCachedResourceImpl(cachedResource);
1232 }
1233
1234 inline bool InspectorInstrumentation::willInterceptRequest(const Frame* frame, const ResourceRequest& request)
1235 {
1236     FAST_RETURN_IF_NO_FRONTENDS(false);
1237     if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1238         return willInterceptRequestImpl(*instrumentingAgents, request);
1239     return false;
1240 }
1241
1242 inline bool InspectorInstrumentation::shouldInterceptResponse(const Frame& frame, const ResourceResponse& response)
1243 {
1244     ASSERT(InspectorInstrumentationPublic::hasFrontends());
1245     if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1246         return shouldInterceptResponseImpl(*instrumentingAgents, response);
1247     return false;
1248 }
1249
1250 inline void InspectorInstrumentation::interceptResponse(const Frame& frame, const ResourceResponse& response, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&& handler)
1251 {
1252     ASSERT(InspectorInstrumentation::shouldInterceptResponse(frame, response));
1253     if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1254         interceptResponseImpl(*instrumentingAgents, response, identifier, WTFMove(handler));
1255 }
1256
1257 inline void InspectorInstrumentation::didOpenDatabase(Database& database)
1258 {
1259     FAST_RETURN_IF_NO_FRONTENDS(void());
1260     if (auto* instrumentingAgents = instrumentingAgentsForContext(database.document()))
1261         didOpenDatabaseImpl(*instrumentingAgents, database);
1262 }
1263
1264 inline void InspectorInstrumentation::didDispatchDOMStorageEvent(Page& page, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin)
1265 {
1266     FAST_RETURN_IF_NO_FRONTENDS(void());
1267     didDispatchDOMStorageEventImpl(instrumentingAgentsForPage(page), key, oldValue, newValue, storageType, securityOrigin);
1268 }
1269
1270 inline bool InspectorInstrumentation::shouldWaitForDebuggerOnStart(ScriptExecutionContext& context)
1271 {
1272     FAST_RETURN_IF_NO_FRONTENDS(false);
1273     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1274         return shouldWaitForDebuggerOnStartImpl(*instrumentingAgents);
1275     return false;
1276 }
1277
1278 inline void InspectorInstrumentation::workerStarted(ScriptExecutionContext& context, WorkerInspectorProxy* proxy, const URL& url)
1279 {
1280     FAST_RETURN_IF_NO_FRONTENDS(void());
1281     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1282         workerStartedImpl(*instrumentingAgents, proxy, url);
1283 }
1284
1285 inline void InspectorInstrumentation::workerTerminated(ScriptExecutionContext& context, WorkerInspectorProxy* proxy)
1286 {
1287     FAST_RETURN_IF_NO_FRONTENDS(void());
1288     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1289         workerTerminatedImpl(*instrumentingAgents, proxy);
1290 }
1291
1292 inline void InspectorInstrumentation::didCreateWebSocket(Document* document, unsigned long identifier, const URL& requestURL)
1293 {
1294     FAST_RETURN_IF_NO_FRONTENDS(void());
1295     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1296         didCreateWebSocketImpl(*instrumentingAgents, identifier, requestURL);
1297 }
1298
1299 inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(Document* document, unsigned long identifier, const ResourceRequest& request)
1300 {
1301     FAST_RETURN_IF_NO_FRONTENDS(void());
1302     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1303         willSendWebSocketHandshakeRequestImpl(*instrumentingAgents, identifier, request);
1304 }
1305
1306 inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(Document* document, unsigned long identifier, const ResourceResponse& response)
1307 {
1308     FAST_RETURN_IF_NO_FRONTENDS(void());
1309     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1310         didReceiveWebSocketHandshakeResponseImpl(*instrumentingAgents, identifier, response);
1311 }
1312
1313 inline void InspectorInstrumentation::didCloseWebSocket(Document* document, unsigned long identifier)
1314 {
1315     FAST_RETURN_IF_NO_FRONTENDS(void());
1316     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1317         didCloseWebSocketImpl(*instrumentingAgents, identifier);
1318 }
1319
1320 inline void InspectorInstrumentation::didReceiveWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1321 {
1322     FAST_RETURN_IF_NO_FRONTENDS(void());
1323     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1324         didReceiveWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1325 }
1326
1327 inline void InspectorInstrumentation::didReceiveWebSocketFrameError(Document* document, unsigned long identifier, const String& errorMessage)
1328 {
1329     FAST_RETURN_IF_NO_FRONTENDS(void());
1330     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1331         didReceiveWebSocketFrameErrorImpl(*instrumentingAgents, identifier, errorMessage);
1332 }
1333
1334 inline void InspectorInstrumentation::didSendWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1335 {
1336     FAST_RETURN_IF_NO_FRONTENDS(void());
1337     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1338         didSendWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1339 }
1340
1341 #if ENABLE(RESOURCE_USAGE)
1342 inline void InspectorInstrumentation::didHandleMemoryPressure(Page& page, Critical critical)
1343 {
1344     FAST_RETURN_IF_NO_FRONTENDS(void());
1345     didHandleMemoryPressureImpl(instrumentingAgentsForPage(page), critical);
1346 }
1347 #endif
1348
1349 inline void InspectorInstrumentation::didChangeCSSCanvasClientNodes(CanvasBase& canvasBase)
1350 {
1351     FAST_RETURN_IF_NO_FRONTENDS(void());
1352     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(canvasBase.scriptExecutionContext()))
1353         didChangeCSSCanvasClientNodesImpl(*instrumentingAgents, canvasBase);
1354 }
1355
1356 inline void InspectorInstrumentation::didCreateCanvasRenderingContext(CanvasRenderingContext& context)
1357 {
1358     FAST_RETURN_IF_NO_FRONTENDS(void());
1359     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1360         didCreateCanvasRenderingContextImpl(*instrumentingAgents, context);
1361 }
1362
1363 inline void InspectorInstrumentation::didChangeCanvasMemory(CanvasRenderingContext& context)
1364 {
1365     FAST_RETURN_IF_NO_FRONTENDS(void());
1366     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1367         didChangeCanvasMemoryImpl(*instrumentingAgents, context);
1368 }
1369
1370 inline void InspectorInstrumentation::recordCanvasAction(CanvasRenderingContext& context, const String& name, std::initializer_list<RecordCanvasActionVariant>&& parameters)
1371 {
1372     FAST_RETURN_IF_NO_FRONTENDS(void());
1373     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1374         recordCanvasActionImpl(*instrumentingAgents, context, name, WTFMove(parameters));
1375 }
1376
1377 inline void InspectorInstrumentation::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch)
1378 {
1379     FAST_RETURN_IF_NO_FRONTENDS(void());
1380     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1381         didFinishRecordingCanvasFrameImpl(*instrumentingAgents, context, forceDispatch);
1382 }
1383
1384 #if ENABLE(WEBGL)
1385 inline void InspectorInstrumentation::didEnableExtension(WebGLRenderingContextBase& contextWebGLBase, const String& extension)
1386 {
1387     FAST_RETURN_IF_NO_FRONTENDS(void());
1388     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1389         didEnableExtensionImpl(*instrumentingAgents, contextWebGLBase, extension);
1390 }
1391
1392 inline void InspectorInstrumentation::didCreateWebGLProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1393 {
1394     FAST_RETURN_IF_NO_FRONTENDS(void());
1395     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1396         didCreateWebGLProgramImpl(*instrumentingAgents, contextWebGLBase, program);
1397 }
1398
1399 inline void InspectorInstrumentation::willDestroyWebGLProgram(WebGLProgram& program)
1400 {
1401     FAST_RETURN_IF_NO_FRONTENDS(void());
1402     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(program.scriptExecutionContext()))
1403         willDestroyWebGLProgramImpl(*instrumentingAgents, program);
1404 }
1405
1406 inline bool InspectorInstrumentation::isWebGLProgramDisabled(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1407 {
1408     FAST_RETURN_IF_NO_FRONTENDS(false);
1409     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1410         return isWebGLProgramDisabledImpl(*instrumentingAgents, program);
1411     return false;
1412 }
1413
1414 inline bool InspectorInstrumentation::isWebGLProgramHighlighted(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1415 {
1416     FAST_RETURN_IF_NO_FRONTENDS(false);
1417     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1418         return isWebGLProgramHighlightedImpl(*instrumentingAgents, program);
1419     return false;
1420 }
1421 #endif
1422
1423 #if ENABLE(WEBGPU)
1424 inline void InspectorInstrumentation::didCreateWebGPUDevice(WebGPUDevice& device)
1425 {
1426     FAST_RETURN_IF_NO_FRONTENDS(void());
1427     if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
1428         didCreateWebGPUDeviceImpl(*instrumentingAgents, device);
1429 }
1430
1431 inline void InspectorInstrumentation::willDestroyWebGPUDevice(WebGPUDevice& device)
1432 {
1433     FAST_RETURN_IF_NO_FRONTENDS(void());
1434     if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
1435         willDestroyWebGPUDeviceImpl(*instrumentingAgents, device);
1436 }
1437
1438 inline void InspectorInstrumentation::willConfigureSwapChain(GPUCanvasContext& contextGPU, WebGPUSwapChain& newSwapChain)
1439 {
1440     FAST_RETURN_IF_NO_FRONTENDS(void());
1441     if (auto* instrumentingAgents = instrumentingAgentsForContext(contextGPU.canvasBase().scriptExecutionContext()))
1442         willConfigureSwapChainImpl(*instrumentingAgents, contextGPU, newSwapChain);
1443 }
1444
1445 inline void InspectorInstrumentation::didCreateWebGPUPipeline(WebGPUDevice& device, WebGPUPipeline& pipeline)
1446 {
1447     FAST_RETURN_IF_NO_FRONTENDS(void());
1448     if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
1449         didCreateWebGPUPipelineImpl(*instrumentingAgents, device, pipeline);
1450 }
1451
1452 inline void InspectorInstrumentation::willDestroyWebGPUPipeline(WebGPUPipeline& pipeline)
1453 {
1454     FAST_RETURN_IF_NO_FRONTENDS(void());
1455     if (auto* instrumentingAgents = instrumentingAgentsForContext(pipeline.scriptExecutionContext()))
1456         willDestroyWebGPUPipelineImpl(*instrumentingAgents, pipeline);
1457 }
1458 #endif
1459
1460 inline void InspectorInstrumentation::networkStateChanged(Page& page)
1461 {
1462     FAST_RETURN_IF_NO_FRONTENDS(void());
1463     networkStateChangedImpl(instrumentingAgentsForPage(page));
1464 }
1465
1466 inline void InspectorInstrumentation::updateApplicationCacheStatus(Frame* frame)
1467 {
1468     FAST_RETURN_IF_NO_FRONTENDS(void());
1469     if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1470         updateApplicationCacheStatusImpl(*instrumentingAgents, *frame);
1471 }
1472
1473 inline void InspectorInstrumentation::addMessageToConsole(Page& page, std::unique_ptr<Inspector::ConsoleMessage> message)
1474 {
1475     addMessageToConsoleImpl(instrumentingAgentsForPage(page), WTFMove(message));
1476 }
1477
1478 inline void InspectorInstrumentation::addMessageToConsole(WorkerGlobalScope& workerGlobalScope, std::unique_ptr<Inspector::ConsoleMessage> message)
1479 {
1480     addMessageToConsoleImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), WTFMove(message));
1481 }
1482
1483 inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, const String& label)
1484 {
1485     consoleCountImpl(instrumentingAgentsForPage(page), state, label);
1486 }
1487
1488 inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label)
1489 {
1490     consoleCountImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label);
1491 }
1492
1493 inline void InspectorInstrumentation::consoleCountReset(Page& page, JSC::ExecState* state, const String& label)
1494 {
1495     consoleCountResetImpl(instrumentingAgentsForPage(page), state, label);
1496 }
1497
1498 inline void InspectorInstrumentation::consoleCountReset(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label)
1499 {
1500     consoleCountResetImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label);
1501 }
1502
1503 inline void InspectorInstrumentation::takeHeapSnapshot(Frame& frame, const String& title)
1504 {
1505     FAST_RETURN_IF_NO_FRONTENDS(void());
1506     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1507         takeHeapSnapshotImpl(*instrumentingAgents, title);
1508 }
1509
1510 inline void InspectorInstrumentation::startConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label)
1511 {
1512     if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1513         startConsoleTimingImpl(*instrumentingAgents, frame, exec, label);
1514 }
1515
1516 inline void InspectorInstrumentation::startConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label)
1517 {
1518     startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label);
1519 }
1520
1521 inline void InspectorInstrumentation::logConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments)
1522 {
1523     if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1524         logConsoleTimingImpl(*instrumentingAgents, exec, label, WTFMove(arguments));
1525 }
1526
1527 inline void InspectorInstrumentation::logConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments)
1528 {
1529     logConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label, WTFMove(arguments));
1530 }
1531
1532 inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label)
1533 {
1534     if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1535         stopConsoleTimingImpl(*instrumentingAgents, frame, exec, label);
1536 }
1537
1538 inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label)
1539 {
1540     stopConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label);
1541 }
1542
1543 inline void InspectorInstrumentation::consoleTimeStamp(Frame& frame, Ref<Inspector::ScriptArguments>&& arguments)
1544 {
1545     FAST_RETURN_IF_NO_FRONTENDS(void());
1546     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1547         consoleTimeStampImpl(*instrumentingAgents, frame, WTFMove(arguments));
1548 }
1549
1550 inline void InspectorInstrumentation::startProfiling(Page& page, JSC::ExecState* exec, const String &title)
1551 {
1552     FAST_RETURN_IF_NO_FRONTENDS(void());
1553     startProfilingImpl(instrumentingAgentsForPage(page), exec, title);
1554 }
1555
1556 inline void InspectorInstrumentation::stopProfiling(Page& page, JSC::ExecState* exec, const String &title)
1557 {
1558     FAST_RETURN_IF_NO_FRONTENDS(void());
1559     stopProfilingImpl(instrumentingAgentsForPage(page), exec, title);
1560 }
1561
1562 inline void InspectorInstrumentation::consoleStartRecordingCanvas(CanvasRenderingContext& context, JSC::ExecState& exec, JSC::JSObject* options)
1563 {
1564     FAST_RETURN_IF_NO_FRONTENDS(void());
1565     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1566         consoleStartRecordingCanvasImpl(*instrumentingAgents, context, exec, options);
1567 }
1568
1569 inline void InspectorInstrumentation::didRequestAnimationFrame(Document& document, int callbackId)
1570 {
1571     FAST_RETURN_IF_NO_FRONTENDS(void());
1572     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1573         didRequestAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1574 }
1575
1576 inline void InspectorInstrumentation::didCancelAnimationFrame(Document& document, int callbackId)
1577 {
1578     FAST_RETURN_IF_NO_FRONTENDS(void());
1579     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1580         didCancelAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1581 }
1582
1583 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrame(Document& document, int callbackId)
1584 {
1585     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1586     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1587         return willFireAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1588     return InspectorInstrumentationCookie();
1589 }
1590
1591 inline void InspectorInstrumentation::didFireAnimationFrame(const InspectorInstrumentationCookie& cookie)
1592 {
1593     FAST_RETURN_IF_NO_FRONTENDS(void());
1594     if (cookie.isValid())
1595         didFireAnimationFrameImpl(cookie);
1596 }
1597
1598 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireObserverCallback(ScriptExecutionContext& context, const String& callbackType)
1599 {
1600     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1601     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1602         return willFireObserverCallbackImpl(*instrumentingAgents, callbackType, context);
1603     return InspectorInstrumentationCookie();
1604 }
1605
1606 inline void InspectorInstrumentation::didFireObserverCallback(const InspectorInstrumentationCookie& cookie)
1607 {
1608     FAST_RETURN_IF_NO_FRONTENDS(void());
1609     if (cookie.isValid())
1610         didFireObserverCallbackImpl(cookie);
1611 }
1612
1613 inline void InspectorInstrumentation::layerTreeDidChange(Page* page)
1614 {
1615     FAST_RETURN_IF_NO_FRONTENDS(void());
1616     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1617         layerTreeDidChangeImpl(*instrumentingAgents);
1618 }
1619
1620 inline void InspectorInstrumentation::renderLayerDestroyed(Page* page, const RenderLayer& renderLayer)
1621 {
1622     FAST_RETURN_IF_NO_FRONTENDS(void());
1623     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1624         renderLayerDestroyedImpl(*instrumentingAgents, renderLayer);
1625 }
1626
1627 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext* context)
1628 {
1629     return context ? instrumentingAgentsForContext(*context) : nullptr;
1630 }
1631
1632 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext& context)
1633 {
1634     if (is<Document>(context))
1635         return instrumentingAgentsForPage(downcast<Document>(context).page());
1636     if (is<WorkerGlobalScope>(context))
1637         return &instrumentingAgentsForWorkerGlobalScope(downcast<WorkerGlobalScope>(context));
1638     return nullptr;
1639 }
1640
1641 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(const Frame* frame)
1642 {
1643     return frame ? instrumentingAgentsForFrame(*frame) : nullptr;
1644 }
1645
1646 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(const Frame& frame)
1647 {
1648     return instrumentingAgentsForPage(frame.page());
1649 }
1650
1651 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document* document)
1652 {
1653     return document ? instrumentingAgentsForDocument(*document) : nullptr;
1654 }
1655
1656 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document& document)
1657 {
1658     Page* page = document.page();
1659     if (!page && document.templateDocumentHost())
1660         page = document.templateDocumentHost()->page();
1661     return instrumentingAgentsForPage(page);
1662 }
1663
1664 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForPage(Page* page)
1665 {
1666     return page ? &instrumentingAgentsForPage(*page) : nullptr;
1667 }
1668
1669 inline InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForPage(Page& page)
1670 {
1671     ASSERT(isMainThread());
1672     return page.inspectorController().m_instrumentingAgents.get();
1673 }
1674
1675 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope* workerGlobalScope)
1676 {
1677     return workerGlobalScope ? &instrumentingAgentsForWorkerGlobalScope(*workerGlobalScope) : nullptr;
1678 }
1679
1680 inline InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope& workerGlobalScope)
1681 {
1682     return workerGlobalScope.inspectorController().m_instrumentingAgents;
1683 }
1684
1685 inline void InspectorInstrumentation::frontendCreated()
1686 {
1687     ASSERT(isMainThread());
1688     ++InspectorInstrumentationPublic::s_frontendCounter;
1689
1690     if (InspectorInstrumentationPublic::s_frontendCounter == 1)
1691         InspectorInstrumentation::firstFrontendCreated();
1692 }
1693
1694 inline void InspectorInstrumentation::frontendDeleted()
1695 {
1696     ASSERT(isMainThread());
1697     --InspectorInstrumentationPublic::s_frontendCounter;
1698
1699     if (!InspectorInstrumentationPublic::s_frontendCounter)
1700         InspectorInstrumentation::lastFrontendDeleted();
1701 }
1702
1703 } // namespace WebCore