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