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