[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

podivilov at chromium.org podivilov at chromium.org
Wed Dec 22 14:22:05 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit b6cd025e41734305231106884225d30587fe90f5
Author: podivilov at chromium.org <podivilov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 7 09:43:02 2010 +0000

    2010-10-05  Pavel Podivilov  <podivilov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: extract Inspector Instrumentation API as a class
            https://bugs.webkit.org/show_bug.cgi?id=47173
    
            * bindings/js/JSXMLHttpRequestCustom.cpp:
            (WebCore::JSXMLHttpRequest::send):
            * bindings/js/ScriptController.cpp:
            (WebCore::ScriptController::evaluateInWorld):
            * bindings/v8/V8DOMWindowShell.cpp:
            * bindings/v8/V8Proxy.cpp:
            (WebCore::V8Proxy::evaluate):
            (WebCore::V8Proxy::callFunction):
            * bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
            (WebCore::V8XMLHttpRequest::sendCallback):
            * dom/Document.cpp:
            (WebCore::Document::recalcStyle):
            * dom/Document.h:
            * dom/Node.cpp:
            (WebCore::Node::dispatchGenericEvent):
            * html/parser/HTMLDocumentParser.cpp:
            (WebCore::HTMLDocumentParser::pumpTokenizer):
            * html/parser/HTMLDocumentParser.h:
            * inspector/InspectorInstrumentation.cpp:
            (WebCore::InspectorInstrumentation::hasFrontend):
            (WebCore::InspectorInstrumentation::retrieveTimelineAgent):
            * inspector/InspectorInstrumentation.h:
            (WebCore::InspectorInstrumentation::hasFrontends):
            (WebCore::InspectorInstrumentation::inspectorControllerForContext):
            (WebCore::InspectorInstrumentation::inspectorControllerForDocument):
            (WebCore::InspectorInstrumentation::inspectorControllerForFrame):
            (WebCore::InspectorInstrumentation::inspectorControllerForPage):
            * inspector/InspectorTimelineAgent.cpp:
            (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
            (WebCore::InspectorTimelineAgent::~InspectorTimelineAgent):
            * inspector/InspectorTimelineAgent.h:
            * loader/ResourceLoader.cpp:
            (WebCore::ResourceLoader::didReceiveResponse):
            (WebCore::ResourceLoader::didReceiveData):
            * loader/loader.cpp:
            (WebCore::Loader::load):
            * page/DOMTimer.cpp:
            (WebCore::DOMTimer::install):
            (WebCore::DOMTimer::removeById):
            (WebCore::DOMTimer::fired):
            * page/DOMTimer.h:
            * page/DOMWindow.cpp:
            (WebCore::DOMWindow::dispatchEvent):
            * page/DOMWindow.h:
            * page/FrameView.cpp:
            (WebCore::FrameView::layout):
            (WebCore::FrameView::paintContents):
            * page/FrameView.h:
            * page/Page.cpp:
            * page/Page.h:
            * rendering/RenderLayerBacking.cpp:
            (WebCore::RenderLayerBacking::paintContents):
            * xml/XMLHttpRequest.cpp:
            (WebCore::XMLHttpRequest::callReadyStateChangeListener):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69283 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c0f2aa2..92d30cd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,65 @@
+2010-10-05  Pavel Podivilov  <podivilov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: extract Inspector Instrumentation API as a class
+        https://bugs.webkit.org/show_bug.cgi?id=47173
+
+        * bindings/js/JSXMLHttpRequestCustom.cpp:
+        (WebCore::JSXMLHttpRequest::send):
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::evaluateInWorld):
+        * bindings/v8/V8DOMWindowShell.cpp:
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::evaluate):
+        (WebCore::V8Proxy::callFunction):
+        * bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
+        (WebCore::V8XMLHttpRequest::sendCallback):
+        * dom/Document.cpp:
+        (WebCore::Document::recalcStyle):
+        * dom/Document.h:
+        * dom/Node.cpp:
+        (WebCore::Node::dispatchGenericEvent):
+        * html/parser/HTMLDocumentParser.cpp:
+        (WebCore::HTMLDocumentParser::pumpTokenizer):
+        * html/parser/HTMLDocumentParser.h:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::hasFrontend):
+        (WebCore::InspectorInstrumentation::retrieveTimelineAgent):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::hasFrontends):
+        (WebCore::InspectorInstrumentation::inspectorControllerForContext):
+        (WebCore::InspectorInstrumentation::inspectorControllerForDocument):
+        (WebCore::InspectorInstrumentation::inspectorControllerForFrame):
+        (WebCore::InspectorInstrumentation::inspectorControllerForPage):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+        (WebCore::InspectorTimelineAgent::~InspectorTimelineAgent):
+        * inspector/InspectorTimelineAgent.h:
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::didReceiveResponse):
+        (WebCore::ResourceLoader::didReceiveData):
+        * loader/loader.cpp:
+        (WebCore::Loader::load):
+        * page/DOMTimer.cpp:
+        (WebCore::DOMTimer::install):
+        (WebCore::DOMTimer::removeById):
+        (WebCore::DOMTimer::fired):
+        * page/DOMTimer.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::dispatchEvent):
+        * page/DOMWindow.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layout):
+        (WebCore::FrameView::paintContents):
+        * page/FrameView.h:
+        * page/Page.cpp:
+        * page/Page.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::paintContents):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::callReadyStateChangeListener):
+
 2010-10-07  Zraly Mike  <mike.zraly at nokia.com>
 
         Reviewed by Andreas Kling.
diff --git a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
index c47b9f3..49dfbaa 100644
--- a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
+++ b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
@@ -94,7 +94,7 @@ JSValue JSXMLHttpRequest::open(ExecState* exec)
 
 JSValue JSXMLHttpRequest::send(ExecState* exec)
 {
-    InspectorInstrumentation::instrumentWillSendXMLHttpRequest(impl()->scriptExecutionContext(), impl()->url());
+    InspectorInstrumentation::willSendXMLHttpRequest(impl()->scriptExecutionContext(), impl()->url());
 
     ExceptionCode ec = 0;
     if (!exec->argumentCount())
diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp
index d318cbb..12c0c07 100644
--- a/WebCore/bindings/js/ScriptController.cpp
+++ b/WebCore/bindings/js/ScriptController.cpp
@@ -28,7 +28,7 @@
 #include "FrameLoaderClient.h"
 #include "GCController.h"
 #include "HTMLPlugInElement.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "JSDocument.h"
 #include "JSMainThreadExecState.h"
 #include "NP_jsobject.h"
@@ -142,19 +142,13 @@ ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode& sourceCode
 
     RefPtr<Frame> protect = m_frame;
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
-        timelineAgent->willEvaluateScript(sourceURL, sourceCode.startLine());
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, sourceURL, sourceCode.startLine());
 
     exec->globalData().timeoutChecker.start();
     Completion comp = JSMainThreadExecState::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, shell);
     exec->globalData().timeoutChecker.stop();
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
-        timelineAgent->didEvaluateScript();
-#endif
+    InspectorInstrumentation::didEvaluateScript(m_frame, cookie);
 
     // Evaluating the JavaScript could cause the frame to be deallocated
     // so we start the keep alive timer here.
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.cpp b/WebCore/bindings/v8/V8DOMWindowShell.cpp
index 4bd4b42..80bf683 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -37,7 +37,6 @@
 #include "DocumentLoader.h"
 #include "Frame.h"
 #include "FrameLoaderClient.h"
-#include "InspectorTimelineAgent.h"
 #include "Page.h"
 #include "PageGroup.h"
 #include "ScriptController.h"
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index f6535aa..ef72b77 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -39,7 +39,7 @@
 #include "FrameLoaderClient.h"
 #include "IDBFactoryBackendInterface.h"
 #include "IDBPendingTransactionMonitor.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "Page.h"
 #include "PageGroup.h"
 #include "PlatformBridge.h"
