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