1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef InspectorInstrumentation_h
32 #define InspectorInstrumentation_h
33
34 #include "Console.h"
35 #include "Frame.h"
36 #include "Page.h"
37 #include "ScriptExecutionContext.h"
38 #include <wtf/HashMap.h>
39
40 namespace WebCore {
41
42 class CharacterData;
43 class DOMWrapperWorld;
44 class Database;
45 class Document;
46 class Element;
47 class EventContext;
48 class DocumentLoader;
49 class HitTestResult;
50 class InspectorAgent;
51 class InspectorPageAgent;
52 class InspectorResourceAgent;
53 class InspectorTimelineAgent;
54 class KURL;
55 class Node;
56 class ResourceRequest;
57 class ResourceResponse;
58 class ScriptArguments;
59 class ScriptCallStack;
60 class ScriptExecutionContext;
61 class StorageArea;
62 class XMLHttpRequest;
63
64 #if ENABLE(WEB_SOCKETS)
65 class WebSocketHandshakeRequest;
66 class WebSocketHandshakeResponse;
67 #endif
68
69 typedef pair<InspectorAgent*, int> InspectorInstrumentationCookie;
70
71 class InspectorInstrumentation {
72 public:
73 static void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
74 static void inspectedPageDestroyed(Page*);
75
76 static void willInsertDOMNode(Document*, Node*, Node* parent);
77 static void didInsertDOMNode(Document*, Node*);
78 static void willRemoveDOMNode(Document*, Node*);
79 static void willModifyDOMAttr(Document*, Element*);
80 static void didModifyDOMAttr(Document*, Element*);
81 static void characterDataModified(Document*, CharacterData*);
82 static void didInvalidateStyleAttr(Document*, Node*);
83
84 static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags);
85 static bool handleMousePress(Page*);
86
87 static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
88 static void didScheduleResourceRequest(Document*, const String& url);
89 static void didInstallTimer(ScriptExecutionContext*, int timerId, int timeout, bool singleShot);
90 static void didRemoveTimer(ScriptExecutionContext*, int timerId);
91
92 static InspectorInstrumentationCookie willCallFunction(Frame*, const String& scriptName, int scriptLine);
93 static void didCallFunction(const InspectorInstrumentationCookie&);
94 static InspectorInstrumentationCookie willChangeXHRReadyState(ScriptExecutionContext*, XMLHttpRequest* request);
95 static void didChangeXHRReadyState(const InspectorInstrumentationCookie&);
96 static InspectorInstrumentationCookie willDispatchEvent(Document*, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors);
97 static void didDispatchEvent(const InspectorInstrumentationCookie&);
98 static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event& event, DOMWindow* window);
99 static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&);
100 static InspectorInstrumentationCookie willEvaluateScript(Frame*, const String& url, int lineNumber);
101 static void didEvaluateScript(const InspectorInstrumentationCookie&);
102 static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext*, int timerId);
103 static void didFireTimer(const InspectorInstrumentationCookie&);
104 static InspectorInstrumentationCookie willLayout(Frame*);
105 static void didLayout(const InspectorInstrumentationCookie&);
106 static InspectorInstrumentationCookie willLoadXHR(ScriptExecutionContext*, XMLHttpRequest*);
107 static void didLoadXHR(const InspectorInstrumentationCookie&);
108 static InspectorInstrumentationCookie willPaint(Frame*, const IntRect& rect);
109 static void didPaint(const InspectorInstrumentationCookie&);
110 static InspectorInstrumentationCookie willRecalculateStyle(Document*);
111 static void didRecalculateStyle(const InspectorInstrumentationCookie&);
112
113 static void applyUserAgentOverride(Frame*, String*);
114 static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
115 static void markResourceAsCached(Page*, unsigned long identifier);
116 static void didLoadResourceFromMemoryCache(Page*, DocumentLoader*, const CachedResource*);
117 static InspectorInstrumentationCookie willReceiveResourceData(Frame*, unsigned long identifier);
118 static void didReceiveResourceData(const InspectorInstrumentationCookie&);
119 static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*, unsigned long identifier, const ResourceResponse&);
120 static void didReceiveResourceResponse(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&);
121 static void continueAfterXFrameOptionsDenied(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
122 static void continueWithPolicyDownload(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
123 static void continueWithPolicyIgnore(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
124 static void didReceiveContentLength(Frame*, unsigned long identifier, int dataLength, int encodedDataLength);
125 static void didFinishLoading(Frame*, unsigned long identifier, double finishTime);
126 static void didFailLoading(Frame*, unsigned long identifier, const ResourceError&);
127 static void resourceRetrievedByXMLHttpRequest(ScriptExecutionContext*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
128 static void scriptImported(ScriptExecutionContext*, unsigned long identifier, const String& sourceString);
129 static void domContentLoadedEventFired(Frame*, const KURL&);
130 static void loadEventFired(Frame*, const KURL&);
131 static void frameDetachedFromParent(Frame*);
132 static void didCommitLoad(Frame*, DocumentLoader*);
133
134 static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine);
135 static void didWriteHTML(const InspectorInstrumentationCookie&, unsigned int endLine);
136
137 static void addMessageToConsole(Page*, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
138 static void addMessageToConsole(Page*, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String&);
139 static void consoleCount(Page*, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
140 static void startConsoleTiming(Page*, const String& title);
141 static void stopConsoleTiming(Page*, const String& title, PassRefPtr<ScriptCallStack>);
142 static void consoleMarkTimeline(Page*, PassRefPtr<ScriptArguments>);
143
144 #if ENABLE(JAVASCRIPT_DEBUGGER)
145 static void addStartProfilingMessageToConsole(Page*, const String& title, unsigned lineNumber, const String& sourceURL);
146 static void addProfile(Page*, RefPtr<ScriptProfile>, PassRefPtr<ScriptCallStack>);
147 static String getCurrentUserInitiatedProfileName(Page*, bool incrementProfileNumber);
148 static bool profilerEnabled(Page*);
149 #endif
150
151 #if ENABLE(DATABASE)
152 static void didOpenDatabase(ScriptExecutionContext*, PassRefPtr<Database>, const String& domain, const String& name, const String& version);
153 #endif
154
155 #if ENABLE(DOM_STORAGE)
156 static void didUseDOMStorage(Page*, StorageArea*, bool isLocalStorage, Frame*);
157 #endif
158
159 #if ENABLE(WORKERS)
160 static void didCreateWorker(ScriptExecutionContext*, intptr_t id, const String& url, bool isSharedWorker);
161 static void didDestroyWorker(ScriptExecutionContext*, intptr_t id);
162 #endif
163
164 #if ENABLE(WEB_SOCKETS)
165 static void didCreateWebSocket(ScriptExecutionContext*, unsigned long identifier, const KURL& requestURL, const KURL& documentURL);
166 static void willSendWebSocketHandshakeRequest(ScriptExecutionContext*, unsigned long identifier, const WebSocketHandshakeRequest&);
167 static void didReceiveWebSocketHandshakeResponse(ScriptExecutionContext*, unsigned long identifier, const WebSocketHandshakeResponse&);
168 static void didCloseWebSocket(ScriptExecutionContext*, unsigned long identifier);
169 #endif
170
171 static void networkStateChanged(Page*);
172
173 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
174 static void updateApplicationCacheStatus(Frame*);
175 #endif
176
177 #if ENABLE(INSPECTOR)
bindInspectorAgent(Page * page,InspectorAgent * inspectorAgent)178 static void bindInspectorAgent(Page* page, InspectorAgent* inspectorAgent) { inspectorAgents().set(page, inspectorAgent); }
unbindInspectorAgent(Page * page)179 static void unbindInspectorAgent(Page* page) { inspectorAgents().remove(page); }
frontendCreated()180 static void frontendCreated() { s_frontendCounter += 1; }
frontendDeleted()181 static void frontendDeleted() { s_frontendCounter -= 1; }
hasFrontends()182 static bool hasFrontends() { return s_frontendCounter; }
183 static bool hasFrontend(Page*);
184 #else
hasFrontends()185 static bool hasFrontends() { return false; }
hasFrontend(Page *)186 static bool hasFrontend(Page*) { return false; }
187 #endif
188
189 private:
190 #if ENABLE(INSPECTOR)
191 static void didClearWindowObjectInWorldImpl(InspectorAgent*, Frame*, DOMWrapperWorld*);
192 static void inspectedPageDestroyedImpl(InspectorAgent*);
193
194 static void willInsertDOMNodeImpl(InspectorAgent*, Node* node, Node* parent);
195 static void didInsertDOMNodeImpl(InspectorAgent*, Node*);
196 static void willRemoveDOMNodeImpl(InspectorAgent*, Node*);
197 static void didRemoveDOMNodeImpl(InspectorAgent*, Node*);
198 static void willModifyDOMAttrImpl(InspectorAgent*, Element*);
199 static void didModifyDOMAttrImpl(InspectorAgent*, Element*);
200 static void characterDataModifiedImpl(InspectorAgent*, CharacterData*);
201 static void didInvalidateStyleAttrImpl(InspectorAgent*, Node*);
202
203 static void mouseDidMoveOverElementImpl(InspectorAgent*, const HitTestResult&, unsigned modifierFlags);
204 static bool handleMousePressImpl(InspectorAgent*);
205
206 static void willSendXMLHttpRequestImpl(InspectorAgent*, const String& url);
207 static void didScheduleResourceRequestImpl(InspectorAgent*, const String& url);
208 static void didInstallTimerImpl(InspectorAgent*, int timerId, int timeout, bool singleShot);
209 static void didRemoveTimerImpl(InspectorAgent*, int timerId);
210
211 static InspectorInstrumentationCookie willCallFunctionImpl(InspectorAgent*, const String& scriptName, int scriptLine);
212 static void didCallFunctionImpl(const InspectorInstrumentationCookie&);
213 static InspectorInstrumentationCookie willChangeXHRReadyStateImpl(InspectorAgent*, XMLHttpRequest* request);
214 static void didChangeXHRReadyStateImpl(const InspectorInstrumentationCookie&);
215 static InspectorInstrumentationCookie willDispatchEventImpl(InspectorAgent*, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors);
216 static void didDispatchEventImpl(const InspectorInstrumentationCookie&);
217 static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InspectorAgent*, const Event& event, DOMWindow* window);
218 static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&);
219 static InspectorInstrumentationCookie willEvaluateScriptImpl(InspectorAgent*, const String& url, int lineNumber);
220 static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&);
221 static InspectorInstrumentationCookie willFireTimerImpl(InspectorAgent*, int timerId);
222 static void didFireTimerImpl(const InspectorInstrumentationCookie&);
223 static InspectorInstrumentationCookie willLayoutImpl(InspectorAgent*);
224 static void didLayoutImpl(const InspectorInstrumentationCookie&);
225 static InspectorInstrumentationCookie willLoadXHRImpl(InspectorAgent*, XMLHttpRequest* request);
226 static void didLoadXHRImpl(const InspectorInstrumentationCookie&);
227 static InspectorInstrumentationCookie willPaintImpl(InspectorAgent*, const IntRect& rect);
228 static void didPaintImpl(const InspectorInstrumentationCookie&);
229 static InspectorInstrumentationCookie willRecalculateStyleImpl(InspectorAgent*);
230 static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
231
232 static void applyUserAgentOverrideImpl(InspectorAgent*, String*);
233 static void willSendRequestImpl(InspectorAgent*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
234 static void markResourceAsCachedImpl(InspectorAgent*, unsigned long identifier);
235 static void didLoadResourceFromMemoryCacheImpl(InspectorAgent*, DocumentLoader*, const CachedResource*);
236 static InspectorInstrumentationCookie willReceiveResourceDataImpl(InspectorAgent*, unsigned long identifier);
237 static void didReceiveResourceDataImpl(const InspectorInstrumentationCookie&);
238 static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InspectorAgent*, unsigned long identifier, const ResourceResponse&);
239 static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&);
240 static void didReceiveResourceResponseButCanceledImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
241 static void continueAfterXFrameOptionsDeniedImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
242 static void continueWithPolicyDownloadImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
243 static void continueWithPolicyIgnoreImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
244 static void didReceiveContentLengthImpl(InspectorAgent*, unsigned long identifier, int dataLength, int encodedDataLength);
245 static void didFinishLoadingImpl(InspectorAgent*, unsigned long identifier, double finishTime);
246 static void didFailLoadingImpl(InspectorAgent*, unsigned long identifier, const ResourceError&);
247 static void resourceRetrievedByXMLHttpRequestImpl(InspectorAgent*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
248 static void scriptImportedImpl(InspectorAgent*, unsigned long identifier, const String& sourceString);
249 static void domContentLoadedEventFiredImpl(InspectorAgent*, Frame*, const KURL&);
250 static void loadEventFiredImpl(InspectorAgent*, Frame*, const KURL&);
251 static void frameDetachedFromParentImpl(InspectorAgent*, Frame*);
252 static void didCommitLoadImpl(Page*, InspectorAgent*, DocumentLoader*);
253
254 static InspectorInstrumentationCookie willWriteHTMLImpl(InspectorAgent*, unsigned int length, unsigned int startLine);
255 static void didWriteHTMLImpl(const InspectorInstrumentationCookie&, unsigned int endLine);
256
257 static void addMessageToConsoleImpl(InspectorAgent*, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
258 static void addMessageToConsoleImpl(InspectorAgent*, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID);
259 static void consoleCountImpl(InspectorAgent*, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
260 static void startConsoleTimingImpl(InspectorAgent*, const String& title);
261 static void stopConsoleTimingImpl(InspectorAgent*, const String& title, PassRefPtr<ScriptCallStack>);
262 static void consoleMarkTimelineImpl(InspectorAgent*, PassRefPtr<ScriptArguments>);
263
264 #if ENABLE(JAVASCRIPT_DEBUGGER)
265 static void addStartProfilingMessageToConsoleImpl(InspectorAgent*, const String& title, unsigned lineNumber, const String& sourceURL);
266 static void addProfileImpl(InspectorAgent*, RefPtr<ScriptProfile>, PassRefPtr<ScriptCallStack>);
267 static String getCurrentUserInitiatedProfileNameImpl(InspectorAgent*, bool incrementProfileNumber);
268 static bool profilerEnabledImpl(InspectorAgent*);
269 #endif
270
271 #if ENABLE(DATABASE)
272 static void didOpenDatabaseImpl(InspectorAgent*, PassRefPtr<Database>, const String& domain, const String& name, const String& version);
273 #endif
274
275 #if ENABLE(DOM_STORAGE)
276 static void didUseDOMStorageImpl(InspectorAgent*, StorageArea*, bool isLocalStorage, Frame*);
277 #endif
278
279 #if ENABLE(WORKERS)
280 static void didCreateWorkerImpl(InspectorAgent*, intptr_t id, const String& url, bool isSharedWorker);
281 static void didDestroyWorkerImpl(InspectorAgent*, intptr_t id);
282 #endif
283
284 #if ENABLE(WEB_SOCKETS)
285 static void didCreateWebSocketImpl(InspectorAgent*, unsigned long identifier, const KURL& requestURL, const KURL& documentURL);
286 static void willSendWebSocketHandshakeRequestImpl(InspectorAgent*, unsigned long identifier, const WebSocketHandshakeRequest&);
287 static void didReceiveWebSocketHandshakeResponseImpl(InspectorAgent*, unsigned long identifier, const WebSocketHandshakeResponse&);
288 static void didCloseWebSocketImpl(InspectorAgent*, unsigned long identifier);
289 #endif
290
291 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
292 static void networkStateChangedImpl(InspectorAgent*);
293 static void updateApplicationCacheStatusImpl(InspectorAgent*, Frame*);
294 #endif
295
296 static InspectorAgent* inspectorAgentForFrame(Frame*);
297 static InspectorAgent* inspectorAgentForContext(ScriptExecutionContext*);
298 static InspectorAgent* inspectorAgentForPage(Page*);
299 static InspectorAgent* inspectorAgentWithFrontendForContext(ScriptExecutionContext*);
300 static InspectorAgent* inspectorAgentWithFrontendForDocument(Document*);
301 static InspectorAgent* inspectorAgentWithFrontendForFrame(Frame*);
302 static InspectorAgent* inspectorAgentWithFrontendForPage(Page*);
303
304 static bool hasFrontend(InspectorAgent*);
305 static void pauseOnNativeEventIfNeeded(InspectorAgent*, const String& categoryType, const String& eventName, bool synchronous);
306 static void cancelPauseOnNativeEvent(InspectorAgent*);
307 static InspectorTimelineAgent* retrieveTimelineAgent(InspectorAgent*);
308 static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
309 static InspectorResourceAgent* retrieveResourceAgent(InspectorAgent*);
310 static InspectorPageAgent* retrievePageAgent(InspectorAgent*);
311
312 static HashMap<Page*, InspectorAgent*>& inspectorAgents();
313 static int s_frontendCounter;
314 #endif
315 };
316
didClearWindowObjectInWorld(Frame * frame,DOMWrapperWorld * world)317 inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world)
318 {
319 #if ENABLE(INSPECTOR)
320 if (InspectorAgent* inspectorAgent = inspectorAgentForFrame(frame))
321 didClearWindowObjectInWorldImpl(inspectorAgent, frame, world);
322 #endif
323 }
324
inspectedPageDestroyed(Page * page)325 inline void InspectorInstrumentation::inspectedPageDestroyed(Page* page)
326 {
327 #if ENABLE(INSPECTOR)
328 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page))
329 inspectedPageDestroyedImpl(inspectorAgent);
330 #endif
331 }
332
willInsertDOMNode(Document * document,Node * node,Node * parent)333 inline void InspectorInstrumentation::willInsertDOMNode(Document* document, Node* node, Node* parent)
334 {
335 #if ENABLE(INSPECTOR)
336 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
337 willInsertDOMNodeImpl(inspectorAgent, node, parent);
338 #endif
339 }
340
didInsertDOMNode(Document * document,Node * node)341 inline void InspectorInstrumentation::didInsertDOMNode(Document* document, Node* node)
342 {
343 #if ENABLE(INSPECTOR)
344 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
345 didInsertDOMNodeImpl(inspectorAgent, node);
346 #endif
347 }
348
willRemoveDOMNode(Document * document,Node * node)349 inline void InspectorInstrumentation::willRemoveDOMNode(Document* document, Node* node)
350 {
351 #if ENABLE(INSPECTOR)
352 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document)) {
353 willRemoveDOMNodeImpl(inspectorAgent, node);
354 didRemoveDOMNodeImpl(inspectorAgent, node);
355 }
356 #endif
357 }
358
willModifyDOMAttr(Document * document,Element * element)359 inline void InspectorInstrumentation::willModifyDOMAttr(Document* document, Element* element)
360 {
361 #if ENABLE(INSPECTOR)
362 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
363 willModifyDOMAttrImpl(inspectorAgent, element);
364 #endif
365 }
366
didModifyDOMAttr(Document * document,Element * element)367 inline void InspectorInstrumentation::didModifyDOMAttr(Document* document, Element* element)
368 {
369 #if ENABLE(INSPECTOR)
370 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
371 didModifyDOMAttrImpl(inspectorAgent, element);
372 #endif
373 }
374
didInvalidateStyleAttr(Document * document,Node * node)375 inline void InspectorInstrumentation::didInvalidateStyleAttr(Document* document, Node* node)
376 {
377 #if ENABLE(INSPECTOR)
378 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
379 didInvalidateStyleAttrImpl(inspectorAgent, node);
380 #endif
381 }
382
mouseDidMoveOverElement(Page * page,const HitTestResult & result,unsigned modifierFlags)383 inline void InspectorInstrumentation::mouseDidMoveOverElement(Page* page, const HitTestResult& result, unsigned modifierFlags)
384 {
385 #if ENABLE(INSPECTOR)
386 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForPage(page))
387 mouseDidMoveOverElementImpl(inspectorAgent, result, modifierFlags);
388 #endif
389 }
390
handleMousePress(Page * page)391 inline bool InspectorInstrumentation::handleMousePress(Page* page)
392 {
393 #if ENABLE(INSPECTOR)
394 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForPage(page))
395 return handleMousePressImpl(inspectorAgent);
396 #endif
397 return false;
398 }
399
characterDataModified(Document * document,CharacterData * characterData)400 inline void InspectorInstrumentation::characterDataModified(Document* document, CharacterData* characterData)
401 {
402 #if ENABLE(INSPECTOR)
403 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
404 characterDataModifiedImpl(inspectorAgent, characterData);
405 #endif
406 }
407
willSendXMLHttpRequest(ScriptExecutionContext * context,const String & url)408 inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url)
409 {
410 #if ENABLE(INSPECTOR)
411 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForContext(context))
412 willSendXMLHttpRequestImpl(inspectorAgent, url);
413 #endif
414 }
415
didScheduleResourceRequest(Document * document,const String & url)416 inline void InspectorInstrumentation::didScheduleResourceRequest(Document* document, const String& url)
417 {
418 #if ENABLE(INSPECTOR)
419 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
420 didScheduleResourceRequestImpl(inspectorAgent, url);
421 #endif
422 }
423
didInstallTimer(ScriptExecutionContext * context,int timerId,int timeout,bool singleShot)424 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, int timeout, bool singleShot)
425 {
426 #if ENABLE(INSPECTOR)
427 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForContext(context))
428 didInstallTimerImpl(inspectorAgent, timerId, timeout, singleShot);
429 #endif
430 }
431
didRemoveTimer(ScriptExecutionContext * context,int timerId)432 inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext* context, int timerId)
433 {
434 #if ENABLE(INSPECTOR)
435 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForContext(context))
436 didRemoveTimerImpl(inspectorAgent, timerId);
437 #endif
438 }
439
440
willCallFunction(Frame * frame,const String & scriptName,int scriptLine)441 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(Frame* frame, const String& scriptName, int scriptLine)
442 {
443 #if ENABLE(INSPECTOR)
444 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForFrame(frame))
445 return willCallFunctionImpl(inspectorAgent, scriptName, scriptLine);
446 #endif
447 return InspectorInstrumentationCookie();
448 }
449
didCallFunction(const InspectorInstrumentationCookie & cookie)450 inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie)
451 {
452 #if ENABLE(INSPECTOR)
453 if (hasFrontends() && cookie.first)
454 didCallFunctionImpl(cookie);
455 #endif
456 }
457
willChangeXHRReadyState(ScriptExecutionContext * context,XMLHttpRequest * request)458 inline InspectorInstrumentationCookie InspectorInstrumentation::willChangeXHRReadyState(ScriptExecutionContext* context, XMLHttpRequest* request)
459 {
460 #if ENABLE(INSPECTOR)
461 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForContext(context))
462 return willChangeXHRReadyStateImpl(inspectorAgent, request);
463 #endif
464 return InspectorInstrumentationCookie();
465 }
466
didChangeXHRReadyState(const InspectorInstrumentationCookie & cookie)467 inline void InspectorInstrumentation::didChangeXHRReadyState(const InspectorInstrumentationCookie& cookie)
468 {
469 #if ENABLE(INSPECTOR)
470 if (hasFrontends() && cookie.first)
471 didChangeXHRReadyStateImpl(cookie);
472 #endif
473 }
474
willDispatchEvent(Document * document,const Event & event,DOMWindow * window,Node * node,const Vector<EventContext> & ancestors)475 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document* document, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors)
476 {
477 #if ENABLE(INSPECTOR)
478 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
479 return willDispatchEventImpl(inspectorAgent, event, window, node, ancestors);
480 #endif
481 return InspectorInstrumentationCookie();
482 }
483
didDispatchEvent(const InspectorInstrumentationCookie & cookie)484 inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie)
485 {
486 #if ENABLE(INSPECTOR)
487 if (hasFrontends() && cookie.first)
488 didDispatchEventImpl(cookie);
489 #endif
490 }
491
willDispatchEventOnWindow(Frame * frame,const Event & event,DOMWindow * window)492 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindow(Frame* frame, const Event& event, DOMWindow* window)
493 {
494 #if ENABLE(INSPECTOR)
495 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForFrame(frame))
496 return willDispatchEventOnWindowImpl(inspectorAgent, event, window);
497 #endif
498 return InspectorInstrumentationCookie();
499 }
500
didDispatchEventOnWindow(const InspectorInstrumentationCookie & cookie)501 inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie)
502 {
503 #if ENABLE(INSPECTOR)
504 if (hasFrontends() && cookie.first)
505 didDispatchEventOnWindowImpl(cookie);
506 #endif
507 }
508
willEvaluateScript(Frame * frame,const String & url,int lineNumber)509 inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame* frame, const String& url, int lineNumber)
510 {
511 #if ENABLE(INSPECTOR)
512 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForFrame(frame))
513 return willEvaluateScriptImpl(inspectorAgent, url, lineNumber);
514 #endif
515 return InspectorInstrumentationCookie();
516 }
517
didEvaluateScript(const InspectorInstrumentationCookie & cookie)518 inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumentationCookie& cookie)
519 {
520 #if ENABLE(INSPECTOR)
521 if (hasFrontends() && cookie.first)
522 didEvaluateScriptImpl(cookie);
523 #endif
524 }
525
willFireTimer(ScriptExecutionContext * context,int timerId)526 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext* context, int timerId)
527 {
528 #if ENABLE(INSPECTOR)
529 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForContext(context))
530 return willFireTimerImpl(inspectorAgent, timerId);
531 #endif
532 return InspectorInstrumentationCookie();
533 }
534
didFireTimer(const InspectorInstrumentationCookie & cookie)535 inline void InspectorInstrumentation::didFireTimer(const InspectorInstrumentationCookie& cookie)
536 {
537 #if ENABLE(INSPECTOR)
538 if (hasFrontends() && cookie.first)
539 didFireTimerImpl(cookie);
540 #endif
541 }
542
willLayout(Frame * frame)543 inline InspectorInstrumentationCookie InspectorInstrumentation::willLayout(Frame* frame)
544 {
545 #if ENABLE(INSPECTOR)
546 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForFrame(frame))
547 return willLayoutImpl(inspectorAgent);
548 #endif
549 return InspectorInstrumentationCookie();
550 }
551
didLayout(const InspectorInstrumentationCookie & cookie)552 inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCookie& cookie)
553 {
554 #if ENABLE(INSPECTOR)
555 if (hasFrontends() && cookie.first)
556 didLayoutImpl(cookie);
557 #endif
558 }
559
willLoadXHR(ScriptExecutionContext * context,XMLHttpRequest * request)560 inline InspectorInstrumentationCookie InspectorInstrumentation::willLoadXHR(ScriptExecutionContext* context, XMLHttpRequest* request)
561 {
562 #if ENABLE(INSPECTOR)
563 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForContext(context))
564 return willLoadXHRImpl(inspectorAgent, request);
565 #endif
566 return InspectorInstrumentationCookie();
567 }
568
didLoadXHR(const InspectorInstrumentationCookie & cookie)569 inline void InspectorInstrumentation::didLoadXHR(const InspectorInstrumentationCookie& cookie)
570 {
571 #if ENABLE(INSPECTOR)
572 if (hasFrontends() && cookie.first)
573 didLoadXHRImpl(cookie);
574 #endif
575 }
576
willPaint(Frame * frame,const IntRect & rect)577 inline InspectorInstrumentationCookie InspectorInstrumentation::willPaint(Frame* frame, const IntRect& rect)
578 {
579 #if ENABLE(INSPECTOR)
580 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForFrame(frame))
581 return willPaintImpl(inspectorAgent, rect);
582 #endif
583 return InspectorInstrumentationCookie();
584 }
585
didPaint(const InspectorInstrumentationCookie & cookie)586 inline void InspectorInstrumentation::didPaint(const InspectorInstrumentationCookie& cookie)
587 {
588 #if ENABLE(INSPECTOR)
589 if (hasFrontends() && cookie.first)
590 didPaintImpl(cookie);
591 #endif
592 }
593
willRecalculateStyle(Document * document)594 inline InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyle(Document* document)
595 {
596 #if ENABLE(INSPECTOR)
597 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
598 return willRecalculateStyleImpl(inspectorAgent);
599 #endif
600 return InspectorInstrumentationCookie();
601 }
602
didRecalculateStyle(const InspectorInstrumentationCookie & cookie)603 inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrumentationCookie& cookie)
604 {
605 #if ENABLE(INSPECTOR)
606 if (hasFrontends() && cookie.first)
607 didRecalculateStyleImpl(cookie);
608 #endif
609 }
610
applyUserAgentOverride(Frame * frame,String * userAgent)611 inline void InspectorInstrumentation::applyUserAgentOverride(Frame* frame, String* userAgent)
612 {
613 #if ENABLE(INSPECTOR)
614 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForFrame(frame))
615 applyUserAgentOverrideImpl(inspectorAgent, userAgent);
616 #endif
617 }
618
willSendRequest(Frame * frame,unsigned long identifier,DocumentLoader * loader,ResourceRequest & request,const ResourceResponse & redirectResponse)619 inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
620 {
621 #if ENABLE(INSPECTOR)
622 if (InspectorAgent* ic = inspectorAgentForFrame(frame))
623 willSendRequestImpl(ic, identifier, loader, request, redirectResponse);
624 #endif
625 }
626
markResourceAsCached(Page * page,unsigned long identifier)627 inline void InspectorInstrumentation::markResourceAsCached(Page* page, unsigned long identifier)
628 {
629 #if ENABLE(INSPECTOR)
630 markResourceAsCachedImpl(inspectorAgentForPage(page), identifier);
631 #endif
632 }
633
didLoadResourceFromMemoryCache(Page * page,DocumentLoader * loader,const CachedResource * resource)634 inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page* page, DocumentLoader* loader, const CachedResource* resource)
635 {
636 #if ENABLE(INSPECTOR)
637 didLoadResourceFromMemoryCacheImpl(inspectorAgentForPage(page), loader, resource);
638 #endif
639 }
640
willReceiveResourceData(Frame * frame,unsigned long identifier)641 inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceData(Frame* frame, unsigned long identifier)
642 {
643 #if ENABLE(INSPECTOR)
644 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForFrame(frame))
645 return willReceiveResourceDataImpl(inspectorAgent, identifier);
646 #endif
647 return InspectorInstrumentationCookie();
648 }
649
didReceiveResourceData(const InspectorInstrumentationCookie & cookie)650 inline void InspectorInstrumentation::didReceiveResourceData(const InspectorInstrumentationCookie& cookie)
651 {
652 #if ENABLE(INSPECTOR)
653 if (hasFrontends() && cookie.first)
654 didReceiveResourceDataImpl(cookie);
655 #endif
656 }
657
willReceiveResourceResponse(Frame * frame,unsigned long identifier,const ResourceResponse & response)658 inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponse(Frame* frame, unsigned long identifier, const ResourceResponse& response)
659 {
660 #if ENABLE(INSPECTOR)
661 if (InspectorAgent* inspectorAgent = inspectorAgentForFrame(frame))
662 return willReceiveResourceResponseImpl(inspectorAgent, identifier, response);
663 #endif
664 return InspectorInstrumentationCookie();
665 }
666
didReceiveResourceResponse(const InspectorInstrumentationCookie & cookie,unsigned long identifier,DocumentLoader * loader,const ResourceResponse & response)667 inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
668 {
669 #if ENABLE(INSPECTOR)
670 // Call this unconditionally so that we're able to log to console with no front-end attached.
671 didReceiveResourceResponseImpl(cookie, identifier, loader, response);
672 #endif
673 }
674
continueAfterXFrameOptionsDenied(Frame * frame,DocumentLoader * loader,unsigned long identifier,const ResourceResponse & r)675 inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
676 {
677 #if ENABLE(INSPECTOR)
678 if (inspectorAgentWithFrontendForFrame(frame))
679 InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl(frame, loader, identifier, r);
680 #endif
681 }
682
continueWithPolicyDownload(Frame * frame,DocumentLoader * loader,unsigned long identifier,const ResourceResponse & r)683 inline void InspectorInstrumentation::continueWithPolicyDownload(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
684 {
685 #if ENABLE(INSPECTOR)
686 if (inspectorAgentWithFrontendForFrame(frame))
687 InspectorInstrumentation::continueWithPolicyDownloadImpl(frame, loader, identifier, r);
688 #endif
689 }
690
continueWithPolicyIgnore(Frame * frame,DocumentLoader * loader,unsigned long identifier,const ResourceResponse & r)691 inline void InspectorInstrumentation::continueWithPolicyIgnore(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
692 {
693 #if ENABLE(INSPECTOR)
694 if (inspectorAgentWithFrontendForFrame(frame))
695 InspectorInstrumentation::continueWithPolicyIgnoreImpl(frame, loader, identifier, r);
696 #endif
697 }
698
didReceiveContentLength(Frame * frame,unsigned long identifier,int dataLength,int encodedDataLength)699 inline void InspectorInstrumentation::didReceiveContentLength(Frame* frame, unsigned long identifier, int dataLength, int encodedDataLength)
700 {
701 #if ENABLE(INSPECTOR)
702 if (InspectorAgent* inspectorAgent = inspectorAgentForFrame(frame))
703 didReceiveContentLengthImpl(inspectorAgent, identifier, dataLength, encodedDataLength);
704 #endif
705 }
706
didFinishLoading(Frame * frame,unsigned long identifier,double finishTime)707 inline void InspectorInstrumentation::didFinishLoading(Frame* frame, unsigned long identifier, double finishTime)
708 {
709 #if ENABLE(INSPECTOR)
710 if (InspectorAgent* inspectorAgent = inspectorAgentForFrame(frame))
711 didFinishLoadingImpl(inspectorAgent, identifier, finishTime);
712 #endif
713 }
714
didFailLoading(Frame * frame,unsigned long identifier,const ResourceError & error)715 inline void InspectorInstrumentation::didFailLoading(Frame* frame, unsigned long identifier, const ResourceError& error)
716 {
717 #if ENABLE(INSPECTOR)
718 if (InspectorAgent* inspectorAgent = inspectorAgentForFrame(frame))
719 didFailLoadingImpl(inspectorAgent, identifier, error);
720 #endif
721 }
722
resourceRetrievedByXMLHttpRequest(ScriptExecutionContext * context,unsigned long identifier,const String & sourceString,const String & url,const String & sendURL,unsigned sendLineNumber)723 inline void InspectorInstrumentation::resourceRetrievedByXMLHttpRequest(ScriptExecutionContext* context, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
724 {
725 #if ENABLE(INSPECTOR)
726 if (InspectorAgent* inspectorAgent = inspectorAgentForContext(context))
727 resourceRetrievedByXMLHttpRequestImpl(inspectorAgent, identifier, sourceString, url, sendURL, sendLineNumber);
728 #endif
729 }
730
scriptImported(ScriptExecutionContext * context,unsigned long identifier,const String & sourceString)731 inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext* context, unsigned long identifier, const String& sourceString)
732 {
733 #if ENABLE(INSPECTOR)
734 if (InspectorAgent* inspectorAgent = inspectorAgentForContext(context))
735 scriptImportedImpl(inspectorAgent, identifier, sourceString);
736 #endif
737 }
738
domContentLoadedEventFired(Frame * frame,const KURL & url)739 inline void InspectorInstrumentation::domContentLoadedEventFired(Frame* frame, const KURL& url)
740 {
741 #if ENABLE(INSPECTOR)
742 if (InspectorAgent* inspectorAgent = inspectorAgentForFrame(frame))
743 domContentLoadedEventFiredImpl(inspectorAgent, frame, url);
744 #endif
745 }
746
loadEventFired(Frame * frame,const KURL & url)747 inline void InspectorInstrumentation::loadEventFired(Frame* frame, const KURL& url)
748 {
749 #if ENABLE(INSPECTOR)
750 if (InspectorAgent* inspectorAgent = inspectorAgentForFrame(frame))
751 loadEventFiredImpl(inspectorAgent, frame, url);
752 #endif
753 }
754
frameDetachedFromParent(Frame * frame)755 inline void InspectorInstrumentation::frameDetachedFromParent(Frame* frame)
756 {
757 #if ENABLE(INSPECTOR)
758 if (InspectorAgent* inspectorAgent = inspectorAgentForFrame(frame))
759 frameDetachedFromParentImpl(inspectorAgent, frame);
760 #endif
761 }
762
didCommitLoad(Frame * frame,DocumentLoader * loader)763 inline void InspectorInstrumentation::didCommitLoad(Frame* frame, DocumentLoader* loader)
764 {
765 #if ENABLE(INSPECTOR)
766 if (!frame)
767 return;
768 Page* page = frame->page();
769 if (!page)
770 return;
771 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page))
772 didCommitLoadImpl(page, inspectorAgent, loader);
773 #endif
774 }
775
willWriteHTML(Document * document,unsigned int length,unsigned int startLine)776 inline InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTML(Document* document, unsigned int length, unsigned int startLine)
777 {
778 #if ENABLE(INSPECTOR)
779 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForDocument(document))
780 return willWriteHTMLImpl(inspectorAgent, length, startLine);
781 #endif
782 return InspectorInstrumentationCookie();
783 }
784
didWriteHTML(const InspectorInstrumentationCookie & cookie,unsigned int endLine)785 inline void InspectorInstrumentation::didWriteHTML(const InspectorInstrumentationCookie& cookie, unsigned int endLine)
786 {
787 #if ENABLE(INSPECTOR)
788 if (hasFrontends() && cookie.first)
789 didWriteHTMLImpl(cookie, endLine);
790 #endif
791 }
792
793 #if ENABLE(DOM_STORAGE)
didUseDOMStorage(Page * page,StorageArea * storageArea,bool isLocalStorage,Frame * frame)794 inline void InspectorInstrumentation::didUseDOMStorage(Page* page, StorageArea* storageArea, bool isLocalStorage, Frame* frame)
795 {
796 #if ENABLE(INSPECTOR)
797 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page))
798 didUseDOMStorageImpl(inspectorAgent, storageArea, isLocalStorage, frame);
799 #endif
800 }
801 #endif
802
803 #if ENABLE(WORKERS)
didCreateWorker(ScriptExecutionContext * context,intptr_t id,const String & url,bool isSharedWorker)804 inline void InspectorInstrumentation::didCreateWorker(ScriptExecutionContext* context, intptr_t id, const String& url, bool isSharedWorker)
805 {
806 #if ENABLE(INSPECTOR)
807 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForContext(context))
808 didCreateWorkerImpl(inspectorAgent, id, url, isSharedWorker);
809 #endif
810 }
811
didDestroyWorker(ScriptExecutionContext * context,intptr_t id)812 inline void InspectorInstrumentation::didDestroyWorker(ScriptExecutionContext* context, intptr_t id)
813 {
814 #if ENABLE(INSPECTOR)
815 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForContext(context))
816 didDestroyWorkerImpl(inspectorAgent, id);
817 #endif
818 }
819 #endif
820
821
822 #if ENABLE(WEB_SOCKETS)
didCreateWebSocket(ScriptExecutionContext * context,unsigned long identifier,const KURL & requestURL,const KURL & documentURL)823 inline void InspectorInstrumentation::didCreateWebSocket(ScriptExecutionContext* context, unsigned long identifier, const KURL& requestURL, const KURL& documentURL)
824 {
825 #if ENABLE(INSPECTOR)
826 if (InspectorAgent* inspectorAgent = inspectorAgentForContext(context))
827 didCreateWebSocketImpl(inspectorAgent, identifier, requestURL, documentURL);
828 #endif
829 }
830
willSendWebSocketHandshakeRequest(ScriptExecutionContext * context,unsigned long identifier,const WebSocketHandshakeRequest & request)831 inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(ScriptExecutionContext* context, unsigned long identifier, const WebSocketHandshakeRequest& request)
832 {
833 #if ENABLE(INSPECTOR)
834 if (InspectorAgent* inspectorAgent = inspectorAgentForContext(context))
835 willSendWebSocketHandshakeRequestImpl(inspectorAgent, identifier, request);
836 #endif
837 }
838
didReceiveWebSocketHandshakeResponse(ScriptExecutionContext * context,unsigned long identifier,const WebSocketHandshakeResponse & response)839 inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(ScriptExecutionContext* context, unsigned long identifier, const WebSocketHandshakeResponse& response)
840 {
841 #if ENABLE(INSPECTOR)
842 if (InspectorAgent* inspectorAgent = inspectorAgentForContext(context))
843 didReceiveWebSocketHandshakeResponseImpl(inspectorAgent, identifier, response);
844 #endif
845 }
846
didCloseWebSocket(ScriptExecutionContext * context,unsigned long identifier)847 inline void InspectorInstrumentation::didCloseWebSocket(ScriptExecutionContext* context, unsigned long identifier)
848 {
849 #if ENABLE(INSPECTOR)
850 if (InspectorAgent* inspectorAgent = inspectorAgentForContext(context))
851 didCloseWebSocketImpl(inspectorAgent, identifier);
852 #endif
853 }
854 #endif
855
networkStateChanged(Page * page)856 inline void InspectorInstrumentation::networkStateChanged(Page* page)
857 {
858 #if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS)
859 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForPage(page))
860 networkStateChangedImpl(inspectorAgent);
861 #endif
862 }
863
864 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
updateApplicationCacheStatus(Frame * frame)865 inline void InspectorInstrumentation::updateApplicationCacheStatus(Frame* frame)
866 {
867 #if ENABLE(INSPECTOR)
868 if (InspectorAgent* inspectorAgent = inspectorAgentWithFrontendForFrame(frame))
869 updateApplicationCacheStatusImpl(inspectorAgent, frame);
870 #endif
871 }
872 #endif
873
874 #if ENABLE(INSPECTOR)
hasFrontend(Page * page)875 inline bool InspectorInstrumentation::hasFrontend(Page* page)
876 {
877 return inspectorAgentWithFrontendForPage(page);
878 }
879 #endif
880
881
882 #if ENABLE(INSPECTOR)
inspectorAgentForContext(ScriptExecutionContext * context)883 inline InspectorAgent* InspectorInstrumentation::inspectorAgentForContext(ScriptExecutionContext* context)
884 {
885 if (context && context->isDocument())
886 return inspectorAgentForPage(static_cast<Document*>(context)->page());
887 return 0;
888 }
889
inspectorAgentForFrame(Frame * frame)890 inline InspectorAgent* InspectorInstrumentation::inspectorAgentForFrame(Frame* frame)
891 {
892 if (frame)
893 return inspectorAgentForPage(frame->page());
894 return 0;
895 }
896
inspectorAgentForPage(Page * page)897 inline InspectorAgent* InspectorInstrumentation::inspectorAgentForPage(Page* page)
898 {
899 if (!page)
900 return 0;
901 return inspectorAgents().get(page);
902 }
903
inspectorAgentWithFrontendForContext(ScriptExecutionContext * context)904 inline InspectorAgent* InspectorInstrumentation::inspectorAgentWithFrontendForContext(ScriptExecutionContext* context)
905 {
906 if (hasFrontends() && context && context->isDocument())
907 return inspectorAgentWithFrontendForPage(static_cast<Document*>(context)->page());
908 return 0;
909 }
910
inspectorAgentWithFrontendForDocument(Document * document)911 inline InspectorAgent* InspectorInstrumentation::inspectorAgentWithFrontendForDocument(Document* document)
912 {
913 if (hasFrontends() && document)
914 return inspectorAgentWithFrontendForPage(document->page());
915 return 0;
916 }
917
inspectorAgentWithFrontendForFrame(Frame * frame)918 inline InspectorAgent* InspectorInstrumentation::inspectorAgentWithFrontendForFrame(Frame* frame)
919 {
920 if (hasFrontends() && frame)
921 return inspectorAgentWithFrontendForPage(frame->page());
922 return 0;
923 }
924
inspectorAgentWithFrontendForPage(Page * page)925 inline InspectorAgent* InspectorInstrumentation::inspectorAgentWithFrontendForPage(Page* page)
926 {
927 if (page) {
928 if (InspectorAgent* inspectorAgent = inspectorAgentForPage(page)) {
929 if (hasFrontend(inspectorAgent))
930 return inspectorAgent;
931 }
932 }
933 return 0;
934 }
935
936 #endif
937
938 } // namespace WebCore
939
940 #endif // !defined(InspectorInstrumentation_h)
941