@@ -376,10 +376,7 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod
 
     V8GCController::checkMemoryUsage();
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
-        timelineAgent->willEvaluateScript(source.url().isNull() ? String() : source.url().string(), source.startLine());
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, source.url().isNull() ? String() : source.url().string(), source.startLine());
 
     v8::Local<v8::Value> result;
     {
@@ -414,10 +411,7 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod
     PlatformBridge::traceEventEnd("v8.run", node, "");
 #endif
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
-        timelineAgent->didEvaluateScript();
-#endif
+    InspectorInstrumentation::didEvaluateScript(m_frame, cookie);
 
     return result;
 }
@@ -505,33 +499,23 @@ v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8
         // execution finishs before firing the timer.
         m_frame->keepAlive();
 
-#if ENABLE(INSPECTOR)
-        Page* inspectedPage = InspectorTimelineAgent::instanceCount() ? m_frame->page(): 0;
-        if (inspectedPage) {
-            if (InspectorTimelineAgent* timelineAgent = inspectedPage->inspectorTimelineAgent()) {
-                v8::ScriptOrigin origin = function->GetScriptOrigin();
-                String resourceName("undefined");
-                int lineNumber = 1;
-                if (!origin.ResourceName().IsEmpty()) {
-                    resourceName = toWebCoreString(origin.ResourceName());
-                    lineNumber = function->GetScriptLineNumber() + 1;
-                }
-                timelineAgent->willCallFunction(resourceName, lineNumber);
-            } else
-                inspectedPage = 0;
+        InspectorInstrumentationCookie cookie = 0;
+        if (InspectorInstrumentation::hasFrontends()) {
+            v8::ScriptOrigin origin = function->GetScriptOrigin();
+            String resourceName("undefined");
+            int lineNumber = 1;
+            if (!origin.ResourceName().IsEmpty()) {
+                resourceName = toWebCoreString(origin.ResourceName());
+                lineNumber = function->GetScriptLineNumber() + 1;
+            }
+            cookie = InspectorInstrumentation::willCallFunction(m_frame, resourceName, lineNumber);
         }
-#endif // !ENABLE(INSPECTOR)
 
         m_recursion++;
         result = function->Call(receiver, argc, args);
         m_recursion--;
 
-#if ENABLE(INSPECTOR)
-        if (inspectedPage)
-            if (InspectorTimelineAgent* timelineAgent = inspectedPage->inspectorTimelineAgent())
-                timelineAgent->didCallFunction();
-#endif // !ENABLE(INSPECTOR)
-
+        InspectorInstrumentation::didCallFunction(m_frame, cookie);
     }
 
     // Release the storage mutex if applicable.
diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
index 1add292..8ab3ada 100644
--- a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
@@ -114,7 +114,7 @@ v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args)
     INC_STATS("DOM.XMLHttpRequest.send()");
     XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder());
 
-    InspectorInstrumentation::instrumentWillSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());
+    InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());
 
     ExceptionCode ec = 0;
     if (args.Length() < 1)
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 8d52078..2848e00 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -88,7 +88,7 @@
 #include "HitTestResult.h"
 #include "ImageLoader.h"
 #include "InspectorController.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "KeyboardEvent.h"
 #include "Logging.h"
 #include "MessageEvent.h"
@@ -1460,10 +1460,7 @@ void Document::recalcStyle(StyleChange change)
     if (m_inStyleRecalc)
         return; // Guard against re-entrancy. -dwh
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
-        timelineAgent->willRecalculateStyle();
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalculateStyle(this);
 
     m_inStyleRecalc = true;
     suspendPostAttachCallbacks();
@@ -1518,10 +1515,7 @@ bail_out:
         implicitClose();
     }
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
-        timelineAgent->didRecalculateStyle();
-#endif
+    InspectorInstrumentation::didRecalculateStyle(this, cookie);
 }
 
 void Document::updateStyleIfNeeded()
@@ -4685,18 +4679,6 @@ bool Document::isXHTMLMPDocument() const
 }
 #endif
 
-#if ENABLE(INSPECTOR)
-InspectorTimelineAgent* Document::inspectorTimelineAgent() const 
-{
-    return page() ? page()->inspectorTimelineAgent() : 0;
-}
-
-InspectorController* Document::inspectorController() const 
-{
-    return page() ? page()->inspectorController() : 0;
-}
-#endif
-    
 #if ENABLE(FULLSCREEN_API)
 void Document::webkitRequestFullScreenForElement(Element* element, unsigned short flags)
 {
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 372090c..2eaaa4b 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -88,7 +88,6 @@ class HTMLInputElement;
 class HTMLMapElement;
 class HitTestRequest;
 class HitTestResult;
-class InspectorTimelineAgent;
 class IntPoint;
 class DOMWrapperWorld;
 class JSNode;
@@ -480,10 +479,6 @@ public:
     Frame* frame() const { return m_frame; } // can be NULL
     Page* page() const; // can be NULL
     Settings* settings() const; // can be NULL
-#if ENABLE(INSPECTOR)
-    InspectorTimelineAgent* inspectorTimelineAgent() const; // can be NULL
-    virtual InspectorController* inspectorController() const; // can be NULL
-#endif
 
     PassRefPtr<Range> createRange();
 
diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp
index 68666a0..e95f620 100644
--- a/WebCore/dom/Node.cpp
+++ b/WebCore/dom/Node.cpp
@@ -2602,7 +2602,7 @@ bool Node::dispatchGenericEvent(PassRefPtr<Event> prpEvent)
             targetForWindowEvents = static_cast<Document*>(topLevelContainer)->domWindow();
     }
 
-    int instrumentationCookie = InspectorInstrumentation::instrumentWillDispatchEvent(document(), *event, targetForWindowEvents, this, ancestors);
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(document(), *event, targetForWindowEvents, this, ancestors);
 
     // Give the target node a chance to do some work before DOM event handlers get a crack.
     void* data = preDispatchEventHandler(event.get());
@@ -2685,7 +2685,7 @@ doneDispatching:
 
 doneWithDefault:
 
-    InspectorInstrumentation::instrumentDidDispatchEvent(document(), instrumentationCookie);
+    InspectorInstrumentation::didDispatchEvent(document(), cookie);
 
     return !event->defaultPrevented();
 }
diff --git a/WebCore/html/parser/HTMLDocumentParser.cpp b/WebCore/html/parser/HTMLDocumentParser.cpp
index 630b6aa..d668d5e 100644
--- a/WebCore/html/parser/HTMLDocumentParser.cpp
+++ b/WebCore/html/parser/HTMLDocumentParser.cpp
@@ -36,15 +36,12 @@
 #include "HTMLScriptRunner.h"
 #include "HTMLTreeBuilder.h"
 #include "HTMLDocument.h"
+#include "InspectorInstrumentation.h"
 #include "NestingLevelIncrementer.h"
 #include "Settings.h"
 #include "XSSAuditor.h"
 #include <wtf/CurrentTime.h>
 
-#if ENABLE(INSPECTOR)
-#include "InspectorTimelineAgent.h"
-#endif
-
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -210,9 +207,12 @@ void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode)
     // ASSERT that this object is both attached to the Document and protected.
     ASSERT(refCount() >= 2);
 
-    // We tell the InspectorTimelineAgent about every pump, even if we
+    // We tell the InspectorInstrumentation about every pump, even if we
     // end up pumping nothing.  It can filter out empty pumps itself.
-    willPumpLexer();
+    // FIXME: m_input.current().length() is only accurate if we
+    // end up parsing the whole buffer in this pump.  We should pass how
+    // much we parsed as part of didWriteHTML instead of willWriteHTML.
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), m_input.current().length(), m_tokenizer->lineNumber());
 
     HTMLParserScheduler::PumpSession session;
     // FIXME: This loop body has is now too long and needs cleanup.
