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