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