@@ -256,26 +256,7 @@ void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode)
         m_preloadScanner->scan();
     }
 
-    didPumpLexer();
-}
-
-void HTMLDocumentParser::willPumpLexer()
-{
-#if ENABLE(INSPECTOR)
-    // FIXME: m_input.current().length() is only accurate if we
-    // end up parsing the whole buffer in this pump.  We should pass how
-    // much we parsed as part of didWriteHTML instead of willWriteHTML.
-    if (InspectorTimelineAgent* timelineAgent = document()->inspectorTimelineAgent())
-        timelineAgent->willWriteHTML(m_input.current().length(), m_tokenizer->lineNumber());
-#endif
-}
-
-void HTMLDocumentParser::didPumpLexer()
-{
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = document()->inspectorTimelineAgent())
-        timelineAgent->didWriteHTML(m_tokenizer->lineNumber());
-#endif
+    InspectorInstrumentation::didWriteHTML(document(), m_tokenizer->lineNumber(), cookie);
 }
 
 bool HTMLDocumentParser::hasInsertionPoint()
diff --git a/WebCore/html/parser/HTMLDocumentParser.h b/WebCore/html/parser/HTMLDocumentParser.h
index e65a582..d9625f1 100644
--- a/WebCore/html/parser/HTMLDocumentParser.h
+++ b/WebCore/html/parser/HTMLDocumentParser.h
@@ -103,9 +103,6 @@ private:
     // CachedResourceClient
     virtual void notifyFinished(CachedResource*);
 
-    void willPumpLexer();
-    void didPumpLexer();
-
     enum SynchronousMode {
         AllowYield,
         ForceSynchronous,
diff --git a/WebCore/inspector/InspectorInstrumentation.cpp b/WebCore/inspector/InspectorInstrumentation.cpp
index fb5768a..e744c5e 100644
--- a/WebCore/inspector/InspectorInstrumentation.cpp
+++ b/WebCore/inspector/InspectorInstrumentation.cpp
@@ -39,6 +39,7 @@
 #include "InspectorDOMAgent.h"
 #include "InspectorDebuggerAgent.h"
 #include "InspectorTimelineAgent.h"
+#include "XMLHttpRequest.h"
 
 namespace WebCore {
 
@@ -64,8 +65,6 @@ static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window,
 void InspectorInstrumentation::willInsertDOMNodeImpl(InspectorController* inspectorController, Node* node, Node* parent)
 {
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    if (!inspectorController->hasFrontend())
-        return;
     InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
     if (!debuggerAgent)
         return;
@@ -80,8 +79,6 @@ void InspectorInstrumentation::willInsertDOMNodeImpl(InspectorController* inspec
 
 void InspectorInstrumentation::didInsertDOMNodeImpl(InspectorController* inspectorController, Node* node)
 {
-    if (!inspectorController->hasFrontend())
-        return;
     if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
         domAgent->didInsertDOMNode(node);
 }
@@ -89,8 +86,6 @@ void InspectorInstrumentation::didInsertDOMNodeImpl(InspectorController* inspect
 void InspectorInstrumentation::willRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node)
 {
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    if (!inspectorController->hasFrontend())
-        return;
     InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
     if (!debuggerAgent)
         return;
@@ -105,8 +100,6 @@ void InspectorInstrumentation::willRemoveDOMNodeImpl(InspectorController* inspec
 
 void InspectorInstrumentation::didRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node)
 {
-    if (!inspectorController->hasFrontend())
-        return;
     if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
         domAgent->didRemoveDOMNode(node);
 }
@@ -114,8 +107,6 @@ void InspectorInstrumentation::didRemoveDOMNodeImpl(InspectorController* inspect
 void InspectorInstrumentation::willModifyDOMAttrImpl(InspectorController* inspectorController, Element* element)
 {
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    if (!inspectorController->hasFrontend())
-        return;
     InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
     if (!debuggerAgent)
         return;
@@ -130,27 +121,86 @@ void InspectorInstrumentation::willModifyDOMAttrImpl(InspectorController* inspec
 
 void InspectorInstrumentation::didModifyDOMAttrImpl(InspectorController* inspectorController, Element* element)
 {
-    if (!inspectorController->hasFrontend())
-        return;
     if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
         domAgent->didModifyDOMAttr(element);
 }
 
 void InspectorInstrumentation::characterDataModifiedImpl(InspectorController* inspectorController, CharacterData* characterData)
 {
-    if (!inspectorController->hasFrontend())
-        return;
     if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
         domAgent->characterDataModified(characterData);
 }
 
-int InspectorInstrumentation::instrumentWillDispatchEventImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors)
+
+void InspectorInstrumentation::willSendXMLHttpRequestImpl(InspectorController* inspectorController, const String& url)
+{
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+    InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
+    if (!debuggerAgent)
+        return;
+
+    if (!inspectorController->shouldBreakOnXMLHttpRequest(url))
+        return;
+
+    RefPtr<InspectorObject> eventData = InspectorObject::create();
+    eventData->setString("type", "XHR");
+    eventData->setString("url", url);
+    debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
+#endif
+}
+
+void InspectorInstrumentation::didScheduleResourceRequestImpl(InspectorController* inspectorController, const String& url)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
+        timelineAgent->didScheduleResourceRequest(url);
+}
+
+void InspectorInstrumentation::didInstallTimerImpl(InspectorController* inspectorController, int timerId, int timeout, bool singleShot)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
+        timelineAgent->didInstallTimer(timerId, timeout, singleShot);
+}
+
+void InspectorInstrumentation::didRemoveTimerImpl(InspectorController* inspectorController, int timerId)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
+        timelineAgent->didRemoveTimer(timerId);
+}
+
+
+InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(InspectorController* inspectorController, const String& scriptName, int scriptLine)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
+        timelineAgent->willCallFunction(scriptName, scriptLine);
+        return timelineAgent->id();
+    }
+    return 0;
+}
+
+void InspectorInstrumentation::didCallFunctionImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
 {
-    int instrumentationCookie = 0;
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didCallFunction();
+}
 
-    if (!inspectorController->hasFrontend())
-        return instrumentationCookie;
+InspectorInstrumentationCookie InspectorInstrumentation::willChangeXHRReadyStateImpl(InspectorController* inspectorController, XMLHttpRequest* request)
+{
+    InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
+    if (timelineAgent && request->hasEventListeners(eventNames().readystatechangeEvent)) {
+        timelineAgent->willChangeXHRReadyState(request->url().string(), request->readyState());
+        return timelineAgent->id();
+    }
+    return 0;
+}
 
+void InspectorInstrumentation::didChangeXHRReadyStateImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didChangeXHRReadyState();
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors)
+{
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     if (InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get()) {
         if (inspectorController->shouldBreakOnEvent(event.type())) {
@@ -162,47 +212,194 @@ int InspectorInstrumentation::instrumentWillDispatchEventImpl(InspectorControlle
     }
 #endif
 
-    InspectorTimelineAgent* timelineAgent = inspectorController->m_timelineAgent.get();
+    InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
     if (timelineAgent && eventHasListeners(event.type(), window, node, ancestors)) {
         timelineAgent->willDispatchEvent(event);
-        instrumentationCookie = timelineAgent->id();
+        return timelineAgent->id();
     }
-    return instrumentationCookie;
+    return 0;
 }
 
-void InspectorInstrumentation::instrumentDidDispatchEventImpl(InspectorController* inspectorController, int instrumentationCookie)
+void InspectorInstrumentation::didDispatchEventImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
 {
-    if (!inspectorController->hasFrontend())
-        return;
-
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     if (InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get())
         debuggerAgent->cancelPauseOnNextStatement();
 #endif
 
-    InspectorTimelineAgent* timelineAgent = inspectorController->m_timelineAgent.get();
-    if (timelineAgent && timelineAgent->id() == instrumentationCookie)
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
         timelineAgent->didDispatchEvent();
 }
 
-void InspectorInstrumentation::instrumentWillSendXMLHttpRequestImpl(InspectorController* inspectorController, const String& url)
+InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindowImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window)
 {
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-    if (!inspectorController->hasFrontend())
-        return;
+    InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
+    if (timelineAgent && window->hasEventListeners(event.type())) {
+        timelineAgent->willDispatchEvent(event);
+        return timelineAgent->id();
+    }
+    return 0;
+}
 
-    InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
-    if (!debuggerAgent)
-        return;
+void InspectorInstrumentation::didDispatchEventOnWindowImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didDispatchEvent();
+}
 
-    if (!inspectorController->shouldBreakOnXMLHttpRequest(url))
-        return;
+InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScriptImpl(InspectorController* inspectorController, const String& url, int lineNumber)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
+        timelineAgent->willEvaluateScript(url, lineNumber);
+        return timelineAgent->id();
+    }
+    return 0;
+}
 
