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