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