-    RefPtr<InspectorObject> eventData = InspectorObject::create();
-    eventData->setString("type", "XHR");
-    eventData->setString("url", url);
-    debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
-#endif
+void InspectorInstrumentation::didEvaluateScriptImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didEvaluateScript();
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(InspectorController* inspectorController, int timerId)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
+        timelineAgent->willFireTimer(timerId);
+        return timelineAgent->id();
+    }
+    return 0;
+}
+
+void InspectorInstrumentation::didFireTimerImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didFireTimer();
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willLayoutImpl(InspectorController* inspectorController)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
+        timelineAgent->willLayout();
+        return timelineAgent->id();
+    }
+    return 0;
+}
+
+void InspectorInstrumentation::didLayoutImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didLayout();
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willLoadXHRImpl(InspectorController* inspectorController, XMLHttpRequest* request)
+{
+    InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
+    if (timelineAgent && request->hasEventListeners(eventNames().loadEvent)) {
+        timelineAgent->willLoadXHR(request->url().string());
+        return timelineAgent->id();
+    }
+    return 0;
+}
+
+void InspectorInstrumentation::didLoadXHRImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didLoadXHR();
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willPaintImpl(InspectorController* inspectorController, const IntRect& rect)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
+        timelineAgent->willPaint(rect);
+        return timelineAgent->id();
+    }
+    return 0;
+}
+
+void InspectorInstrumentation::didPaintImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didPaint();
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyleImpl(InspectorController* inspectorController)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
+        timelineAgent->willRecalculateStyle();
+        return timelineAgent->id();
+    }
+    return 0;
+}
+
+void InspectorInstrumentation::didRecalculateStyleImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didRecalculateStyle();
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceDataImpl(InspectorController* inspectorController, unsigned long identifier)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
+        timelineAgent->willReceiveResourceData(identifier);
+        return timelineAgent->id();
+    }
+    return 0;
+}
+
+void InspectorInstrumentation::didReceiveResourceDataImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didReceiveResourceData();
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponseImpl(InspectorController* inspectorController, unsigned long identifier, const ResourceResponse& response)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
+        timelineAgent->willReceiveResourceResponse(identifier, response);
+        return timelineAgent->id();
+    }
+    return 0;
+}
+
+void InspectorInstrumentation::didReceiveResourceResponseImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didReceiveResourceResponse();
+}
+
+InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTMLImpl(InspectorController* inspectorController, unsigned int length, unsigned int startLine)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
+        timelineAgent->willWriteHTML(length, startLine);
+        return timelineAgent->id();
+    }
+    return 0;
+}
+
+void InspectorInstrumentation::didWriteHTMLImpl(InspectorController* inspectorController, unsigned int endLine, InspectorInstrumentationCookie cookie)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
+        timelineAgent->didWriteHTML(endLine);
+}
+
+
+bool InspectorInstrumentation::hasFrontend(InspectorController* inspectorController)
+{
+    return inspectorController->hasFrontend();
+}
+
+InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(InspectorController* inspectorController)
+{
+    return inspectorController->m_timelineAgent.get();
+}
+
+InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
+{
+    InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
+    if (timelineAgent && timelineAgent->id() == cookie)
+        return timelineAgent;
+    return 0;
 }
 
 } // namespace WebCore
diff --git a/WebCore/inspector/InspectorInstrumentation.h b/WebCore/inspector/InspectorInstrumentation.h
index 5b66a2e..072101f 100644
--- a/WebCore/inspector/InspectorInstrumentation.h
+++ b/WebCore/inspector/InspectorInstrumentation.h
@@ -32,6 +32,7 @@
 #define InspectorInstrumentation_h
 
 #include "Document.h"
+#include "Frame.h"
 #include "Page.h"
 #include "ScriptExecutionContext.h"
 
