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