Second unreviewed build fix for r95941
[WebKit-https.git] / Source / WebCore / inspector / InspectorInstrumentation.cpp
1 /*
2 * Copyright (C) 2011 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 #include "config.h"
32 #include "InspectorInstrumentation.h"
33
34 #if ENABLE(INSPECTOR)
35
36 #include "DOMWindow.h"
37 #include "Database.h"
38 #include "DocumentLoader.h"
39 #include "Event.h"
40 #include "EventContext.h"
41 #include "InspectorAgent.h"
42 #include "InspectorApplicationCacheAgent.h"
43 #include "InspectorDOMDebuggerAgent.h"
44 #include "InspectorCSSAgent.h"
45 #include "InspectorConsoleAgent.h"
46 #include "InspectorDatabaseAgent.h"
47 #include "InspectorDOMAgent.h"
48 #include "InspectorDOMStorageAgent.h"
49 #include "InspectorDebuggerAgent.h"
50 #include "InspectorPageAgent.h"
51 #include "InspectorProfilerAgent.h"
52 #include "InspectorResourceAgent.h"
53 #include "InspectorTimelineAgent.h"
54 #include "InspectorWorkerAgent.h"
55 #include "InstrumentingAgents.h"
56 #include "ScriptArguments.h"
57 #include "ScriptCallStack.h"
58 #include "ScriptProfile.h"
59 #include "XMLHttpRequest.h"
60 #include <wtf/StdLibExtras.h>
61 #include <wtf/text/CString.h>
62
63 namespace WebCore {
64
65 static const char* const listenerEventCategoryType = "listener";
66 static const char* const instrumentationEventCategoryType = "instrumentation";
67
68 static const char* const setTimerEventName = "setTimer";
69 static const char* const clearTimerEventName = "clearTimer";
70 static const char* const timerFiredEventName = "timerFired";
71
72 int InspectorInstrumentation::s_frontendCounter = 0;
73
74 static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors)
75 {
76     if (window && window->hasEventListeners(eventType))
77         return true;
78
79     if (node->hasEventListeners(eventType))
80         return true;
81
82     for (size_t i = 0; i < ancestors.size(); i++) {
83         Node* ancestor = ancestors[i].node();
84         if (ancestor->hasEventListeners(eventType))
85             return true;
86     }
87
88     return false;
89 }
90
91 void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, DOMWrapperWorld* world)
92 {
93     if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
94         pageAgent->didClearWindowObjectInWorld(frame, world);
95     if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
96         inspectorAgent->didClearWindowObjectInWorld(frame, world);
97 }
98
99 void InspectorInstrumentation::inspectedPageDestroyedImpl(InstrumentingAgents* instrumentingAgents)
100 {
101     if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
102         inspectorAgent->inspectedPageDestroyed();
103 }
104
105 void InspectorInstrumentation::willInsertDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node, Node* parent)
106 {
107 #if ENABLE(JAVASCRIPT_DEBUGGER)
108     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
109         domDebuggerAgent->willInsertDOMNode(node, parent);
110 #endif
111 }
112
113 void InspectorInstrumentation::didInsertDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node)
114 {
115     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
116         domAgent->didInsertDOMNode(node);
117 #if ENABLE(JAVASCRIPT_DEBUGGER)
118     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
119         domDebuggerAgent->didInsertDOMNode(node);
120 #endif
121 }
122
123 void InspectorInstrumentation::willRemoveDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node)
124 {
125 #if ENABLE(JAVASCRIPT_DEBUGGER)
126     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
127         domDebuggerAgent->willRemoveDOMNode(node);
128 #endif
129 }
130
131 void InspectorInstrumentation::didRemoveDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node)
132 {
133 #if ENABLE(JAVASCRIPT_DEBUGGER)
134     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
135         domDebuggerAgent->didRemoveDOMNode(node);
136 #endif
137     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
138         domAgent->didRemoveDOMNode(node);
139 }
140
141 void InspectorInstrumentation::willModifyDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element)
142 {
143 #if ENABLE(JAVASCRIPT_DEBUGGER)
144     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
145         domDebuggerAgent->willModifyDOMAttr(element);
146 #endif
147 }
148
149 void InspectorInstrumentation::didModifyDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element)
150 {
151     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
152         domAgent->didModifyDOMAttr(element);
153 }
154
155 void InspectorInstrumentation::didInvalidateStyleAttrImpl(InstrumentingAgents* instrumentingAgents, Node* node)
156 {
157     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
158         domAgent->didInvalidateStyleAttr(node);
159 #if ENABLE(JAVASCRIPT_DEBUGGER)
160     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
161         domDebuggerAgent->didInvalidateStyleAttr(node);
162 #endif
163 }
164
165 void InspectorInstrumentation::frameWindowDiscardedImpl(InstrumentingAgents* instrumentingAgents, DOMWindow* window)
166 {
167     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
168         consoleAgent->frameWindowDiscarded(window);
169 }
170
171 void InspectorInstrumentation::mouseDidMoveOverElementImpl(InstrumentingAgents* instrumentingAgents, const HitTestResult& result, unsigned modifierFlags)
172 {
173     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
174         domAgent->mouseDidMoveOverElement(result, modifierFlags);
175 }
176
177 bool InspectorInstrumentation::handleMousePressImpl(InstrumentingAgents* instrumentingAgents)
178 {
179     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
180         return domAgent->handleMousePress();
181     return false;
182 }
183
184 bool InspectorInstrumentation::forcePseudoStateImpl(InstrumentingAgents* instrumentingAgents, Element* element, CSSSelector::PseudoType pseudoState)
185 {
186     if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
187         return cssAgent->forcePseudoState(element, pseudoState);
188     return false;
189 }
190
191 void InspectorInstrumentation::characterDataModifiedImpl(InstrumentingAgents* instrumentingAgents, CharacterData* characterData)
192 {
193     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
194         domAgent->characterDataModified(characterData);
195 }
196
197 void InspectorInstrumentation::willSendXMLHttpRequestImpl(InstrumentingAgents* instrumentingAgents, const String& url)
198 {
199 #if ENABLE(JAVASCRIPT_DEBUGGER)
200     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
201         domDebuggerAgent->willSendXMLHttpRequest(url);
202 #endif
203 }
204
205 void InspectorInstrumentation::didScheduleResourceRequestImpl(InstrumentingAgents* instrumentingAgents, const String& url)
206 {
207     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
208         timelineAgent->didScheduleResourceRequest(url);
209 }
210
211 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents* instrumentingAgents, int timerId, int timeout, bool singleShot)
212 {
213     pauseOnNativeEventIfNeeded(instrumentingAgents, instrumentationEventCategoryType, setTimerEventName, true);
214     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
215         timelineAgent->didInstallTimer(timerId, timeout, singleShot);
216 }
217
218 void InspectorInstrumentation::didRemoveTimerImpl(InstrumentingAgents* instrumentingAgents, int timerId)
219 {
220     pauseOnNativeEventIfNeeded(instrumentingAgents, instrumentationEventCategoryType, clearTimerEventName, true);
221     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
222         timelineAgent->didRemoveTimer(timerId);
223 }
224
225 #if USE(JSC) // It is disabled for JSC see WK-BUG 40119
226 InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(InstrumentingAgents*, const String&, int)
227 {
228     return InspectorInstrumentationCookie();
229 }
230 #else
231 InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(InstrumentingAgents* instrumentingAgents, const String& scriptName, int scriptLine)
232 {
233     int timelineAgentId = 0;
234     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
235         timelineAgent->willCallFunction(scriptName, scriptLine);
236         timelineAgentId = timelineAgent->id();
237     }
238     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
239 }
240 #endif
241
242 void InspectorInstrumentation::didCallFunctionImpl(const InspectorInstrumentationCookie& cookie)
243 {
244     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
245         timelineAgent->didCallFunction();
246 }
247
248 InspectorInstrumentationCookie InspectorInstrumentation::willChangeXHRReadyStateImpl(InstrumentingAgents* instrumentingAgents, XMLHttpRequest* request)
249 {
250     int timelineAgentId = 0;
251     InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
252     if (timelineAgent && request->hasEventListeners(eventNames().readystatechangeEvent)) {
253         timelineAgent->willChangeXHRReadyState(request->url().string(), request->readyState());
254         timelineAgentId = timelineAgent->id();
255     }
256     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
257 }
258
259 void InspectorInstrumentation::didChangeXHRReadyStateImpl(const InspectorInstrumentationCookie& cookie)
260 {
261     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
262         timelineAgent->didChangeXHRReadyState();
263 }
264
265 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InstrumentingAgents* instrumentingAgents, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors)
266 {
267     pauseOnNativeEventIfNeeded(instrumentingAgents, listenerEventCategoryType, event.type(), false);
268
269     int timelineAgentId = 0;
270     InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
271     if (timelineAgent && eventHasListeners(event.type(), window, node, ancestors)) {
272         timelineAgent->willDispatchEvent(event);
273         timelineAgentId = timelineAgent->id();
274     }
275     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
276 }
277
278 void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie)
279 {
280     cancelPauseOnNativeEvent(cookie.first);
281
282     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
283         timelineAgent->didDispatchEvent();
284 }
285
286 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindowImpl(InstrumentingAgents* instrumentingAgents, const Event& event, DOMWindow* window)
287 {
288     pauseOnNativeEventIfNeeded(instrumentingAgents, listenerEventCategoryType, event.type(), false);
289
290     int timelineAgentId = 0;
291     InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
292     if (timelineAgent && window->hasEventListeners(event.type())) {
293         timelineAgent->willDispatchEvent(event);
294         timelineAgentId = timelineAgent->id();
295     }
296     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
297 }
298
299 void InspectorInstrumentation::didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie& cookie)
300 {
301     cancelPauseOnNativeEvent(cookie.first);
302
303     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
304         timelineAgent->didDispatchEvent();
305 }
306
307 InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScriptImpl(InstrumentingAgents* instrumentingAgents, const String& url, int lineNumber)
308 {
309     int timelineAgentId = 0;
310     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
311         timelineAgent->willEvaluateScript(url, lineNumber);
312         timelineAgentId = timelineAgent->id();
313     }
314     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
315 }
316
317 void InspectorInstrumentation::didEvaluateScriptImpl(const InspectorInstrumentationCookie& cookie)
318 {
319     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
320         timelineAgent->didEvaluateScript();
321 }
322
323 InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(InstrumentingAgents* instrumentingAgents, int timerId)
324 {
325     pauseOnNativeEventIfNeeded(instrumentingAgents, instrumentationEventCategoryType, timerFiredEventName, false);
326
327     int timelineAgentId = 0;
328     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
329         timelineAgent->willFireTimer(timerId);
330         timelineAgentId = timelineAgent->id();
331     }
332     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
333 }
334
335 void InspectorInstrumentation::didFireTimerImpl(const InspectorInstrumentationCookie& cookie)
336 {
337     cancelPauseOnNativeEvent(cookie.first);
338
339     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
340         timelineAgent->didFireTimer();
341 }
342
343 InspectorInstrumentationCookie InspectorInstrumentation::willLayoutImpl(InstrumentingAgents* instrumentingAgents)
344 {
345     int timelineAgentId = 0;
346     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
347         timelineAgent->willLayout();
348         timelineAgentId = timelineAgent->id();
349     }
350     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
351 }
352
353 void InspectorInstrumentation::didLayoutImpl(const InspectorInstrumentationCookie& cookie)
354 {
355     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
356         timelineAgent->didLayout();
357 }
358
359 InspectorInstrumentationCookie InspectorInstrumentation::willLoadXHRImpl(InstrumentingAgents* instrumentingAgents, XMLHttpRequest* request)
360 {
361     int timelineAgentId = 0;
362     InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
363     if (timelineAgent && request->hasEventListeners(eventNames().loadEvent)) {
364         timelineAgent->willLoadXHR(request->url());
365         timelineAgentId = timelineAgent->id();
366     }
367     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
368 }
369
370 void InspectorInstrumentation::didLoadXHRImpl(const InspectorInstrumentationCookie& cookie)
371 {
372     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
373         timelineAgent->didLoadXHR();
374 }
375
376 InspectorInstrumentationCookie InspectorInstrumentation::willPaintImpl(InstrumentingAgents* instrumentingAgents, const LayoutRect& rect)
377 {
378     int timelineAgentId = 0;
379     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
380         timelineAgent->willPaint(rect);
381         timelineAgentId = timelineAgent->id();
382     }
383     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
384 }
385
386 void InspectorInstrumentation::didPaintImpl(const InspectorInstrumentationCookie& cookie)
387 {
388     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
389         timelineAgent->didPaint();
390 }
391
392 InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyleImpl(InstrumentingAgents* instrumentingAgents)
393 {
394     int timelineAgentId = 0;
395     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
396         timelineAgent->willRecalculateStyle();
397         timelineAgentId = timelineAgent->id();
398     }
399     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
400         resourceAgent->willRecalculateStyle();
401     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
402 }
403
404 void InspectorInstrumentation::didRecalculateStyleImpl(const InspectorInstrumentationCookie& cookie)
405 {
406     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
407         timelineAgent->didRecalculateStyle();
408     InstrumentingAgents* instrumentingAgents = cookie.first;
409     if (!instrumentingAgents)
410         return;
411     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
412         resourceAgent->didRecalculateStyle();
413 }
414
415 void InspectorInstrumentation::didScheduleStyleRecalculationImpl(InstrumentingAgents* instrumentingAgents, Document* document)
416 {
417     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
418         resourceAgent->didScheduleStyleRecalculation(document);
419 }
420
421 void InspectorInstrumentation::applyUserAgentOverrideImpl(InstrumentingAgents* instrumentingAgents, String* userAgent)
422 {
423     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
424         resourceAgent->applyUserAgentOverride(userAgent);
425 }
426
427 void InspectorInstrumentation::willSendRequestImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
428 {
429     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
430         timelineAgent->willSendResourceRequest(identifier, request);
431     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
432         resourceAgent->willSendRequest(identifier, loader, request, redirectResponse);
433 }
434
435 void InspectorInstrumentation::continueAfterPingLoaderImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& response)
436 {
437     willSendRequestImpl(instrumentingAgents, identifier, loader, request, response);
438 }
439
440 void InspectorInstrumentation::markResourceAsCachedImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
441 {
442     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
443         resourceAgent->markResourceAsCached(identifier);
444 }
445
446 void InspectorInstrumentation::didLoadResourceFromMemoryCacheImpl(InstrumentingAgents* instrumentingAgents, DocumentLoader* loader, CachedResource* cachedResource)
447 {
448     InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
449     if (!inspectorAgent || !inspectorAgent->enabled())
450         return;
451     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
452         resourceAgent->didLoadResourceFromMemoryCache(loader, cachedResource);
453 }
454
455 InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceDataImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
456 {
457     int timelineAgentId = 0;
458     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
459         timelineAgent->willReceiveResourceData(identifier);
460         timelineAgentId = timelineAgent->id();
461     }
462     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
463 }
464
465 void InspectorInstrumentation::didReceiveResourceDataImpl(const InspectorInstrumentationCookie& cookie)
466 {
467     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
468         timelineAgent->didReceiveResourceData();
469 }
470
471 InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const ResourceResponse& response)
472 {
473     int timelineAgentId = 0;
474     InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
475     if (timelineAgent) {
476         timelineAgent->willReceiveResourceResponse(identifier, response);
477         timelineAgentId = timelineAgent->id();
478     }
479     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
480 }
481
482 void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
483 {
484     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
485         timelineAgent->didReceiveResourceResponse();
486     if (!loader)
487         return;
488     InstrumentingAgents* instrumentingAgents = cookie.first;
489     if (!instrumentingAgents)
490         return;
491     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
492         resourceAgent->didReceiveResponse(identifier, loader, response);
493     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
494         consoleAgent->didReceiveResponse(identifier, response); // This should come AFTER resource notification, front-end relies on this.
495 }
496
497 void InspectorInstrumentation::didReceiveResourceResponseButCanceledImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
498 {
499     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(frame, identifier, r);
500     InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r);
501 }
502
503 void InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
504 {
505     didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
506 }
507
508 void InspectorInstrumentation::continueWithPolicyDownloadImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
509 {
510     didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
511 }
512
513 void InspectorInstrumentation::continueWithPolicyIgnoreImpl(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
514 {
515     didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
516 }
517
518 void InspectorInstrumentation::didReceiveDataImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
519 {
520     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
521         resourceAgent->didReceiveData(identifier, data, dataLength, encodedDataLength);
522 }
523
524 void InspectorInstrumentation::didFinishLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, double finishTime)
525 {
526     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
527         timelineAgent->didFinishLoadingResource(identifier, false, finishTime);
528     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
529         resourceAgent->didFinishLoading(identifier, loader, finishTime);
530 }
531
532 void InspectorInstrumentation::didFailLoadingImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, DocumentLoader* loader, const ResourceError& error)
533 {
534     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
535         timelineAgent->didFinishLoadingResource(identifier, true, 0);
536     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
537         resourceAgent->didFailLoading(identifier, loader, error);
538     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
539         consoleAgent->didFailLoading(identifier, error); // This should come AFTER resource notification, front-end relies on this.
540 }
541
542 void InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
543 {
544     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
545         consoleAgent->resourceRetrievedByXMLHttpRequest(url, sendURL, sendLineNumber);
546     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
547         resourceAgent->setInitialXHRContent(identifier, sourceString);
548 }
549
550 void InspectorInstrumentation::didReceiveXHRResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
551 {
552     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
553         resourceAgent->didReceiveXHRResponse(identifier);
554 }
555
556 void InspectorInstrumentation::willLoadXHRSynchronouslyImpl(InstrumentingAgents* instrumentingAgents)
557 {
558     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
559         resourceAgent->willLoadXHRSynchronously();
560 }
561
562 void InspectorInstrumentation::didLoadXHRSynchronouslyImpl(InstrumentingAgents* instrumentingAgents)
563 {
564     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
565         resourceAgent->didLoadXHRSynchronously();
566 }
567
568 void InspectorInstrumentation::scriptImportedImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const String& sourceString)
569 {
570     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
571         resourceAgent->setInitialScriptContent(identifier, sourceString);
572 }
573
574 void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
575 {
576     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
577         resourceAgent->didReceiveScriptResponse(identifier);
578 }
579
580 void InspectorInstrumentation::domContentLoadedEventFiredImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
581 {
582     if (frame->page()->mainFrame() != frame)
583         return;
584
585     if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
586         inspectorAgent->domContentLoadedEventFired();
587
588     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
589         domAgent->mainFrameDOMContentLoaded();
590
591     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
592         timelineAgent->didMarkDOMContentEvent();
593
594     if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
595         pageAgent->domContentEventFired();
596 }
597
598 void InspectorInstrumentation::loadEventFiredImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
599 {
600     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
601         domAgent->loadEventFired(frame->document());
602
603     if (frame->page()->mainFrame() != frame)
604         return;
605
606     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
607         timelineAgent->didMarkLoadEvent();
608
609     if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
610         pageAgent->loadEventFired();
611 }
612
613 void InspectorInstrumentation::frameDetachedFromParentImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
614 {
615     if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
616         pageAgent->frameDetached(frame);
617 }
618
619 void InspectorInstrumentation::didCommitLoadImpl(InstrumentingAgents* instrumentingAgents, Page* page, DocumentLoader* loader)
620 {
621     InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
622     if (!inspectorAgent || !inspectorAgent->enabled())
623         return;
624
625     Frame* mainFrame = page->mainFrame();
626     if (loader->frame() == mainFrame) {
627         if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
628             consoleAgent->reset();
629
630         if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
631             resourceAgent->mainFrameNavigated(loader);
632
633 #if ENABLE(JAVASCRIPT_DEBUGGER)
634         if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent()) {
635             KURL url = inspectorAgent->inspectedURLWithoutFragment();
636             debuggerAgent->inspectedURLChanged(url);
637         }
638 #endif
639 #if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
640         if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent()) {
641             profilerAgent->stopUserInitiatedProfiling(true);
642             profilerAgent->resetState();
643         }
644 #endif
645         if (InspectorCSSAgent* cssAgent = instrumentingAgents->inspectorCSSAgent())
646             cssAgent->reset();
647 #if ENABLE(SQL_DATABASE)
648         if (InspectorDatabaseAgent* databaseAgent = instrumentingAgents->inspectorDatabaseAgent())
649             databaseAgent->clearResources();
650 #endif
651 #if ENABLE(DOM_STORAGE)
652         if (InspectorDOMStorageAgent* domStorageAgent = instrumentingAgents->inspectorDOMStorageAgent())
653             domStorageAgent->clearResources();
654 #endif
655         if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
656             domAgent->setDocument(mainFrame->document());
657
658         inspectorAgent->didCommitLoad();
659     }
660     if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
661         pageAgent->frameNavigated(loader);
662 }
663
664 void InspectorInstrumentation::loaderDetachedFromFrameImpl(InstrumentingAgents* instrumentingAgents, DocumentLoader* loader)
665 {
666     if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
667         inspectorPageAgent->loaderDetachedFromFrame(loader);
668 }
669
670 InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTMLImpl(InstrumentingAgents* instrumentingAgents, unsigned int length, unsigned int startLine)
671 {
672     int timelineAgentId = 0;
673     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
674         timelineAgent->willWriteHTML(length, startLine);
675         timelineAgentId = timelineAgent->id();
676     }
677     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
678 }
679
680 void InspectorInstrumentation::didWriteHTMLImpl(const InspectorInstrumentationCookie& cookie, unsigned int endLine)
681 {
682     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
683         timelineAgent->didWriteHTML(endLine);
684 }
685
686 void InspectorInstrumentation::addMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
687 {
688     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
689         consoleAgent->addMessageToConsole(source, type, level, message, arguments, callStack);
690 }
691
692 void InspectorInstrumentation::addMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& scriptId)
693 {
694     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
695         consoleAgent->addMessageToConsole(source, type, level, message, lineNumber, scriptId);
696 }
697
698 void InspectorInstrumentation::consoleCountImpl(InstrumentingAgents* instrumentingAgents, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> stack)
699 {
700     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
701         consoleAgent->count(arguments, stack);
702 }
703
704 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents* instrumentingAgents, const String& title)
705 {
706     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
707         consoleAgent->startTiming(title);
708 }
709
710 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents* instrumentingAgents, const String& title, PassRefPtr<ScriptCallStack> stack)
711 {
712     if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
713         consoleAgent->stopTiming(title, stack);
714 }
715
716 void InspectorInstrumentation::consoleTimeStampImpl(InstrumentingAgents* instrumentingAgents, PassRefPtr<ScriptArguments> arguments)
717 {
718     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
719         String message;
720         arguments->getFirstArgumentAsString(message);
721         timelineAgent->didTimeStamp(message);
722      }
723 }
724
725 #if ENABLE(JAVASCRIPT_DEBUGGER)
726 void InspectorInstrumentation::addStartProfilingMessageToConsoleImpl(InstrumentingAgents* instrumentingAgents, const String& title, unsigned lineNumber, const String& sourceURL)
727 {
728     if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
729         profilerAgent->addStartProfilingMessageToConsole(title, lineNumber, sourceURL);
730 }
731
732 void InspectorInstrumentation::addProfileImpl(InstrumentingAgents* instrumentingAgents, RefPtr<ScriptProfile> profile, PassRefPtr<ScriptCallStack> callStack)
733 {
734     if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent()) {
735         const ScriptCallFrame& lastCaller = callStack->at(0);
736         profilerAgent->addProfile(profile, lastCaller.lineNumber(), lastCaller.sourceURL());
737     }
738 }
739
740 String InspectorInstrumentation::getCurrentUserInitiatedProfileNameImpl(InstrumentingAgents* instrumentingAgents, bool incrementProfileNumber)
741 {
742     if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
743         return profilerAgent->getCurrentUserInitiatedProfileName(incrementProfileNumber);
744     return "";
745 }
746
747 bool InspectorInstrumentation::profilerEnabledImpl(InstrumentingAgents* instrumentingAgents)
748 {
749     if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
750         return profilerAgent->enabled();
751     return false;
752 }
753 #endif
754
755 #if ENABLE(SQL_DATABASE)
756 void InspectorInstrumentation::didOpenDatabaseImpl(InstrumentingAgents* instrumentingAgents, PassRefPtr<Database> database, const String& domain, const String& name, const String& version)
757 {
758     InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
759     if (!inspectorAgent || !inspectorAgent->enabled())
760         return;
761     if (InspectorDatabaseAgent* dbAgent = instrumentingAgents->inspectorDatabaseAgent())
762         dbAgent->didOpenDatabase(database, domain, name, version);
763 }
764 #endif
765
766 #if ENABLE(DOM_STORAGE)
767 void InspectorInstrumentation::didUseDOMStorageImpl(InstrumentingAgents* instrumentingAgents, StorageArea* storageArea, bool isLocalStorage, Frame* frame)
768 {
769     InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
770     if (!inspectorAgent || !inspectorAgent->enabled())
771         return;
772     if (InspectorDOMStorageAgent* domStorageAgent = instrumentingAgents->inspectorDOMStorageAgent())
773         domStorageAgent->didUseDOMStorage(storageArea, isLocalStorage, frame);
774 }
775 #endif
776
777 #if ENABLE(WORKERS)
778 void InspectorInstrumentation::didStartWorkerContextImpl(InstrumentingAgents* instrumentingAgents, WorkerContextProxy* workerContextProxy, const KURL& url)
779 {
780     if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent())
781         workerAgent->didStartWorkerContext(workerContextProxy, url);
782 }
783
784 void InspectorInstrumentation::didCreateWorkerImpl(InstrumentingAgents* instrumentingAgents, intptr_t id, const String& url, bool isSharedWorker)
785 {
786     if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
787         inspectorAgent->didCreateWorker(id, url, isSharedWorker);
788 }
789
790 void InspectorInstrumentation::didDestroyWorkerImpl(InstrumentingAgents* instrumentingAgents, intptr_t id)
791 {
792     if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
793         inspectorAgent->didDestroyWorker(id);
794 }
795
796 void InspectorInstrumentation::workerContextTerminatedImpl(InstrumentingAgents* instrumentingAgents, WorkerContextProxy* proxy)
797 {
798     if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent())
799         workerAgent->workerContextTerminated(proxy);
800 }
801 #endif
802
803 #if ENABLE(WEB_SOCKETS)
804 void InspectorInstrumentation::didCreateWebSocketImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const KURL& requestURL, const KURL&)
805 {
806     InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent();
807     if (!inspectorAgent || !inspectorAgent->enabled())
808         return;
809     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
810         resourceAgent->didCreateWebSocket(identifier, requestURL);
811 }
812
813 void InspectorInstrumentation::willSendWebSocketHandshakeRequestImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const WebSocketHandshakeRequest& request)
814 {
815     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
816         resourceAgent->willSendWebSocketHandshakeRequest(identifier, request);
817 }
818
819 void InspectorInstrumentation::didReceiveWebSocketHandshakeResponseImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, const WebSocketHandshakeResponse& response)
820 {
821     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
822         resourceAgent->didReceiveWebSocketHandshakeResponse(identifier, response);
823 }
824
825 void InspectorInstrumentation::didCloseWebSocketImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier)
826 {
827     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
828         resourceAgent->didCloseWebSocket(identifier);
829 }
830 #endif
831
832 void InspectorInstrumentation::networkStateChangedImpl(InstrumentingAgents* instrumentingAgents)
833 {
834     if (InspectorApplicationCacheAgent* applicationCacheAgent = instrumentingAgents->inspectorApplicationCacheAgent())
835         applicationCacheAgent->networkStateChanged();
836 }
837
838 void InspectorInstrumentation::updateApplicationCacheStatusImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
839 {
840     if (InspectorApplicationCacheAgent* applicationCacheAgent = instrumentingAgents->inspectorApplicationCacheAgent())
841         applicationCacheAgent->updateApplicationCacheStatus(frame);
842 }
843
844 bool InspectorInstrumentation::collectingHTMLParseErrors(InstrumentingAgents* instrumentingAgents)
845 {
846     if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
847         return inspectorAgent->hasFrontend();
848     return false;
849 }
850
851 void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InstrumentingAgents* instrumentingAgents, const String& categoryType, const String& eventName, bool synchronous)
852 {
853 #if ENABLE(JAVASCRIPT_DEBUGGER)
854     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
855         domDebuggerAgent->pauseOnNativeEventIfNeeded(categoryType, eventName, synchronous);
856 #endif
857 }
858
859 void InspectorInstrumentation::cancelPauseOnNativeEvent(InstrumentingAgents* instrumentingAgents)
860 {
861 #if ENABLE(JAVASCRIPT_DEBUGGER)
862     if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent())
863         debuggerAgent->cancelPauseOnNextStatement();
864 #endif
865 }
866
867 void InspectorInstrumentation::didRegisterAnimationFrameCallbackImpl(InstrumentingAgents* instrumentingAgents, int callbackId)
868 {
869     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
870         timelineAgent->didRegisterAnimationFrameCallback(callbackId);
871 }
872
873 void InspectorInstrumentation::didCancelAnimationFrameCallbackImpl(InstrumentingAgents* instrumentingAgents, int callbackId)
874 {
875     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
876         timelineAgent->didCancelAnimationFrameCallback(callbackId);
877 }
878
879 InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrameEventImpl(InstrumentingAgents* instrumentingAgents, int callbackId)
880 {
881     int timelineAgentId = 0;
882     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
883         timelineAgent->willFireAnimationFrameEvent(callbackId);
884         timelineAgentId = timelineAgent->id();
885     }
886     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
887 }
888
889 void InspectorInstrumentation::didFireAnimationFrameEventImpl(const InspectorInstrumentationCookie& cookie)
890 {
891     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
892         timelineAgent->didFireAnimationFrameEvent();
893 }
894
895 InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(const InspectorInstrumentationCookie& cookie)
896 {
897     if (!cookie.first)
898         return 0;
899     InspectorTimelineAgent* timelineAgent = cookie.first->inspectorTimelineAgent();
900     if (timelineAgent && timelineAgent->id() == cookie.second)
901         return timelineAgent;
902     return 0;
903 }
904
905 InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForPage(Page* page)
906 {
907     if (!page)
908         return 0;
909     return instrumentationForPage(page);
910 }
911
912 } // namespace WebCore
913
914 #endif // !ENABLE(INSPECTOR)