@@ -40,7 +41,13 @@ namespace WebCore {
 class CharacterData;
 class Element;
 class InspectorController;
+class InspectorTimelineAgent;
 class Node;
+class ResourceRequest;
+class ResourceResponse;
+class XMLHttpRequest;
+
+typedef int InspectorInstrumentationCookie;
 
 class InspectorInstrumentation {
 public:
@@ -51,15 +58,44 @@ public:
     static void didModifyDOMAttr(Document*, Element*);
     static void characterDataModified(Document*, CharacterData*);
 
-    static int instrumentWillDispatchEvent(Document*, const Event&, DOMWindow*, Node*, const Vector<RefPtr<ContainerNode> >& ancestors);
-    static void instrumentDidDispatchEvent(Document*, int instrumentationCookie);
+    static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
+    static void didScheduleResourceRequest(Document*, const String& url);
+    static void didInstallTimer(ScriptExecutionContext*, int timerId, int timeout, bool singleShot);
+    static void didRemoveTimer(ScriptExecutionContext*, int timerId);
 
-    static void instrumentWillSendXMLHttpRequest(ScriptExecutionContext*, const String&);
+    static InspectorInstrumentationCookie willCallFunction(Frame*, const String& scriptName, int scriptLine);
+    static void didCallFunction(Frame*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willChangeXHRReadyState(ScriptExecutionContext*, XMLHttpRequest* request);
+    static void didChangeXHRReadyState(ScriptExecutionContext*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willDispatchEvent(Document*, const Event& event, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors);
+    static void didDispatchEvent(Document*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event& event, DOMWindow* window);
+    static void didDispatchEventOnWindow(Frame*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willEvaluateScript(Frame*, const String& url, int lineNumber);
+    static void didEvaluateScript(Frame*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext*, int timerId);
+    static void didFireTimer(ScriptExecutionContext*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willLayout(Frame*);
+    static void didLayout(Frame*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willLoadXHR(ScriptExecutionContext*, XMLHttpRequest* request);
+    static void didLoadXHR(ScriptExecutionContext*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willPaint(Frame*, const IntRect& rect);
+    static void didPaint(Frame*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willRecalculateStyle(Document*);
+    static void didRecalculateStyle(Document*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willReceiveResourceData(Frame*, unsigned long identifier);
+    static void didReceiveResourceData(Frame*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*, unsigned long identifier, const ResourceResponse& response);
+    static void didReceiveResourceResponse(Frame*, InspectorInstrumentationCookie cookie);
+    static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine);
+    static void didWriteHTML(Document*, unsigned int endLine, InspectorInstrumentationCookie cookie);
 
 #if ENABLE(INSPECTOR)
     static void frontendCreated() { s_frontendCounter += 1; }
     static void frontendDeleted() { s_frontendCounter -= 1; }
     static bool hasFrontends() { return s_frontendCounter; }
+#else
+    static bool hasFrontends() { return false; }
 #endif
 
 private:
@@ -72,15 +108,47 @@ private:
     static void didModifyDOMAttrImpl(InspectorController*, Element*);
     static void characterDataModifiedImpl(InspectorController*, CharacterData*);
 
-    static int instrumentWillDispatchEventImpl(InspectorController*, const Event&, DOMWindow*, Node*, const Vector<RefPtr<ContainerNode> >& ancestors);
-    static void instrumentDidDispatchEventImpl(InspectorController*, int instrumentationCookie);
+    static void willSendXMLHttpRequestImpl(InspectorController*, const String& url);
+    static void didScheduleResourceRequestImpl(InspectorController*, const String& url);
+    static void didInstallTimerImpl(InspectorController*, int timerId, int timeout, bool singleShot);
+    static void didRemoveTimerImpl(InspectorController*, int timerId);
 
-    static void instrumentWillSendXMLHttpRequestImpl(InspectorController*, const String&);
+    static InspectorInstrumentationCookie willCallFunctionImpl(InspectorController*, const String& scriptName, int scriptLine);
+    static void didCallFunctionImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willChangeXHRReadyStateImpl(InspectorController*, XMLHttpRequest* request);
+    static void didChangeXHRReadyStateImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willDispatchEventImpl(InspectorController*, const Event& event, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors);
+    static void didDispatchEventImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InspectorController*, const Event& event, DOMWindow* window);
+    static void didDispatchEventOnWindowImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willEvaluateScriptImpl(InspectorController*, const String& url, int lineNumber);
+    static void didEvaluateScriptImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willFireTimerImpl(InspectorController*, int timerId);
+    static void didFireTimerImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willLayoutImpl(InspectorController*);
+    static void didLayoutImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willLoadXHRImpl(InspectorController*, XMLHttpRequest* request);
+    static void didLoadXHRImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willPaintImpl(InspectorController*, const IntRect& rect);
+    static void didPaintImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willRecalculateStyleImpl(InspectorController*);
+    static void didRecalculateStyleImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willReceiveResourceDataImpl(InspectorController*, unsigned long identifier);
+    static void didReceiveResourceDataImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InspectorController*, unsigned long identifier, const ResourceResponse& response);
+    static void didReceiveResourceResponseImpl(InspectorController*, InspectorInstrumentationCookie);
+    static InspectorInstrumentationCookie willWriteHTMLImpl(InspectorController*, unsigned int length, unsigned int startLine);
+    static void didWriteHTMLImpl(InspectorController*, unsigned int endLine, InspectorInstrumentationCookie);
 
-    static InspectorController* inspectorControllerForScriptExecutionContext(ScriptExecutionContext*);
+    static InspectorController* inspectorControllerForContext(ScriptExecutionContext*);
     static InspectorController* inspectorControllerForDocument(Document*);
+    static InspectorController* inspectorControllerForFrame(Frame*);
     static InspectorController* inspectorControllerForPage(Page*);
 
+    static bool hasFrontend(InspectorController*);
+    static InspectorTimelineAgent* retrieveTimelineAgent(InspectorController*);
+    static InspectorTimelineAgent* retrieveTimelineAgent(InspectorController*, InspectorInstrumentationCookie);
+
     static int s_frontendCounter;
 #endif
 };
@@ -135,33 +203,264 @@ inline void InspectorInstrumentation::characterDataModified(Document* document,
 #endif
 }
 
-inline int InspectorInstrumentation::instrumentWillDispatchEvent(Document* document, const Event& event, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors)
+
+inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForContext(context))
+        willSendXMLHttpRequestImpl(inspectorController, url);
+#endif
+}
+
+inline void InspectorInstrumentation::didScheduleResourceRequest(Document* document, const String& url)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForDocument(document))
+        didScheduleResourceRequestImpl(inspectorController, url);
+#endif
+}
+
+inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, int timeout, bool singleShot)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForContext(context))
+        didInstallTimerImpl(inspectorController, timerId, timeout, singleShot);
+#endif
+}
+
+inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext* context, int timerId)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForContext(context))
+        didRemoveTimerImpl(inspectorController, timerId);
+#endif
+}
+
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(Frame* frame, const String& scriptName, int scriptLine)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        return willCallFunctionImpl(inspectorController, scriptName, scriptLine);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didCallFunction(Frame* frame, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didCallFunctionImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willChangeXHRReadyState(ScriptExecutionContext* context, XMLHttpRequest* request)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForContext(context))
+        return willChangeXHRReadyStateImpl(inspectorController, request);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didChangeXHRReadyState(ScriptExecutionContext* context, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForContext(context))
+        didChangeXHRReadyStateImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document* document, const Event& event, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors)
 {
 #if ENABLE(INSPECTOR)
     if (InspectorController* inspectorController = inspectorControllerForDocument(document))
-        return instrumentWillDispatchEventImpl(inspectorController, event, window, node, ancestors);
+        return willDispatchEventImpl(inspectorController, event, window, node, ancestors);
 #endif
     return 0;
 }
 
-inline void InspectorInstrumentation::instrumentDidDispatchEvent(Document* document, int instrumentationCookie)
+inline void InspectorInstrumentation::didDispatchEvent(Document* document, InspectorInstrumentationCookie cookie)
 {
 #if ENABLE(INSPECTOR)
     if (InspectorController* inspectorController = inspectorControllerForDocument(document))
-        instrumentDidDispatchEventImpl(inspectorController, instrumentationCookie);
+        didDispatchEventImpl(inspectorController, cookie);
 #endif
 }
 
-inline void InspectorInstrumentation::instrumentWillSendXMLHttpRequest(ScriptExecutionContext* context, const String& url)
+inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindow(Frame* frame, const Event& event, DOMWindow* window)
 {
 #if ENABLE(INSPECTOR)
-    if (InspectorController* inspectorController = inspectorControllerForScriptExecutionContext(context))
-        instrumentWillSendXMLHttpRequestImpl(inspectorController, url);
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        return willDispatchEventOnWindowImpl(inspectorController, event, window);
 #endif
+    return 0;
 }
 
