Web Inspector: tint all pixels drawn by shader program when hovering ShaderProgramTre...
[WebKit-https.git] / Source / WebCore / inspector / InspectorInstrumentation.h
1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 *     * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *     * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 *     * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #pragma once
33
34 #include "CSSSelector.h"
35 #include "CallTracerTypes.h"
36 #include "CanvasBase.h"
37 #include "CanvasRenderingContext.h"
38 #include "DocumentThreadableLoader.h"
39 #include "Element.h"
40 #include "EventTarget.h"
41 #include "FormData.h"
42 #include "Frame.h"
43 #include "HitTestResult.h"
44 #include "InspectorController.h"
45 #include "InspectorInstrumentationCookie.h"
46 #include "OffscreenCanvas.h"
47 #include "Page.h"
48 #include "StorageArea.h"
49 #include "WorkerGlobalScope.h"
50 #include "WorkerInspectorController.h"
51 #include <JavaScriptCore/JSCInlines.h>
52 #include <wtf/MemoryPressureHandler.h>
53 #include <wtf/RefPtr.h>
54
55 #if ENABLE(WEBGL)
56 #include "WebGLRenderingContextBase.h"
57 #endif
58
59 namespace Inspector {
60 class ConsoleMessage;
61 class ScriptArguments;
62 class ScriptCallStack;
63 }
64
65 namespace WebCore {
66
67 class CachedResource;
68 class CharacterData;
69 class DOMWindow;
70 class DOMWrapperWorld;
71 class Database;
72 class Document;
73 class DocumentLoader;
74 class EventListener;
75 class HTTPHeaderMap;
76 class InspectorTimelineAgent;
77 class InstrumentingAgents;
78 class NetworkLoadMetrics;
79 class Node;
80 class PseudoElement;
81 class RegisteredEventListener;
82 class RenderLayer;
83 class RenderObject;
84 class ResourceLoader;
85 class ResourceRequest;
86 class ResourceResponse;
87 class ScriptExecutionContext;
88 class SecurityOrigin;
89 class ShadowRoot;
90 class TimerBase;
91 class URL;
92 #if ENABLE(WEBGL)
93 class WebGLProgram;
94 #endif
95 class WebKitNamedFlow;
96 class WorkerInspectorProxy;
97
98 enum class StorageType;
99
100 struct WebSocketFrame;
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 didChangeCustomElementState(Element&);
125     static void pseudoElementCreated(Page*, PseudoElement&);
126     static void pseudoElementDestroyed(Page*, PseudoElement&);
127     static void didCreateNamedFlow(Document*, WebKitNamedFlow&);
128     static void willRemoveNamedFlow(Document*, WebKitNamedFlow&);
129     static void didChangeRegionOverset(Document&, WebKitNamedFlow&);
130     static void didRegisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
131     static void didUnregisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement);
132
133     static void mouseDidMoveOverElement(Page&, const HitTestResult&, unsigned modifierFlags);
134     static bool handleMousePress(Frame&);
135     static bool handleTouchEvent(Frame&, Node&);
136     static bool forcePseudoState(const Element&, CSSSelector::PseudoClassType);
137
138     static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
139     static void didInstallTimer(ScriptExecutionContext&, int timerId, Seconds timeout, bool singleShot);
140     static void didRemoveTimer(ScriptExecutionContext&, int timerId);
141
142     static void didPostMessage(Frame&, TimerBase&, JSC::ExecState&);
143     static void didFailPostMessage(Frame&, TimerBase&);
144     static void willDispatchPostMessage(Frame&, TimerBase&);
145     static void didDispatchPostMessage(Frame&, TimerBase&);
146
147     static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine);
148     static void didCallFunction(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
149     static void didAddEventListener(EventTarget&, const AtomicString& eventType);
150     static void willRemoveEventListener(EventTarget&, const AtomicString& eventType, EventListener&, bool capture);
151     static bool isEventListenerDisabled(EventTarget&, const AtomicString& eventType, EventListener&, bool capture);
152     static InspectorInstrumentationCookie willDispatchEvent(Document&, const Event&, bool hasEventListeners);
153     static void didDispatchEvent(const InspectorInstrumentationCookie&);
154     static void willHandleEvent(ScriptExecutionContext&, const Event&, const RegisteredEventListener&);
155     static void didHandleEvent(ScriptExecutionContext&);
156     static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event&, DOMWindow&);
157     static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&);
158     static InspectorInstrumentationCookie willEvaluateScript(Frame&, const String& url, int lineNumber);
159     static void didEvaluateScript(const InspectorInstrumentationCookie&, Frame&);
160     static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext&, int timerId);
161     static void didFireTimer(const InspectorInstrumentationCookie&);
162     static void didInvalidateLayout(Frame&);
163     static InspectorInstrumentationCookie willLayout(Frame&);
164     static void didLayout(const InspectorInstrumentationCookie&, RenderObject&);
165     static void didScroll(Page&);
166     static void willComposite(Frame&);
167     static void didComposite(Frame&);
168     static void willPaint(RenderObject&);
169     static void didPaint(RenderObject&, const LayoutRect&);
170     static InspectorInstrumentationCookie willRecalculateStyle(Document&);
171     static void didRecalculateStyle(const InspectorInstrumentationCookie&);
172     static void didScheduleStyleRecalculation(Document&);
173     static void applyEmulatedMedia(Frame&, String&);
174
175     static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
176     static void didLoadResourceFromMemoryCache(Page&, DocumentLoader*, CachedResource*);
177     static void didReceiveResourceResponse(Frame&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
178     static void didReceiveThreadableLoaderResponse(DocumentThreadableLoader&, unsigned long identifier);
179     static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
180     static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, const NetworkLoadMetrics&, ResourceLoader*);
181     static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
182
183     static void willSendRequest(WorkerGlobalScope&, unsigned long identifier, ResourceRequest&);
184     static void didReceiveResourceResponse(WorkerGlobalScope&, unsigned long identifier, const ResourceResponse&);
185     static void didReceiveData(WorkerGlobalScope&, unsigned long identifier, const char* data, int dataLength);
186     static void didFinishLoading(WorkerGlobalScope&, unsigned long identifier, const NetworkLoadMetrics&);
187     static void didFailLoading(WorkerGlobalScope&, unsigned long identifier, const ResourceError&);
188
189     // Some network requests do not go through the normal network loading path.
190     // These network requests have to issue their own willSendRequest / didReceiveResponse / didFinishLoading / didFailLoading
191     // instrumentation calls. Some of these loads are for resources that lack a CachedResource::Type.
192     enum class LoadType { Ping, Beacon };
193     static void willSendRequestOfType(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
194
195     static void continueAfterXFrameOptionsDenied(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
196     static void continueWithPolicyDownload(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
197     static void continueWithPolicyIgnore(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
198     static void willLoadXHRSynchronously(ScriptExecutionContext*);
199     static void didLoadXHRSynchronously(ScriptExecutionContext*);
200     static void scriptImported(ScriptExecutionContext&, unsigned long identifier, const String& sourceString);
201     static void scriptExecutionBlockedByCSP(ScriptExecutionContext*, const String& directiveText);
202     static void didReceiveScriptResponse(ScriptExecutionContext*, unsigned long identifier);
203     static void domContentLoadedEventFired(Frame&);
204     static void loadEventFired(Frame*);
205     static void frameDetachedFromParent(Frame&);
206     static void didCommitLoad(Frame&, DocumentLoader*);
207     static void frameDocumentUpdated(Frame&);
208     static void loaderDetachedFromFrame(Frame&, DocumentLoader&);
209     static void frameStartedLoading(Frame&);
210     static void frameStoppedLoading(Frame&);
211     static void frameScheduledNavigation(Frame&, Seconds delay);
212     static void frameClearedScheduledNavigation(Frame&);
213     static void willDestroyCachedResource(CachedResource&);
214
215     static void addMessageToConsole(Page&, std::unique_ptr<Inspector::ConsoleMessage>);
216     static void addMessageToConsole(WorkerGlobalScope&, std::unique_ptr<Inspector::ConsoleMessage>);
217
218     static void consoleCount(Page&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
219     static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
220     static void takeHeapSnapshot(Frame&, const String& title);
221     static void startConsoleTiming(Frame&, const String& title);
222     static void startConsoleTiming(WorkerGlobalScope&, const String& title);
223     static void stopConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
224     static void stopConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptCallStack>&&);
225     static void consoleTimeStamp(Frame&, Ref<Inspector::ScriptArguments>&&);
226     static void startProfiling(Page&, JSC::ExecState*, const String& title);
227     static void stopProfiling(Page&, JSC::ExecState*, const String& title);
228     static void consoleStartRecordingCanvas(CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
229
230     static void didRequestAnimationFrame(Document&, int callbackId);
231     static void didCancelAnimationFrame(Document&, int callbackId);
232     static InspectorInstrumentationCookie willFireAnimationFrame(Document&, int callbackId);
233     static void didFireAnimationFrame(const InspectorInstrumentationCookie&);
234
235     static void didOpenDatabase(ScriptExecutionContext*, RefPtr<Database>&&, const String& domain, const String& name, const String& version);
236
237     static void didDispatchDOMStorageEvent(Page&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
238
239     static bool shouldWaitForDebuggerOnStart(ScriptExecutionContext&);
240     static void workerStarted(ScriptExecutionContext&, WorkerInspectorProxy*, const URL&);
241     static void workerTerminated(ScriptExecutionContext&, WorkerInspectorProxy*);
242
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
251 #if ENABLE(RESOURCE_USAGE)
252     static void didHandleMemoryPressure(Page&, Critical);
253 #endif
254
255     static void didChangeCSSCanvasClientNodes(CanvasBase&);
256     static void didCreateCanvasRenderingContext(CanvasRenderingContext&);
257     static void didChangeCanvasMemory(CanvasRenderingContext&);
258     static void recordCanvasAction(CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { });
259     static void didFinishRecordingCanvasFrame(CanvasRenderingContext&, bool forceDispatch = false);
260 #if ENABLE(WEBGL)
261     static void didEnableExtension(WebGLRenderingContextBase&, const String&);
262     static void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
263     static void willDeleteProgram(WebGLRenderingContextBase&, WebGLProgram&);
264     static bool isShaderProgramDisabled(WebGLRenderingContextBase&, WebGLProgram&);
265     static bool isShaderProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&);
266 #endif
267
268     static void networkStateChanged(Page&);
269     static void updateApplicationCacheStatus(Frame*);
270
271     static void layerTreeDidChange(Page*);
272     static void renderLayerDestroyed(Page*, const RenderLayer&);
273
274     static void frontendCreated();
275     static void frontendDeleted();
276     static bool hasFrontends() { return s_frontendCounter; }
277
278     static void firstFrontendCreated();
279     static void lastFrontendDeleted();
280
281     static bool consoleAgentEnabled(ScriptExecutionContext*);
282     static bool timelineAgentEnabled(ScriptExecutionContext*);
283
284     static InstrumentingAgents* instrumentingAgentsForPage(Page*);
285
286     static void registerInstrumentingAgents(InstrumentingAgents&);
287     static void unregisterInstrumentingAgents(InstrumentingAgents&);
288
289 private:
290     static void didClearWindowObjectInWorldImpl(InstrumentingAgents&, Frame&, DOMWrapperWorld&);
291     static bool isDebuggerPausedImpl(InstrumentingAgents&);
292
293     static void willInsertDOMNodeImpl(InstrumentingAgents&, Node& parent);
294     static void didInsertDOMNodeImpl(InstrumentingAgents&, Node&);
295     static void willRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
296     static void didRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
297     static void willModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomicString& oldValue, const AtomicString& newValue);
298     static void didModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomicString& name, const AtomicString& value);
299     static void didRemoveDOMAttrImpl(InstrumentingAgents&, Element&, const AtomicString& name);
300     static void characterDataModifiedImpl(InstrumentingAgents&, CharacterData&);
301     static void didInvalidateStyleAttrImpl(InstrumentingAgents&, Node&);
302     static void documentDetachedImpl(InstrumentingAgents&, Document&);
303     static void frameWindowDiscardedImpl(InstrumentingAgents&, DOMWindow*);
304     static void mediaQueryResultChangedImpl(InstrumentingAgents&);
305     static void activeStyleSheetsUpdatedImpl(InstrumentingAgents&, Document&);
306     static void didPushShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
307     static void willPopShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
308     static void didChangeCustomElementStateImpl(InstrumentingAgents&, Element&);
309     static void pseudoElementCreatedImpl(InstrumentingAgents&, PseudoElement&);
310     static void pseudoElementDestroyedImpl(InstrumentingAgents&, PseudoElement&);
311     static void didCreateNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
312     static void willRemoveNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
313     static void didChangeRegionOversetImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&);
314     static void didRegisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
315     static void didUnregisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement);
316
317     static void mouseDidMoveOverElementImpl(InstrumentingAgents&, const HitTestResult&, unsigned modifierFlags);
318     static bool handleMousePressImpl(InstrumentingAgents&);
319     static bool handleTouchEventImpl(InstrumentingAgents&, Node&);
320     static bool forcePseudoStateImpl(InstrumentingAgents&, const Element&, CSSSelector::PseudoClassType);
321
322     static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url);
323     static void didInstallTimerImpl(InstrumentingAgents&, int timerId, Seconds timeout, bool singleShot, ScriptExecutionContext&);
324     static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext&);
325
326     static void didPostMessageImpl(InstrumentingAgents&, const TimerBase&, JSC::ExecState&);
327     static void didFailPostMessageImpl(InstrumentingAgents&, const TimerBase&);
328     static void willDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&);
329     static void didDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&);
330
331     static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents&, const String& scriptName, int scriptLine, ScriptExecutionContext*);
332     static void didCallFunctionImpl(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
333     static void didAddEventListenerImpl(InstrumentingAgents&, EventTarget&, const AtomicString& eventType);
334     static void willRemoveEventListenerImpl(InstrumentingAgents&, EventTarget&, const AtomicString& eventType, EventListener&, bool capture);
335     static bool isEventListenerDisabledImpl(InstrumentingAgents&, EventTarget&, const AtomicString& eventType, EventListener&, bool capture);
336     static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents&, Document&, const Event&, bool hasEventListeners);
337     static void willHandleEventImpl(InstrumentingAgents&, const Event&, const RegisteredEventListener&);
338     static void didHandleEventImpl(InstrumentingAgents&);
339     static void didDispatchEventImpl(const InspectorInstrumentationCookie&);
340     static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InstrumentingAgents&, const Event&, DOMWindow&);
341     static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&);
342     static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents&, Frame&, const String& url, int lineNumber);
343     static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&, Frame&);
344     static InspectorInstrumentationCookie willFireTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext&);
345     static void didFireTimerImpl(const InspectorInstrumentationCookie&);
346     static void didInvalidateLayoutImpl(InstrumentingAgents&, Frame&);
347     static InspectorInstrumentationCookie willLayoutImpl(InstrumentingAgents&, Frame&);
348     static void didLayoutImpl(const InspectorInstrumentationCookie&, RenderObject&);
349     static void didScrollImpl(InstrumentingAgents&);
350     static void willCompositeImpl(InstrumentingAgents&, Frame&);
351     static void didCompositeImpl(InstrumentingAgents&);
352     static void willPaintImpl(InstrumentingAgents&, RenderObject&);
353     static void didPaintImpl(InstrumentingAgents&, RenderObject&, const LayoutRect&);
354     static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents&, Document&);
355     static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
356     static void didScheduleStyleRecalculationImpl(InstrumentingAgents&, Document&);
357     static void applyEmulatedMediaImpl(InstrumentingAgents&, String&);
358
359     static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
360     static void willSendRequestOfTypeImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
361     static void markResourceAsCachedImpl(InstrumentingAgents&, unsigned long identifier);
362     static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents&, DocumentLoader*, CachedResource*);
363     static void didReceiveResourceResponseImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
364     static void didReceiveThreadableLoaderResponseImpl(InstrumentingAgents&, DocumentThreadableLoader&, unsigned long identifier);
365     static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
366     static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const NetworkLoadMetrics&, ResourceLoader*);
367     static void didFailLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceError&);
368     static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&);
369     static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&);
370     static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString);
371     static void scriptExecutionBlockedByCSPImpl(InstrumentingAgents&, const String& directiveText);
372     static void didReceiveScriptResponseImpl(InstrumentingAgents&, unsigned long identifier);
373     static void domContentLoadedEventFiredImpl(InstrumentingAgents&, Frame&);
374     static void loadEventFiredImpl(InstrumentingAgents&, Frame*);
375     static void frameDetachedFromParentImpl(InstrumentingAgents&, Frame&);
376     static void didCommitLoadImpl(InstrumentingAgents&, Frame&, DocumentLoader*);
377     static void frameDocumentUpdatedImpl(InstrumentingAgents&, Frame&);
378     static void loaderDetachedFromFrameImpl(InstrumentingAgents&, DocumentLoader&);
379     static void frameStartedLoadingImpl(InstrumentingAgents&, Frame&);
380     static void frameStoppedLoadingImpl(InstrumentingAgents&, Frame&);
381     static void frameScheduledNavigationImpl(InstrumentingAgents&, Frame&, Seconds delay);
382     static void frameClearedScheduledNavigationImpl(InstrumentingAgents&, Frame&);
383     static void willDestroyCachedResourceImpl(CachedResource&);
384
385     static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>);
386
387     static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
388     static void takeHeapSnapshotImpl(InstrumentingAgents&, const String& title);
389     static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title);
390     static void startConsoleTimingImpl(InstrumentingAgents&, const String& title);
391     static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
392     static void stopConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptCallStack>&&);
393     static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&);
394     static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
395     static void stopProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
396     static void consoleStartRecordingCanvasImpl(InstrumentingAgents&, CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
397
398     static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
399     static void didCancelAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
400     static InspectorInstrumentationCookie willFireAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
401     static void didFireAnimationFrameImpl(const InspectorInstrumentationCookie&);
402
403     static void didOpenDatabaseImpl(InstrumentingAgents&, RefPtr<Database>&&, const String& domain, const String& name, const String& version);
404
405     static void didDispatchDOMStorageEventImpl(InstrumentingAgents&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
406
407     static bool shouldWaitForDebuggerOnStartImpl(InstrumentingAgents&);
408     static void workerStartedImpl(InstrumentingAgents&, WorkerInspectorProxy*, const URL&);
409     static void workerTerminatedImpl(InstrumentingAgents&, WorkerInspectorProxy*);
410
411     static void didCreateWebSocketImpl(InstrumentingAgents&, unsigned long identifier, const URL& requestURL);
412     static void willSendWebSocketHandshakeRequestImpl(InstrumentingAgents&, unsigned long identifier, const ResourceRequest&);
413     static void didReceiveWebSocketHandshakeResponseImpl(InstrumentingAgents&, unsigned long identifier, const ResourceResponse&);
414     static void didCloseWebSocketImpl(InstrumentingAgents&, unsigned long identifier);
415     static void didReceiveWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
416     static void didSendWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
417     static void didReceiveWebSocketFrameErrorImpl(InstrumentingAgents&, unsigned long identifier, const String&);
418
419 #if ENABLE(RESOURCE_USAGE)
420     static void didHandleMemoryPressureImpl(InstrumentingAgents&, Critical);
421 #endif
422
423     static void networkStateChangedImpl(InstrumentingAgents&);
424     static void updateApplicationCacheStatusImpl(InstrumentingAgents&, Frame&);
425
426     static void didChangeCSSCanvasClientNodesImpl(InstrumentingAgents&, CanvasBase&);
427     static void didCreateCanvasRenderingContextImpl(InstrumentingAgents&, CanvasRenderingContext&);
428     static void didChangeCanvasMemoryImpl(InstrumentingAgents&, CanvasRenderingContext&);
429     static void recordCanvasActionImpl(InstrumentingAgents&, CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { });
430     static void didFinishRecordingCanvasFrameImpl(InstrumentingAgents&, CanvasRenderingContext&, bool forceDispatch = false);
431 #if ENABLE(WEBGL)
432     static void didEnableExtensionImpl(InstrumentingAgents&, WebGLRenderingContextBase&, const String&);
433     static void didCreateProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);
434     static void willDeleteProgramImpl(InstrumentingAgents&, WebGLProgram&);
435     static bool isShaderProgramDisabledImpl(InstrumentingAgents&, WebGLProgram&);
436     static bool isShaderProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&);
437 #endif
438
439     static void layerTreeDidChangeImpl(InstrumentingAgents&);
440     static void renderLayerDestroyedImpl(InstrumentingAgents&, const RenderLayer&);
441
442     static InstrumentingAgents& instrumentingAgentsForPage(Page&);
443     static InstrumentingAgents& instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope&);
444
445     static InstrumentingAgents* instrumentingAgentsForFrame(Frame&);
446     static InstrumentingAgents* instrumentingAgentsForFrame(Frame*);
447     static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext*);
448     static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext&);
449     static InstrumentingAgents* instrumentingAgentsForDocument(Document&);
450     static InstrumentingAgents* instrumentingAgentsForDocument(Document*);
451     static InstrumentingAgents* instrumentingAgentsForRenderer(RenderObject&);
452     static InstrumentingAgents* instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope*);
453
454     static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
455
456     static void pauseOnNativeEventIfNeeded(InstrumentingAgents&, bool isDOMEvent, const String& eventName, bool synchronous);
457
458     WEBCORE_EXPORT static int s_frontendCounter;
459 };
460
461 inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld& world)
462 {
463     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
464         didClearWindowObjectInWorldImpl(*instrumentingAgents, frame, world);
465 }
466
467 inline bool InspectorInstrumentation::isDebuggerPaused(Frame* frame)
468 {
469     FAST_RETURN_IF_NO_FRONTENDS(false);
470     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
471         return isDebuggerPausedImpl(*instrumentingAgents);
472     return false;
473 }
474
475 inline void InspectorInstrumentation::willInsertDOMNode(Document& document, Node& parent)
476 {
477     FAST_RETURN_IF_NO_FRONTENDS(void());
478     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
479         willInsertDOMNodeImpl(*instrumentingAgents, parent);
480 }
481
482 inline void InspectorInstrumentation::didInsertDOMNode(Document& document, Node& node)
483 {
484     FAST_RETURN_IF_NO_FRONTENDS(void());
485     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
486         didInsertDOMNodeImpl(*instrumentingAgents, node);
487 }
488
489 inline void InspectorInstrumentation::willRemoveDOMNode(Document& document, Node& node)
490 {
491     FAST_RETURN_IF_NO_FRONTENDS(void());
492     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
493         willRemoveDOMNodeImpl(*instrumentingAgents, node);
494 }
495
496 inline void InspectorInstrumentation::didRemoveDOMNode(Document& document, Node& node)
497 {
498     FAST_RETURN_IF_NO_FRONTENDS(void());
499     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
500         didRemoveDOMNodeImpl(*instrumentingAgents, node);
501 }
502
503 inline void InspectorInstrumentation::willModifyDOMAttr(Document& document, Element& element, const AtomicString& oldValue, const AtomicString& newValue)
504 {
505     FAST_RETURN_IF_NO_FRONTENDS(void());
506     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
507         willModifyDOMAttrImpl(*instrumentingAgents, element, oldValue, newValue);
508 }
509
510 inline void InspectorInstrumentation::didModifyDOMAttr(Document& document, Element& element, const AtomicString& name, const AtomicString& value)
511 {
512     FAST_RETURN_IF_NO_FRONTENDS(void());
513     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
514         didModifyDOMAttrImpl(*instrumentingAgents, element, name, value);
515 }
516
517 inline void InspectorInstrumentation::didRemoveDOMAttr(Document& document, Element& element, const AtomicString& name)
518 {
519     FAST_RETURN_IF_NO_FRONTENDS(void());
520     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
521         didRemoveDOMAttrImpl(*instrumentingAgents, element, name);
522 }
523
524 inline void InspectorInstrumentation::didInvalidateStyleAttr(Document& document, Node& node)
525 {
526     FAST_RETURN_IF_NO_FRONTENDS(void());
527     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
528         didInvalidateStyleAttrImpl(*instrumentingAgents, node);
529 }
530
531 inline void InspectorInstrumentation::documentDetached(Document& document)
532 {
533     FAST_RETURN_IF_NO_FRONTENDS(void());
534     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
535         documentDetachedImpl(*instrumentingAgents, document);
536 }
537
538 inline void InspectorInstrumentation::frameWindowDiscarded(Frame& frame, DOMWindow* domWindow)
539 {
540     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
541         frameWindowDiscardedImpl(*instrumentingAgents, domWindow);
542 }
543
544 inline void InspectorInstrumentation::mediaQueryResultChanged(Document& document)
545 {
546     FAST_RETURN_IF_NO_FRONTENDS(void());
547     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
548         mediaQueryResultChangedImpl(*instrumentingAgents);
549 }
550
551 inline void InspectorInstrumentation::activeStyleSheetsUpdated(Document& document)
552 {
553     FAST_RETURN_IF_NO_FRONTENDS(void());
554     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
555         activeStyleSheetsUpdatedImpl(*instrumentingAgents, document);
556 }
557
558 inline void InspectorInstrumentation::didPushShadowRoot(Element& host, ShadowRoot& root)
559 {
560     FAST_RETURN_IF_NO_FRONTENDS(void());
561     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
562         didPushShadowRootImpl(*instrumentingAgents, host, root);
563 }
564
565 inline void InspectorInstrumentation::willPopShadowRoot(Element& host, ShadowRoot& root)
566 {
567     FAST_RETURN_IF_NO_FRONTENDS(void());
568     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
569         willPopShadowRootImpl(*instrumentingAgents, host, root);
570 }
571
572 inline void InspectorInstrumentation::didChangeCustomElementState(Element& element)
573 {
574     FAST_RETURN_IF_NO_FRONTENDS(void());
575     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
576         didChangeCustomElementStateImpl(*instrumentingAgents, element);
577 }
578
579 inline void InspectorInstrumentation::pseudoElementCreated(Page* page, PseudoElement& pseudoElement)
580 {
581     FAST_RETURN_IF_NO_FRONTENDS(void());
582     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
583         pseudoElementCreatedImpl(*instrumentingAgents, pseudoElement);
584 }
585
586 inline void InspectorInstrumentation::pseudoElementDestroyed(Page* page, PseudoElement& pseudoElement)
587 {
588     FAST_RETURN_IF_NO_FRONTENDS(void());
589     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
590         pseudoElementDestroyedImpl(*instrumentingAgents, pseudoElement);
591 }
592
593 inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
594 {
595     FAST_RETURN_IF_NO_FRONTENDS(void());
596     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
597         didCreateNamedFlowImpl(*instrumentingAgents, document, namedFlow);
598 }
599
600 inline void InspectorInstrumentation::willRemoveNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
601 {
602     FAST_RETURN_IF_NO_FRONTENDS(void());
603     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
604         willRemoveNamedFlowImpl(*instrumentingAgents, document, namedFlow);
605 }
606
607 inline void InspectorInstrumentation::didChangeRegionOverset(Document& document, WebKitNamedFlow& namedFlow)
608 {
609     FAST_RETURN_IF_NO_FRONTENDS(void());
610     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
611         didChangeRegionOversetImpl(*instrumentingAgents, document, namedFlow);
612 }
613
614 inline void InspectorInstrumentation::didRegisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement, Node* nextContentElement)
615 {
616     FAST_RETURN_IF_NO_FRONTENDS(void());
617     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
618         didRegisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement, nextContentElement);
619 }
620
621 inline void InspectorInstrumentation::didUnregisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement)
622 {
623     FAST_RETURN_IF_NO_FRONTENDS(void());
624     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
625         didUnregisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement);
626 }
627
628 inline void InspectorInstrumentation::mouseDidMoveOverElement(Page& page, const HitTestResult& result, unsigned modifierFlags)
629 {
630     FAST_RETURN_IF_NO_FRONTENDS(void());
631     mouseDidMoveOverElementImpl(instrumentingAgentsForPage(page), result, modifierFlags);
632 }
633
634 inline bool InspectorInstrumentation::handleTouchEvent(Frame& frame, Node& node)
635 {
636     FAST_RETURN_IF_NO_FRONTENDS(false);
637     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
638         return handleTouchEventImpl(*instrumentingAgents, node);
639     return false;
640 }
641
642 inline bool InspectorInstrumentation::handleMousePress(Frame& frame)
643 {
644     FAST_RETURN_IF_NO_FRONTENDS(false);
645     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
646         return handleMousePressImpl(*instrumentingAgents);
647     return false;
648 }
649
650 inline bool InspectorInstrumentation::forcePseudoState(const Element& element, CSSSelector::PseudoClassType pseudoState)
651 {
652     FAST_RETURN_IF_NO_FRONTENDS(false);
653     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
654         return forcePseudoStateImpl(*instrumentingAgents, element, pseudoState);
655     return false;
656 }
657
658 inline void InspectorInstrumentation::characterDataModified(Document& document, CharacterData& characterData)
659 {
660     FAST_RETURN_IF_NO_FRONTENDS(void());
661     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
662         characterDataModifiedImpl(*instrumentingAgents, characterData);
663 }
664
665 inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url)
666 {
667     FAST_RETURN_IF_NO_FRONTENDS(void());
668     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
669         willSendXMLHttpRequestImpl(*instrumentingAgents, url);
670 }
671
672 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext& context, int timerId, Seconds timeout, bool singleShot)
673 {
674     FAST_RETURN_IF_NO_FRONTENDS(void());
675     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
676         didInstallTimerImpl(*instrumentingAgents, timerId, timeout, singleShot, context);
677 }
678
679 inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext& context, int timerId)
680 {
681     FAST_RETURN_IF_NO_FRONTENDS(void());
682     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
683         didRemoveTimerImpl(*instrumentingAgents, timerId, context);
684 }
685
686 inline void InspectorInstrumentation::didAddEventListener(EventTarget& target, const AtomicString& eventType)
687 {
688     FAST_RETURN_IF_NO_FRONTENDS(void());
689     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
690         didAddEventListenerImpl(*instrumentingAgents, target, eventType);
691 }
692
693 inline void InspectorInstrumentation::willRemoveEventListener(EventTarget& target, const AtomicString& eventType, EventListener& listener, bool capture)
694 {
695     FAST_RETURN_IF_NO_FRONTENDS(void());
696     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
697         willRemoveEventListenerImpl(*instrumentingAgents, target, eventType, listener, capture);
698 }
699
700 inline bool InspectorInstrumentation::isEventListenerDisabled(EventTarget& target, const AtomicString& eventType, EventListener& listener, bool capture)
701 {
702     FAST_RETURN_IF_NO_FRONTENDS(false);
703     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
704         return isEventListenerDisabledImpl(*instrumentingAgents, target, eventType, listener, capture);
705     return false;
706 }
707
708 inline void InspectorInstrumentation::didPostMessage(Frame& frame, TimerBase& timer, JSC::ExecState& state)
709 {
710     FAST_RETURN_IF_NO_FRONTENDS(void());
711     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
712         didPostMessageImpl(*instrumentingAgents, timer, state);
713 }
714
715 inline void InspectorInstrumentation::didFailPostMessage(Frame& frame, TimerBase& timer)
716 {
717     FAST_RETURN_IF_NO_FRONTENDS(void());
718     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
719         didFailPostMessageImpl(*instrumentingAgents, timer);
720 }
721
722 inline void InspectorInstrumentation::willDispatchPostMessage(Frame& frame, TimerBase& timer)
723 {
724     FAST_RETURN_IF_NO_FRONTENDS(void());
725     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
726         willDispatchPostMessageImpl(*instrumentingAgents, timer);
727 }
728
729 inline void InspectorInstrumentation::didDispatchPostMessage(Frame& frame, TimerBase& timer)
730 {
731     FAST_RETURN_IF_NO_FRONTENDS(void());
732     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
733         didDispatchPostMessageImpl(*instrumentingAgents, timer);
734 }
735
736 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(ScriptExecutionContext* context, const String& scriptName, int scriptLine)
737 {
738     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
739     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
740         return willCallFunctionImpl(*instrumentingAgents, scriptName, scriptLine, context);
741     return InspectorInstrumentationCookie();
742 }
743
744 inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie, ScriptExecutionContext* context)
745 {
746     FAST_RETURN_IF_NO_FRONTENDS(void());
747     if (cookie.isValid())
748         didCallFunctionImpl(cookie, context);
749 }
750
751 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document& document, const Event& event, bool hasEventListeners)
752 {
753     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
754     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
755         return willDispatchEventImpl(*instrumentingAgents, document, event, hasEventListeners);
756     return InspectorInstrumentationCookie();
757 }
758
759 inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie)
760 {
761     FAST_RETURN_IF_NO_FRONTENDS(void());
762     if (cookie.isValid())
763         didDispatchEventImpl(cookie);
764 }
765
766 inline void InspectorInstrumentation::willHandleEvent(ScriptExecutionContext& context, const Event& event, const RegisteredEventListener& listener)
767 {
768     FAST_RETURN_IF_NO_FRONTENDS(void());
769     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
770         return willHandleEventImpl(*instrumentingAgents, event, listener);
771 }
772
773 inline void InspectorInstrumentation::didHandleEvent(ScriptExecutionContext& context)
774 {
775     FAST_RETURN_IF_NO_FRONTENDS(void());
776     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
777         return didHandleEventImpl(*instrumentingAgents);
778 }
779
780 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindow(Frame* frame, const Event& event, DOMWindow& window)
781 {
782     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
783     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
784         return willDispatchEventOnWindowImpl(*instrumentingAgents, event, window);
785     return InspectorInstrumentationCookie();
786 }
787
788 inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie)
789 {
790     FAST_RETURN_IF_NO_FRONTENDS(void());
791     if (cookie.isValid())
792         didDispatchEventOnWindowImpl(cookie);
793 }
794
795 inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame& frame, const String& url, int lineNumber)
796 {
797     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
798     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
799         return willEvaluateScriptImpl(*instrumentingAgents, frame, url, lineNumber);
800     return InspectorInstrumentationCookie();
801 }
802
803 inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumentationCookie& cookie, Frame& frame)
804 {
805     FAST_RETURN_IF_NO_FRONTENDS(void());
806     if (cookie.isValid())
807         didEvaluateScriptImpl(cookie, frame);
808 }
809
810 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext& context, int timerId)
811 {
812     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
813     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
814         return willFireTimerImpl(*instrumentingAgents, timerId, context);
815     return InspectorInstrumentationCookie();
816 }
817
818 inline void InspectorInstrumentation::didFireTimer(const InspectorInstrumentationCookie& cookie)
819 {
820     FAST_RETURN_IF_NO_FRONTENDS(void());
821     if (cookie.isValid())
822         didFireTimerImpl(cookie);
823 }
824
825 inline void InspectorInstrumentation::didInvalidateLayout(Frame& frame)
826 {
827     FAST_RETURN_IF_NO_FRONTENDS(void());
828     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
829         didInvalidateLayoutImpl(*instrumentingAgents, frame);
830 }
831
832 inline InspectorInstrumentationCookie InspectorInstrumentation::willLayout(Frame& frame)
833 {
834     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
835     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
836         return willLayoutImpl(*instrumentingAgents, frame);
837     return InspectorInstrumentationCookie();
838 }
839
840 inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCookie& cookie, RenderObject& root)
841 {
842     FAST_RETURN_IF_NO_FRONTENDS(void());
843     if (cookie.isValid())
844         didLayoutImpl(cookie, root);
845 }
846
847 inline void InspectorInstrumentation::didScroll(Page& page)
848 {
849     FAST_RETURN_IF_NO_FRONTENDS(void());
850     didScrollImpl(instrumentingAgentsForPage(page));
851 }
852
853 inline void InspectorInstrumentation::willComposite(Frame& frame)
854 {
855     FAST_RETURN_IF_NO_FRONTENDS(void());
856     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
857         willCompositeImpl(*instrumentingAgents, frame);
858 }
859
860 inline void InspectorInstrumentation::didComposite(Frame& frame)
861 {
862     FAST_RETURN_IF_NO_FRONTENDS(void());
863     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
864         didCompositeImpl(*instrumentingAgents);
865 }
866
867 inline void InspectorInstrumentation::willPaint(RenderObject& renderer)
868 {
869     FAST_RETURN_IF_NO_FRONTENDS(void());
870     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
871         return willPaintImpl(*instrumentingAgents, renderer);
872 }
873
874 inline void InspectorInstrumentation::didPaint(RenderObject& renderer, const LayoutRect& rect)
875 {
876     FAST_RETURN_IF_NO_FRONTENDS(void());
877     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
878         didPaintImpl(*instrumentingAgents, renderer, rect);
879 }
880
881 inline InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyle(Document& document)
882 {
883     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
884     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
885         return willRecalculateStyleImpl(*instrumentingAgents, document);
886     return InspectorInstrumentationCookie();
887 }
888
889 inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrumentationCookie& cookie)
890 {
891     FAST_RETURN_IF_NO_FRONTENDS(void());
892     if (cookie.isValid())
893         didRecalculateStyleImpl(cookie);
894 }
895
896 inline void InspectorInstrumentation::didScheduleStyleRecalculation(Document& document)
897 {
898     FAST_RETURN_IF_NO_FRONTENDS(void());
899     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
900         didScheduleStyleRecalculationImpl(*instrumentingAgents, document);
901 }
902
903 inline void InspectorInstrumentation::applyEmulatedMedia(Frame& frame, String& media)
904 {
905     FAST_RETURN_IF_NO_FRONTENDS(void());
906     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
907         applyEmulatedMediaImpl(*instrumentingAgents, media);
908 }
909
910 inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
911 {
912     FAST_RETURN_IF_NO_FRONTENDS(void());
913     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
914         willSendRequestImpl(*instrumentingAgents, identifier, loader, request, redirectResponse);
915 }
916
917 inline void InspectorInstrumentation::willSendRequest(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, ResourceRequest& request)
918 {
919     FAST_RETURN_IF_NO_FRONTENDS(void());
920     willSendRequestImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, request, ResourceResponse { });
921 }
922
923 inline void InspectorInstrumentation::willSendRequestOfType(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, LoadType loadType)
924 {
925     FAST_RETURN_IF_NO_FRONTENDS(void());
926     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
927         willSendRequestOfTypeImpl(*instrumentingAgents, identifier, loader, request, loadType);
928 }
929
930 inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page& page, DocumentLoader* loader, CachedResource* resource)
931 {
932     FAST_RETURN_IF_NO_FRONTENDS(void());
933     didLoadResourceFromMemoryCacheImpl(instrumentingAgentsForPage(page), loader, resource);
934 }
935
936 inline void InspectorInstrumentation::didReceiveResourceResponse(Frame& frame, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
937 {
938     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
939         didReceiveResourceResponseImpl(*instrumentingAgents, identifier, loader, response, resourceLoader);
940 }
941
942 inline void InspectorInstrumentation::didReceiveResourceResponse(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceResponse& response)
943 {
944     didReceiveResourceResponseImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, response, nullptr);
945 }
946
947 inline void InspectorInstrumentation::didReceiveThreadableLoaderResponse(DocumentThreadableLoader& documentThreadableLoader, unsigned long identifier)
948 {
949     FAST_RETURN_IF_NO_FRONTENDS(void());
950     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(documentThreadableLoader.document()))
951         didReceiveThreadableLoaderResponseImpl(*instrumentingAgents, documentThreadableLoader, identifier);
952 }
953     
954 inline void InspectorInstrumentation::didReceiveData(Frame* frame, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
955 {
956     FAST_RETURN_IF_NO_FRONTENDS(void());
957     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
958         didReceiveDataImpl(*instrumentingAgents, identifier, data, dataLength, encodedDataLength);
959 }
960
961 inline void InspectorInstrumentation::didReceiveData(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const char* data, int dataLength)
962 {
963     FAST_RETURN_IF_NO_FRONTENDS(void());
964     didReceiveDataImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, data, dataLength, dataLength);
965 }
966
967 inline void InspectorInstrumentation::didFinishLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const NetworkLoadMetrics& networkLoadMetrics, ResourceLoader* resourceLoader)
968 {
969     FAST_RETURN_IF_NO_FRONTENDS(void());
970     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
971         didFinishLoadingImpl(*instrumentingAgents, identifier, loader, networkLoadMetrics, resourceLoader);
972 }
973
974 inline void InspectorInstrumentation::didFinishLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const NetworkLoadMetrics& networkLoadMetrics)
975 {
976     FAST_RETURN_IF_NO_FRONTENDS(void());
977     didFinishLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, networkLoadMetrics, nullptr);
978 }
979
980 inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
981 {
982     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
983         didFailLoadingImpl(*instrumentingAgents, identifier, loader, error);
984 }
985
986 inline void InspectorInstrumentation::didFailLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceError& error)
987 {
988     didFailLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, error);
989 }
990
991 inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
992 {
993     // Treat the same as didReceiveResponse.
994     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
995         didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
996 }
997
998 inline void InspectorInstrumentation::continueWithPolicyDownload(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
999 {
1000     // Treat the same as didReceiveResponse.
1001     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1002         didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1003 }
1004
1005 inline void InspectorInstrumentation::continueWithPolicyIgnore(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1006 {
1007     // Treat the same as didReceiveResponse.
1008     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1009         didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1010 }
1011
1012 inline void InspectorInstrumentation::willLoadXHRSynchronously(ScriptExecutionContext* context)
1013 {
1014     FAST_RETURN_IF_NO_FRONTENDS(void());
1015     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1016         willLoadXHRSynchronouslyImpl(*instrumentingAgents);
1017 }
1018
1019 inline void InspectorInstrumentation::didLoadXHRSynchronously(ScriptExecutionContext* context)
1020 {
1021     FAST_RETURN_IF_NO_FRONTENDS(void());
1022     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1023         didLoadXHRSynchronouslyImpl(*instrumentingAgents);
1024 }
1025
1026 inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext& context, unsigned long identifier, const String& sourceString)
1027 {
1028     FAST_RETURN_IF_NO_FRONTENDS(void());
1029     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1030         scriptImportedImpl(*instrumentingAgents, identifier, sourceString);
1031 }
1032
1033 inline void InspectorInstrumentation::scriptExecutionBlockedByCSP(ScriptExecutionContext* context, const String& directiveText)
1034 {
1035     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1036         scriptExecutionBlockedByCSPImpl(*instrumentingAgents, directiveText);
1037 }
1038
1039 inline void InspectorInstrumentation::didReceiveScriptResponse(ScriptExecutionContext* context, unsigned long identifier)
1040 {
1041     FAST_RETURN_IF_NO_FRONTENDS(void());
1042     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1043         didReceiveScriptResponseImpl(*instrumentingAgents, identifier);
1044 }
1045
1046 inline void InspectorInstrumentation::domContentLoadedEventFired(Frame& frame)
1047 {
1048     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1049         domContentLoadedEventFiredImpl(*instrumentingAgents, frame);
1050 }
1051
1052 inline void InspectorInstrumentation::loadEventFired(Frame* frame)
1053 {
1054     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1055         loadEventFiredImpl(*instrumentingAgents, frame);
1056 }
1057
1058 inline void InspectorInstrumentation::frameDetachedFromParent(Frame& frame)
1059 {
1060     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1061         frameDetachedFromParentImpl(*instrumentingAgents, frame);
1062 }
1063
1064 inline void InspectorInstrumentation::didCommitLoad(Frame& frame, DocumentLoader* loader)
1065 {
1066     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1067         didCommitLoadImpl(*instrumentingAgents, frame, loader);
1068 }
1069
1070 inline void InspectorInstrumentation::frameDocumentUpdated(Frame& frame)
1071 {
1072     FAST_RETURN_IF_NO_FRONTENDS(void());
1073     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1074         frameDocumentUpdatedImpl(*instrumentingAgents, frame);
1075 }
1076
1077 inline void InspectorInstrumentation::loaderDetachedFromFrame(Frame& frame, DocumentLoader& loader)
1078 {
1079     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1080         loaderDetachedFromFrameImpl(*instrumentingAgents, loader);
1081 }
1082
1083 inline void InspectorInstrumentation::frameStartedLoading(Frame& frame)
1084 {
1085     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1086         frameStartedLoadingImpl(*instrumentingAgents, frame);
1087 }
1088
1089 inline void InspectorInstrumentation::frameStoppedLoading(Frame& frame)
1090 {
1091     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1092         frameStoppedLoadingImpl(*instrumentingAgents, frame);
1093 }
1094
1095 inline void InspectorInstrumentation::frameScheduledNavigation(Frame& frame, Seconds delay)
1096 {
1097     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1098         frameScheduledNavigationImpl(*instrumentingAgents, frame, delay);
1099 }
1100
1101 inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame& frame)
1102 {
1103     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1104         frameClearedScheduledNavigationImpl(*instrumentingAgents, frame);
1105 }
1106
1107 inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource& cachedResource)
1108 {
1109     FAST_RETURN_IF_NO_FRONTENDS(void());
1110     willDestroyCachedResourceImpl(cachedResource);
1111 }
1112
1113 inline void InspectorInstrumentation::didOpenDatabase(ScriptExecutionContext* context, RefPtr<Database>&& database, const String& domain, const String& name, const String& version)
1114 {
1115     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1116         didOpenDatabaseImpl(*instrumentingAgents, WTFMove(database), domain, name, version);
1117 }
1118
1119 inline void InspectorInstrumentation::didDispatchDOMStorageEvent(Page& page, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin)
1120 {
1121     FAST_RETURN_IF_NO_FRONTENDS(void());
1122     didDispatchDOMStorageEventImpl(instrumentingAgentsForPage(page), key, oldValue, newValue, storageType, securityOrigin);
1123 }
1124
1125 inline bool InspectorInstrumentation::shouldWaitForDebuggerOnStart(ScriptExecutionContext& context)
1126 {
1127     FAST_RETURN_IF_NO_FRONTENDS(false);
1128     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1129         return shouldWaitForDebuggerOnStartImpl(*instrumentingAgents);
1130     return false;
1131 }
1132
1133 inline void InspectorInstrumentation::workerStarted(ScriptExecutionContext& context, WorkerInspectorProxy* proxy, const URL& url)
1134 {
1135     FAST_RETURN_IF_NO_FRONTENDS(void());
1136     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1137         workerStartedImpl(*instrumentingAgents, proxy, url);
1138 }
1139
1140 inline void InspectorInstrumentation::workerTerminated(ScriptExecutionContext& context, WorkerInspectorProxy* proxy)
1141 {
1142     FAST_RETURN_IF_NO_FRONTENDS(void());
1143     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1144         workerTerminatedImpl(*instrumentingAgents, proxy);
1145 }
1146
1147 inline void InspectorInstrumentation::didCreateWebSocket(Document* document, unsigned long identifier, const URL& requestURL)
1148 {
1149     FAST_RETURN_IF_NO_FRONTENDS(void());
1150     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1151         didCreateWebSocketImpl(*instrumentingAgents, identifier, requestURL);
1152 }
1153
1154 inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(Document* document, unsigned long identifier, const ResourceRequest& request)
1155 {
1156     FAST_RETURN_IF_NO_FRONTENDS(void());
1157     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1158         willSendWebSocketHandshakeRequestImpl(*instrumentingAgents, identifier, request);
1159 }
1160
1161 inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(Document* document, unsigned long identifier, const ResourceResponse& response)
1162 {
1163     FAST_RETURN_IF_NO_FRONTENDS(void());
1164     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1165         didReceiveWebSocketHandshakeResponseImpl(*instrumentingAgents, identifier, response);
1166 }
1167
1168 inline void InspectorInstrumentation::didCloseWebSocket(Document* document, unsigned long identifier)
1169 {
1170     FAST_RETURN_IF_NO_FRONTENDS(void());
1171     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1172         didCloseWebSocketImpl(*instrumentingAgents, identifier);
1173 }
1174
1175 inline void InspectorInstrumentation::didReceiveWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1176 {
1177     FAST_RETURN_IF_NO_FRONTENDS(void());
1178     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1179         didReceiveWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1180 }
1181
1182 inline void InspectorInstrumentation::didReceiveWebSocketFrameError(Document* document, unsigned long identifier, const String& errorMessage)
1183 {
1184     FAST_RETURN_IF_NO_FRONTENDS(void());
1185     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1186         didReceiveWebSocketFrameErrorImpl(*instrumentingAgents, identifier, errorMessage);
1187 }
1188
1189 inline void InspectorInstrumentation::didSendWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1190 {
1191     FAST_RETURN_IF_NO_FRONTENDS(void());
1192     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1193         didSendWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1194 }
1195
1196 #if ENABLE(RESOURCE_USAGE)
1197 inline void InspectorInstrumentation::didHandleMemoryPressure(Page& page, Critical critical)
1198 {
1199     FAST_RETURN_IF_NO_FRONTENDS(void());
1200     didHandleMemoryPressureImpl(instrumentingAgentsForPage(page), critical);
1201 }
1202 #endif
1203
1204 inline void InspectorInstrumentation::didChangeCSSCanvasClientNodes(CanvasBase& canvasBase)
1205 {
1206     FAST_RETURN_IF_NO_FRONTENDS(void());
1207     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(canvasBase.scriptExecutionContext()))
1208         didChangeCSSCanvasClientNodesImpl(*instrumentingAgents, canvasBase);
1209 }
1210
1211 inline void InspectorInstrumentation::didCreateCanvasRenderingContext(CanvasRenderingContext& context)
1212 {
1213     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1214         didCreateCanvasRenderingContextImpl(*instrumentingAgents, context);
1215 }
1216
1217 inline void InspectorInstrumentation::didChangeCanvasMemory(CanvasRenderingContext& context)
1218 {
1219     FAST_RETURN_IF_NO_FRONTENDS(void());
1220     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1221         didChangeCanvasMemoryImpl(*instrumentingAgents, context);
1222 }
1223
1224 inline void InspectorInstrumentation::recordCanvasAction(CanvasRenderingContext& context, const String& name, Vector<RecordCanvasActionVariant>&& parameters)
1225 {
1226     FAST_RETURN_IF_NO_FRONTENDS(void());
1227     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1228         recordCanvasActionImpl(*instrumentingAgents, context, name, WTFMove(parameters));
1229 }
1230
1231 inline void InspectorInstrumentation::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch)
1232 {
1233     FAST_RETURN_IF_NO_FRONTENDS(void());
1234     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1235         didFinishRecordingCanvasFrameImpl(*instrumentingAgents, context, forceDispatch);
1236 }
1237
1238 #if ENABLE(WEBGL)
1239 inline void InspectorInstrumentation::didEnableExtension(WebGLRenderingContextBase& contextWebGLBase, const String& extension)
1240 {
1241     FAST_RETURN_IF_NO_FRONTENDS(void());
1242     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1243         didEnableExtensionImpl(*instrumentingAgents, contextWebGLBase, extension);
1244 }
1245
1246 inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1247 {
1248     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1249         didCreateProgramImpl(*instrumentingAgents, contextWebGLBase, program);
1250 }
1251
1252 inline void InspectorInstrumentation::willDeleteProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1253 {
1254     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1255         willDeleteProgramImpl(*instrumentingAgents, program);
1256 }
1257
1258 inline bool InspectorInstrumentation::isShaderProgramDisabled(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1259 {
1260     FAST_RETURN_IF_NO_FRONTENDS(false);
1261     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1262         return isShaderProgramDisabledImpl(*instrumentingAgents, program);
1263     return false;
1264 }
1265
1266 inline bool InspectorInstrumentation::isShaderProgramHighlighted(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1267 {
1268     FAST_RETURN_IF_NO_FRONTENDS(false);
1269     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1270         return isShaderProgramHighlightedImpl(*instrumentingAgents, program);
1271     return false;
1272 }
1273 #endif
1274
1275 inline void InspectorInstrumentation::networkStateChanged(Page& page)
1276 {
1277     FAST_RETURN_IF_NO_FRONTENDS(void());
1278     networkStateChangedImpl(instrumentingAgentsForPage(page));
1279 }
1280
1281 inline void InspectorInstrumentation::updateApplicationCacheStatus(Frame* frame)
1282 {
1283     FAST_RETURN_IF_NO_FRONTENDS(void());
1284     if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1285         updateApplicationCacheStatusImpl(*instrumentingAgents, *frame);
1286 }
1287
1288 inline void InspectorInstrumentation::addMessageToConsole(Page& page, std::unique_ptr<Inspector::ConsoleMessage> message)
1289 {
1290     addMessageToConsoleImpl(instrumentingAgentsForPage(page), WTFMove(message));
1291 }
1292
1293 inline void InspectorInstrumentation::addMessageToConsole(WorkerGlobalScope& workerGlobalScope, std::unique_ptr<Inspector::ConsoleMessage> message)
1294 {
1295     addMessageToConsoleImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), WTFMove(message));
1296 }
1297
1298 inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)
1299 {
1300     consoleCountImpl(instrumentingAgentsForPage(page), state, WTFMove(arguments));
1301 }
1302
1303 inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)
1304 {
1305     consoleCountImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, WTFMove(arguments));
1306 }
1307
1308 inline void InspectorInstrumentation::takeHeapSnapshot(Frame& frame, const String& title)
1309 {
1310     FAST_RETURN_IF_NO_FRONTENDS(void());
1311     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1312         takeHeapSnapshotImpl(*instrumentingAgents, title);
1313 }
1314
1315 inline void InspectorInstrumentation::startConsoleTiming(Frame& frame, const String& title)
1316 {
1317     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1318         startConsoleTimingImpl(*instrumentingAgents, frame, title);
1319 }
1320
1321 inline void InspectorInstrumentation::startConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title)
1322 {
1323     startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title);
1324 }
1325
1326 inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptCallStack>&& stack)
1327 {
1328     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1329         stopConsoleTimingImpl(*instrumentingAgents, frame, title, WTFMove(stack));
1330 }
1331
1332 inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title, Ref<Inspector::ScriptCallStack>&& stack)
1333 {
1334     stopConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title, WTFMove(stack));
1335 }
1336
1337 inline void InspectorInstrumentation::consoleTimeStamp(Frame& frame, Ref<Inspector::ScriptArguments>&& arguments)
1338 {
1339     FAST_RETURN_IF_NO_FRONTENDS(void());
1340     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1341         consoleTimeStampImpl(*instrumentingAgents, frame, WTFMove(arguments));
1342 }
1343
1344 inline void InspectorInstrumentation::startProfiling(Page& page, JSC::ExecState* exec, const String &title)
1345 {
1346     startProfilingImpl(instrumentingAgentsForPage(page), exec, title);
1347 }
1348
1349 inline void InspectorInstrumentation::stopProfiling(Page& page, JSC::ExecState* exec, const String &title)
1350 {
1351     stopProfilingImpl(instrumentingAgentsForPage(page), exec, title);
1352 }
1353
1354 inline void InspectorInstrumentation::consoleStartRecordingCanvas(CanvasRenderingContext& context, JSC::ExecState& exec, JSC::JSObject* options)
1355 {
1356     FAST_RETURN_IF_NO_FRONTENDS(void());
1357     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1358         consoleStartRecordingCanvasImpl(*instrumentingAgents, context, exec, options);
1359 }
1360
1361 inline void InspectorInstrumentation::didRequestAnimationFrame(Document& document, int callbackId)
1362 {
1363     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1364         didRequestAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1365 }
1366
1367 inline void InspectorInstrumentation::didCancelAnimationFrame(Document& document, int callbackId)
1368 {
1369     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1370         didCancelAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1371 }
1372
1373 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrame(Document& document, int callbackId)
1374 {
1375     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1376         return willFireAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1377     return InspectorInstrumentationCookie();
1378 }
1379
1380 inline void InspectorInstrumentation::didFireAnimationFrame(const InspectorInstrumentationCookie& cookie)
1381 {
1382     FAST_RETURN_IF_NO_FRONTENDS(void());
1383     if (cookie.isValid())
1384         didFireAnimationFrameImpl(cookie);
1385 }
1386
1387 inline void InspectorInstrumentation::layerTreeDidChange(Page* page)
1388 {
1389     FAST_RETURN_IF_NO_FRONTENDS(void());
1390     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1391         layerTreeDidChangeImpl(*instrumentingAgents);
1392 }
1393
1394 inline void InspectorInstrumentation::renderLayerDestroyed(Page* page, const RenderLayer& renderLayer)
1395 {
1396     FAST_RETURN_IF_NO_FRONTENDS(void());
1397     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1398         renderLayerDestroyedImpl(*instrumentingAgents, renderLayer);
1399 }
1400
1401 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext* context)
1402 {
1403     return context ? instrumentingAgentsForContext(*context) : nullptr;
1404 }
1405
1406 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext& context)
1407 {
1408     if (is<Document>(context))
1409         return instrumentingAgentsForPage(downcast<Document>(context).page());
1410     if (is<WorkerGlobalScope>(context))
1411         return &instrumentingAgentsForWorkerGlobalScope(downcast<WorkerGlobalScope>(context));
1412     return nullptr;
1413 }
1414
1415 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(Frame* frame)
1416 {
1417     return frame ? instrumentingAgentsForFrame(*frame) : nullptr;
1418 }
1419
1420 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(Frame& frame)
1421 {
1422     return instrumentingAgentsForPage(frame.page());
1423 }
1424
1425 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document* document)
1426 {
1427     return document ? instrumentingAgentsForDocument(*document) : nullptr;
1428 }
1429
1430 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document& document)
1431 {
1432     Page* page = document.page();
1433     if (!page && document.templateDocumentHost())
1434         page = document.templateDocumentHost()->page();
1435     return instrumentingAgentsForPage(page);
1436 }
1437
1438 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForPage(Page* page)
1439 {
1440     return page ? &instrumentingAgentsForPage(*page) : nullptr;
1441 }
1442
1443 inline InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForPage(Page& page)
1444 {
1445     ASSERT(isMainThread());
1446     return page.inspectorController().m_instrumentingAgents.get();
1447 }
1448
1449 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope* workerGlobalScope)
1450 {
1451     return workerGlobalScope ? &instrumentingAgentsForWorkerGlobalScope(*workerGlobalScope) : nullptr;
1452 }
1453
1454 inline InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope& workerGlobalScope)
1455 {
1456     return workerGlobalScope.inspectorController().m_instrumentingAgents;
1457 }
1458
1459 inline void InspectorInstrumentation::frontendCreated()
1460 {
1461     s_frontendCounter++;
1462
1463     if (s_frontendCounter == 1)
1464         InspectorInstrumentation::firstFrontendCreated();
1465 }
1466
1467 inline void InspectorInstrumentation::frontendDeleted()
1468 {
1469     s_frontendCounter--;
1470
1471     if (!s_frontendCounter)
1472         InspectorInstrumentation::lastFrontendDeleted();
1473 }
1474
1475 } // namespace WebCore