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