+inline void InspectorInstrumentation::didDispatchEventOnWindow(Frame* frame, InspectorInstrumentationCookie cookie)
+{
 #if ENABLE(INSPECTOR)
-inline InspectorController* InspectorInstrumentation::inspectorControllerForScriptExecutionContext(ScriptExecutionContext* context)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didDispatchEventOnWindowImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame* frame, const String& url, int lineNumber)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        return willEvaluateScriptImpl(inspectorController, url, lineNumber);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didEvaluateScript(Frame* frame, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didEvaluateScriptImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext* context, int timerId)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForContext(context))
+        return willFireTimerImpl(inspectorController, timerId);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didFireTimer(ScriptExecutionContext* context, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForContext(context))
+        didFireTimerImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willLayout(Frame* frame)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        return willLayoutImpl(inspectorController);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didLayout(Frame* frame, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didLayoutImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willLoadXHR(ScriptExecutionContext* context, XMLHttpRequest* request)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForContext(context))
+        return willLoadXHRImpl(inspectorController, request);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didLoadXHR(ScriptExecutionContext* context, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForContext(context))
+        didLoadXHRImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willPaint(Frame* frame, const IntRect& rect)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        return willPaintImpl(inspectorController, rect);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didPaint(Frame* frame, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didPaintImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyle(Document* document)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForDocument(document))
+        return willRecalculateStyleImpl(inspectorController);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didRecalculateStyle(Document* document, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForDocument(document))
+        didRecalculateStyleImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceData(Frame* frame, unsigned long identifier)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        return willReceiveResourceDataImpl(inspectorController, identifier);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didReceiveResourceData(Frame* frame, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didReceiveResourceDataImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponse(Frame* frame, unsigned long identifier, const ResourceResponse& response)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        return willReceiveResourceResponseImpl(inspectorController, identifier, response);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didReceiveResourceResponse(Frame* frame, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didReceiveResourceResponseImpl(inspectorController, cookie);
+#endif
+}
+
+inline InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTML(Document* document, unsigned int length, unsigned int startLine)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForDocument(document))
+        return willWriteHTMLImpl(inspectorController, length, startLine);
+#endif
+    return 0;
+}
+
+inline void InspectorInstrumentation::didWriteHTML(Document* document, unsigned int endLine, InspectorInstrumentationCookie cookie)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForDocument(document))
+        didWriteHTMLImpl(inspectorController, endLine, cookie);
+#endif
+}
+
+
+#if ENABLE(INSPECTOR)
+inline InspectorController* InspectorInstrumentation::inspectorControllerForContext(ScriptExecutionContext* context)
 {
     if (hasFrontends() && context && context->isDocument())
         return inspectorControllerForPage(static_cast<Document*>(context)->page());
@@ -170,14 +469,27 @@ inline InspectorController* InspectorInstrumentation::inspectorControllerForScri
 
 inline InspectorController* InspectorInstrumentation::inspectorControllerForDocument(Document* document)
 {
-    if (hasFrontends())
+    if (hasFrontends() && document)
         return inspectorControllerForPage(document->page());
     return 0;
 }
 
+inline InspectorController* InspectorInstrumentation::inspectorControllerForFrame(Frame* frame)
+{
+    if (hasFrontends() && frame)
+        return inspectorControllerForPage(frame->page());
+    return 0;
+}
+
 inline InspectorController* InspectorInstrumentation::inspectorControllerForPage(Page* page)
 {
-    return page ? page->inspectorController() : 0;
+    if (page) {
+        if (InspectorController* inspectorController = page->inspectorController()) {
+            if (hasFrontend(inspectorController))
+                return inspectorController;
+        }
+    }
+    return 0;
 }
 #endif
 
diff --git a/WebCore/inspector/InspectorTimelineAgent.cpp b/WebCore/inspector/InspectorTimelineAgent.cpp
index 1dd86ad..645b692 100644
--- a/WebCore/inspector/InspectorTimelineAgent.cpp
+++ b/WebCore/inspector/InspectorTimelineAgent.cpp
@@ -44,14 +44,12 @@
 
 namespace WebCore {
 
-int InspectorTimelineAgent::s_instanceCount = 0;
 int InspectorTimelineAgent::s_id = 0;
 
 InspectorTimelineAgent::InspectorTimelineAgent(InspectorFrontend* frontend)
     : m_frontend(frontend)
     , m_id(++s_id)
 {
-    ++s_instanceCount;
     ScriptGCEvent::addEventListener(this);
     ASSERT(m_frontend);
 }
@@ -78,8 +76,6 @@ void InspectorTimelineAgent::didGC(double startTime, double endTime, size_t coll
 
 InspectorTimelineAgent::~InspectorTimelineAgent()
 {
-    ASSERT(s_instanceCount);
-    --s_instanceCount;
     ScriptGCEvent::removeEventListener(this);
 }
 
diff --git a/WebCore/inspector/InspectorTimelineAgent.h b/WebCore/inspector/InspectorTimelineAgent.h
index 9969a14..bc1e027 100644
--- a/WebCore/inspector/InspectorTimelineAgent.h
+++ b/WebCore/inspector/InspectorTimelineAgent.h
@@ -33,9 +33,7 @@
 
 #if ENABLE(INSPECTOR)
 
-#include "Document.h"
 #include "InspectorValues.h"
-#include "ScriptExecutionContext.h"
 #include "ScriptGCEvent.h"
 #include "ScriptGCEventListener.h"
 #include <wtf/Vector.h>
@@ -130,9 +128,6 @@ public:
         
     virtual void didGC(double, double, size_t);
 
-    static int instanceCount() { return s_instanceCount; }
-    static InspectorTimelineAgent* retrieve(ScriptExecutionContext*);
-
 private:
     struct TimelineRecordEntry {
         TimelineRecordEntry(PassRefPtr<InspectorObject> record, PassRefPtr<InspectorObject> data, PassRefPtr<InspectorArray> children, TimelineRecordType type)
@@ -157,7 +152,7 @@ private:
     InspectorFrontend* m_frontend;
 
     Vector<TimelineRecordEntry> m_recordStack;
-    static int s_instanceCount;
+
     static int s_id;
     const int m_id;
     struct GCEvent {
@@ -173,13 +168,6 @@ private:
     GCEvents m_gcEvents;
 };
 
-inline InspectorTimelineAgent* InspectorTimelineAgent::retrieve(ScriptExecutionContext* context)
-{
-    if (context && context->isDocument())
-        return static_cast<Document*>(context)->inspectorTimelineAgent();
-    return 0;
-}
-
 } // namespace WebCore
 
 #endif // !ENABLE(INSPECTOR)
diff --git a/WebCore/loader/ResourceLoader.cpp b/WebCore/loader/ResourceLoader.cpp
index 490bc30..5496d9e 100644
--- a/WebCore/loader/ResourceLoader.cpp
+++ b/WebCore/loader/ResourceLoader.cpp
@@ -36,8 +36,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
-#include "InspectorController.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "Page.h"
 #include "ProgressTracker.h"
 #include "ResourceHandle.h"
@@ -401,44 +400,20 @@ void ResourceLoader::didSendData(ResourceHandle*, unsigned long long bytesSent,
 
 void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
 {
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent::instanceCount()) {
-        InspectorTimelineAgent* timelineAgent = (m_frame && m_frame->page()) ? m_frame->page()->inspectorTimelineAgent() : 0;
-        if (timelineAgent)
-            timelineAgent->willReceiveResourceResponse(identifier(), response);
-    }
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame.get(), identifier(), response);
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
     if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForResponse(this, response))
         return;
 #endif
     didReceiveResponse(response);
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent::instanceCount()) {
-        InspectorTimelineAgent* timelineAgent = (m_frame && m_frame->page()) ? m_frame->page()->inspectorTimelineAgent() : 0;
-        if (timelineAgent)
-            timelineAgent->didReceiveResourceResponse();
-    }
-#endif
+    InspectorInstrumentation::didReceiveResourceResponse(m_frame.get(), cookie);
 }
 
 void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int lengthReceived)
 {
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent::instanceCount()) {
-        InspectorTimelineAgent* timelineAgent = (m_frame && m_frame->page()) ? m_frame->page()->inspectorTimelineAgent() : 0;
-        if (timelineAgent)
-            timelineAgent->willReceiveResourceData(identifier());
-    }
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_frame.get(), identifier());
     didReceiveData(data, length, lengthReceived, false);
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent::instanceCount()) {
-        InspectorTimelineAgent* timelineAgent = (m_frame && m_frame->page()) ? m_frame->page()->inspectorTimelineAgent() : 0;
-        if (timelineAgent)
-            timelineAgent->didReceiveResourceData();
-    }
-#endif
+    InspectorInstrumentation::didReceiveResourceData(m_frame.get(), cookie);
 }
 
 void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime)
diff --git a/WebCore/loader/loader.cpp b/WebCore/loader/loader.cpp
index 3f6fad2..8f262e2 100644
--- a/WebCore/loader/loader.cpp
+++ b/WebCore/loader/loader.cpp
@@ -28,7 +28,7 @@
 #include "CachedImage.h"
 #include "CachedResource.h"
 #include "CachedResourceLoader.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "HTMLDocument.h"
@@ -149,13 +149,7 @@ void Loader::load(CachedResourceLoader* cachedResourceLoader, CachedResource* re
         host->servePendingRequests(priority);
     } else {
         // Handle asynchronously so early low priority requests don't get scheduled before later high priority ones
-#if ENABLE(INSPECTOR)
-        if (InspectorTimelineAgent::instanceCount()) {
-            InspectorTimelineAgent* agent = cachedResourceLoader->doc()->inspectorTimelineAgent();
-            if (agent)
-                agent->didScheduleResourceRequest(resource->url());
-        }
-#endif // ENABLE(INSPECTOR)
+        InspectorInstrumentation::didScheduleResourceRequest(cachedResourceLoader->doc(), resource->url());
         scheduleServePendingRequests();
     }
 }
