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