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