diff --git a/WebCore/page/DOMTimer.cpp b/WebCore/page/DOMTimer.cpp
index 3ac6d15..1402dda 100644
--- a/WebCore/page/DOMTimer.cpp
+++ b/WebCore/page/DOMTimer.cpp
@@ -27,7 +27,7 @@
 #include "config.h"
 #include "DOMTimer.h"
 
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "ScheduledAction.h"
 #include "ScriptExecutionContext.h"
 #include <wtf/HashSet.h>
@@ -81,10 +81,7 @@ int DOMTimer::install(ScriptExecutionContext* context, PassOwnPtr<ScheduledActio
     // or if it is a one-time timer and it has fired (DOMTimer::fired).
     DOMTimer* timer = new DOMTimer(context, action, timeout, singleShot);
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = InspectorTimelineAgent::retrieve(context))
-        timelineAgent->didInstallTimer(timer->m_timeoutId, timeout, singleShot);
-#endif    
+    InspectorInstrumentation::didInstallTimer(context, timer->m_timeoutId, timeout, singleShot);
 
     return timer->m_timeoutId;
 }
@@ -97,10 +94,7 @@ void DOMTimer::removeById(ScriptExecutionContext* context, int timeoutId)
     if (timeoutId <= 0)
         return;
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = InspectorTimelineAgent::retrieve(context))
-        timelineAgent->didRemoveTimer(timeoutId);
-#endif
+    InspectorInstrumentation::didRemoveTimer(context, timeoutId);
 
     delete context->findTimeout(timeoutId);
 }
@@ -110,10 +104,7 @@ void DOMTimer::fired()
     ScriptExecutionContext* context = scriptExecutionContext();
     timerNestingLevel = m_nestingLevel;
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = InspectorTimelineAgent::retrieve(context))
-        timelineAgent->willFireTimer(m_timeoutId);
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTimer(context, m_timeoutId);
 
     // Simple case for non-one-shot timers.
     if (isActive()) {
@@ -125,10 +116,9 @@ void DOMTimer::fired()
 
         // No access to member variables after this point, it can delete the timer.
         m_action->execute(context);
-#if ENABLE(INSPECTOR)
-        if (InspectorTimelineAgent* timelineAgent = InspectorTimelineAgent::retrieve(context))
-            timelineAgent->didFireTimer();
-#endif
+
+        InspectorInstrumentation::didFireTimer(context, cookie);
+
         return;
     }
 
@@ -140,10 +130,7 @@ void DOMTimer::fired()
 
     action->execute(context);
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = InspectorTimelineAgent::retrieve(context))
-        timelineAgent->didFireTimer();
-#endif
+    InspectorInstrumentation::didFireTimer(context, cookie);
 
     timerNestingLevel = 0;
 }
diff --git a/WebCore/page/DOMTimer.h b/WebCore/page/DOMTimer.h
index c1d8d9e..4fc6aae 100644
--- a/WebCore/page/DOMTimer.h
+++ b/WebCore/page/DOMTimer.h
@@ -34,8 +34,6 @@
 
 namespace WebCore {
 
-    class InspectorTimelineAgent;
-
     class DOMTimer : public SuspendableTimer {
     public:
         virtual ~DOMTimer();
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index bb89124..a5dfb4d 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -62,7 +62,7 @@
 #include "IDBFactory.h"
 #include "IDBFactoryBackendInterface.h"
 #include "InspectorController.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "KURL.h"
 #include "Location.h"
 #include "StyleMedia.h"
@@ -1522,15 +1522,6 @@ void DOMWindow::dispatchLoadEvent()
 #endif
 }
 
-#if ENABLE(INSPECTOR)
-InspectorTimelineAgent* DOMWindow::inspectorTimelineAgent() 
-{
-    if (frame() && frame()->page())
-        return frame()->page()->inspectorTimelineAgent();
-    return 0;
-}
-#endif
-
 bool DOMWindow::dispatchEvent(PassRefPtr<Event> prpEvent, PassRefPtr<EventTarget> prpTarget)
 {
     RefPtr<EventTarget> protect = this;
@@ -1540,23 +1531,11 @@ bool DOMWindow::dispatchEvent(PassRefPtr<Event> prpEvent, PassRefPtr<EventTarget
     event->setCurrentTarget(this);
     event->setEventPhase(Event::AT_TARGET);
 
-#if ENABLE(INSPECTOR)
-    Page* inspectedPage = InspectorTimelineAgent::instanceCount() && frame() ? frame()->page() : 0;
-    if (inspectedPage) {
-        if (InspectorTimelineAgent* timelineAgent = hasEventListeners(event->type()) ? inspectedPage->inspectorTimelineAgent() : 0)
-            timelineAgent->willDispatchEvent(*event);
-        else
-            inspectedPage = 0;
-    }
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEventOnWindow(frame(), *event, this);
 
     bool result = fireEventListeners(event.get());
 
-#if ENABLE(INSPECTOR)
-    if (inspectedPage)
-        if (InspectorTimelineAgent* timelineAgent = inspectedPage->inspectorTimelineAgent())
-            timelineAgent->didDispatchEvent();
-#endif
+    InspectorInstrumentation::didDispatchEventOnWindow(frame(), cookie);
 
     return result;
 }
diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h
index 6fd3775..ca45f54 100644
--- a/WebCore/page/DOMWindow.h
+++ b/WebCore/page/DOMWindow.h
@@ -57,7 +57,6 @@ namespace WebCore {
     class Frame;
     class History;
     class IDBFactory;
-    class InspectorTimelineAgent;
     class Location;
     class StyleMedia;
     class Navigator;
@@ -407,7 +406,6 @@ namespace WebCore {
         virtual void derefEventTarget() { deref(); }
         virtual EventTargetData* eventTargetData();
         virtual EventTargetData* ensureEventTargetData();
-        InspectorTimelineAgent* inspectorTimelineAgent();
 
         RefPtr<SecurityOrigin> m_securityOrigin;
         KURL m_url;
diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp
index d399a01..2941f23 100644
--- a/WebCore/page/FrameView.cpp
+++ b/WebCore/page/FrameView.cpp
@@ -45,7 +45,7 @@
 #include "HTMLFrameSetElement.h"
 #include "HTMLNames.h"
 #include "HTMLPlugInImageElement.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "OverflowEvent.h"
 #include "RenderEmbeddedObject.h"
 #include "RenderLayer.h"
@@ -617,10 +617,7 @@ void FrameView::layout(bool allowSubtree)
     if (isPainting())
         return;
 
-#if ENABLE(INSPECTOR)    
-    if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
-        timelineAgent->willLayout();
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLayout(m_frame.get());
 
     if (!allowSubtree && m_layoutRoot) {
         m_layoutRoot->markContainingBlocksForLayout(false);
@@ -840,10 +837,7 @@ void FrameView::layout(bool allowSubtree)
         ASSERT(m_enqueueEvents);
     }
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
-        timelineAgent->didLayout();
-#endif
+    InspectorInstrumentation::didLayout(m_frame.get(), cookie);
 
     m_nestedLayoutCount--;
 }
@@ -1932,10 +1926,7 @@ void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
     if (!frame())
         return;
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
-        timelineAgent->willPaint(rect);
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willPaint(m_frame.get(), rect);
 
     Document* document = frame()->document();
 
@@ -2009,10 +2000,7 @@ void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
     if (isTopLevelPainter)
         sCurrentPaintTimeStamp = 0;
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
-        timelineAgent->didPaint();
-#endif
+    InspectorInstrumentation::didPaint(m_frame.get(), cookie);
 }
 
 void FrameView::setPaintBehavior(PaintBehavior behavior)
diff --git a/WebCore/page/FrameView.h b/WebCore/page/FrameView.h
index 22c05be..5e27433 100644
--- a/WebCore/page/FrameView.h
+++ b/WebCore/page/FrameView.h
@@ -25,9 +25,9 @@
 #ifndef FrameView_h
 #define FrameView_h
 
-#include "Frame.h" // Only used by FrameView::inspectorTimelineAgent()
+#include "Frame.h"
 #include "IntSize.h"
-#include "Page.h" // Only used by FrameView::inspectorTimelineAgent()
+#include "Page.h"
 #include "RenderObject.h" // For PaintBehavior
 #include "ScrollView.h"
 #include <wtf/Forward.h>
@@ -38,7 +38,6 @@ namespace WebCore {
 class Color;
 class Event;
 class FrameViewPrivate;
-class InspectorTimelineAgent;
 class IntRect;
 class Node;
 class PlatformMouseEvent;
@@ -293,10 +292,6 @@ private:
     void scrollToAnchor();
     void scrollPositionChanged();
 
-#if ENABLE(INSPECTOR)
-    InspectorTimelineAgent* inspectorTimelineAgent() const;
-#endif
-    
     bool hasCustomScrollbars() const;
 
     virtual void updateScrollCorner();
@@ -386,13 +381,6 @@ private:
     static double s_deferredRepaintDelayIncrementDuringLoading;
 };
 
-#if ENABLE(INSPECTOR)
-inline InspectorTimelineAgent* FrameView::inspectorTimelineAgent() const
-{
-    return m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0;
-}
-#endif
-
 } // namespace WebCore
 
 #endif // FrameView_h
diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp
index 9a3d3d7..e154968 100644
--- a/WebCore/page/Page.cpp
+++ b/WebCore/page/Page.cpp
@@ -46,7 +46,6 @@
 #include "HTMLElement.h"
 #include "HistoryItem.h"
 #include "InspectorController.h"
-#include "InspectorTimelineAgent.h"
 #include "Logging.h"
 #include "MediaCanStartListener.h"
 #include "Navigator.h"
@@ -841,13 +840,6 @@ bool Page::javaScriptURLsAreAllowed() const
     return m_javaScriptURLsAreAllowed;
 }
 
