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