-#if ENABLE(INSPECTOR)
-InspectorTimelineAgent* Page::inspectorTimelineAgent() const
-{
-    return m_inspectorController->timelineAgent();
-}
-#endif
-
 #if ENABLE(INPUT_SPEECH)
 SpeechInput* Page::speechInput()
 {
diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h
index f7830db..6ff64cf 100644
--- a/WebCore/page/Page.h
+++ b/WebCore/page/Page.h
@@ -61,7 +61,6 @@ namespace WebCore {
     class HistoryItem;
     class InspectorClient;
     class InspectorController;
-    class InspectorTimelineAgent;
     class MediaCanStartListener;
     class Node;
     class PageGroup;
@@ -289,10 +288,6 @@ namespace WebCore {
         void setJavaScriptURLsAreAllowed(bool);
         bool javaScriptURLsAreAllowed() const;
 
-#if ENABLE(INSPECTOR)
-        InspectorTimelineAgent* inspectorTimelineAgent() const;
-#endif
-
         // Don't allow more than a certain number of frames in a page.
         // This seems like a reasonable upper bound, and otherwise mutually
         // recursive frameset pages can quickly bring the program to its knees
diff --git a/WebCore/rendering/RenderLayerBacking.cpp b/WebCore/rendering/RenderLayerBacking.cpp
index f9e2367..f21b670 100644
--- a/WebCore/rendering/RenderLayerBacking.cpp
+++ b/WebCore/rendering/RenderLayerBacking.cpp
@@ -43,7 +43,7 @@
 #include "HTMLIFrameElement.h"
 #include "HTMLMediaElement.h"
 #include "HTMLNames.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "KeyframeList.h"
 #include "PluginViewBase.h"
 #include "RenderBox.h"
@@ -1059,26 +1059,10 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext*
     ASSERT(!m_owningLayer->m_usedTransparency);
 }
 
-#if ENABLE(INSPECTOR)
-static InspectorTimelineAgent* inspectorTimelineAgent(RenderObject* renderer)
-{
-    Frame* frame = renderer->frame();
-    if (!frame)
-        return 0;
-    Page* page = frame->page();
-    if (!page)
-        return 0;
-    return page->inspectorTimelineAgent();
-}
-#endif
-
 // Up-call from compositing layer drawing callback.
 void RenderLayerBacking::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase paintingPhase, const IntRect& clip)
 {
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent(m_owningLayer->renderer()))
-        timelineAgent->willPaint(clip);
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willPaint(m_owningLayer->renderer()->frame(), clip);
 
     // We have to use the same root as for hit testing, because both methods
     // can compute and cache clipRects.
@@ -1098,10 +1082,7 @@ void RenderLayerBacking::paintContents(const GraphicsLayer*, GraphicsContext& co
 
     paintIntoLayer(m_owningLayer, &context, dirtyRect, PaintBehaviorNormal, paintingPhase, renderer());
 
-#if ENABLE(INSPECTOR)
-    if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent(m_owningLayer->renderer()))
-        timelineAgent->didPaint();
-#endif
+    InspectorInstrumentation::didPaint(m_owningLayer->renderer()->frame(), cookie);
 }
 
 bool RenderLayerBacking::showDebugBorders() const
diff --git a/WebCore/xml/XMLHttpRequest.cpp b/WebCore/xml/XMLHttpRequest.cpp
index 07a816d..efbe07a 100644
--- a/WebCore/xml/XMLHttpRequest.cpp
+++ b/WebCore/xml/XMLHttpRequest.cpp
@@ -35,7 +35,7 @@
 #include "File.h"
 #include "HTTPParsers.h"
 #include "InspectorController.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
 #include "ResourceError.h"
 #include "ResourceRequest.h"
 #include "SecurityOrigin.h"
@@ -303,35 +303,17 @@ void XMLHttpRequest::callReadyStateChangeListener()
     if (!scriptExecutionContext())
         return;
 
-#if ENABLE(INSPECTOR)
-    InspectorTimelineAgent* timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext());
-    bool callTimelineAgentOnReadyStateChange = timelineAgent && hasEventListeners(eventNames().readystatechangeEvent);
-    if (callTimelineAgentOnReadyStateChange)
-        timelineAgent->willChangeXHRReadyState(m_url.string(), m_state);
-#endif
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willChangeXHRReadyState(scriptExecutionContext(), this);
 
     if (m_async || (m_state <= OPENED || m_state == DONE))
         m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().readystatechangeEvent), m_state == DONE ? FlushProgressEvent : DoNotFlushProgressEvent);
 
-#if ENABLE(INSPECTOR)
-    if (callTimelineAgentOnReadyStateChange && (timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext())))
-        timelineAgent->didChangeXHRReadyState();
-#endif
+    InspectorInstrumentation::didChangeXHRReadyState(scriptExecutionContext(), cookie);
 
     if (m_state == DONE && !m_error) {
-#if ENABLE(INSPECTOR)
-        timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext());
-        bool callTimelineAgentOnLoad = timelineAgent && hasEventListeners(eventNames().loadEvent);
-        if (callTimelineAgentOnLoad)
-            timelineAgent->willLoadXHR(m_url.string());
-#endif
-
+        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLoadXHR(scriptExecutionContext(), this);
         m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadEvent));
-
-#if ENABLE(INSPECTOR)
-        if (callTimelineAgentOnLoad && (timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext())))
-            timelineAgent->didLoadXHR();
-#endif
+        InspectorInstrumentation::didLoadXHR(scriptExecutionContext(), cookie);
     }
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list