2011-04-25 Pavel Feldman <pfeldman@google.com>
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Apr 2011 14:12:28 +0000 (14:12 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Apr 2011 14:12:28 +0000 (14:12 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: move Frame and Resource Tree management into the Page agent.
        https://bugs.webkit.org/show_bug.cgi?id=59321

        * inspector/report-protocol-errors.html:
2011-04-25  Yury Semikhatsky  <yurys@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: introduce InspectorWorkerAgent
        https://bugs.webkit.org/show_bug.cgi?id=59320

        InspectorWorkerAgent is responsible for routing inspector messages
        between worker context inspector agents and corresponding worker
        inspector front-end.

        * CMakeLists.txt:
        * GNUmakefile.list.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * inspector/CodeGeneratorInspector.pm:
        * inspector/Inspector.json:
        * inspector/InspectorAgent.cpp:
        (WebCore::InspectorAgent::InspectorAgent):
        (WebCore::InspectorAgent::setFrontend):
        (WebCore::InspectorAgent::disconnectFrontend):
        * inspector/InspectorAgent.h:
        (WebCore::InspectorAgent::workerAgent):
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::connectFrontend):
        (WebCore::InspectorController::disconnectFrontend):
        * inspector/InspectorInstrumentation.cpp:
        (WebCore::InspectorInstrumentation::didStartWorkerContextImpl):
        * inspector/InspectorInstrumentation.h:
        (WebCore::InspectorInstrumentation::willStartWorkerContext):
        (WebCore::InspectorInstrumentation::didStartWorkerContext):
        * inspector/InspectorWorkerAgent.cpp: Added.
        (WebCore::InspectorWorkerAgent::WorkerFrontendChannel::WorkerFrontendChannel):
        (WebCore::InspectorWorkerAgent::WorkerFrontendChannel::~WorkerFrontendChannel):
        (WebCore::InspectorWorkerAgent::WorkerFrontendChannel::id):
        (WebCore::InspectorWorkerAgent::WorkerFrontendChannel::inspectorProxy):
        (WebCore::InspectorWorkerAgent::WorkerFrontendChannel::sendMessageToFrontend):
        (WebCore::InspectorWorkerAgent::create):
        (WebCore::InspectorWorkerAgent::InspectorWorkerAgent):
        (WebCore::InspectorWorkerAgent::~InspectorWorkerAgent):
        (WebCore::InspectorWorkerAgent::setFrontend):
        (WebCore::InspectorWorkerAgent::clearFrontend):
        (WebCore::InspectorWorkerAgent::dispatchMessageOnWorkerInspector):
        (WebCore::InspectorWorkerAgent::didStartWorkerContext):
        * inspector/InspectorWorkerAgent.h: Added.
        * inspector/InstrumentingAgents.h:
        (WebCore::InstrumentingAgents::InstrumentingAgents):
        (WebCore::InstrumentingAgents::inspectorWorkerAgent):
        (WebCore::InstrumentingAgents::setInspectorWorkerAgent):
        * inspector/WorkerInspectorController.cpp:
        (WebCore::WorkerInspectorController::connectFrontend):
        * inspector/generate-inspector-idl:
        * workers/Worker.cpp:
        (WebCore::Worker::notifyFinished):
        * workers/WorkerContextInspectorProxy.h: Added. Platform-specific transport for inspector
        messages sent from the inspected page worker agent to the worker context inspector agents.
        (WebCore::WorkerContextInspectorProxy::connectFrontend):
        (WebCore::WorkerContextInspectorProxy::disconnectFrontend):
        (WebCore::WorkerContextInspectorProxy::sendMessageToWorkerContextInspector):
        (WebCore::WorkerContextInspectorProxy::~WorkerContextInspectorProxy):
        * workers/WorkerContextProxy.h:
        (WebCore::WorkerContextProxy::inspectorProxy):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@84774 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/report-protocol-errors.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.h
Source/WebCore/inspector/InspectorResourceAgent.cpp
Source/WebCore/inspector/InspectorResourceAgent.h
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebCore/inspector/front-end/NetworkManager.js
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/ResourceTreeModel.js
Source/WebCore/inspector/front-end/inspector.js

index f126f2d..78733f6 100644 (file)
@@ -2,6 +2,15 @@
 
         Reviewed by Yury Semikhatsky.
 
+        Web Inspector: move Frame and Resource Tree management into the Page agent.
+        https://bugs.webkit.org/show_bug.cgi?id=59321
+
+        * inspector/report-protocol-errors.html:
+
+2011-04-25  Pavel Feldman  <pfeldman@google.com>
+
+        Reviewed by Yury Semikhatsky.
+
         Web Inspector: few protocol improvements.
         https://bugs.webkit.org/show_bug.cgi?id=59319
 
index 590e3e6..530a0a6 100644 (file)
@@ -12,10 +12,10 @@ function test()
         '{"id":1,"method":1}',
         '{"id":2,"method":"resourceContent"}',
         '{"id":3,"method":"DOM.test"}',
-        '{"id":4,"method":"Network.getResourceContent"}',
-        '{"id":5,"method":"Network.getResourceContent","params":[]}',
-        '{"id":6,"method":"Network.getResourceContent","params":{}}',
-        '{"id":7,"method":"Network.getResourceContent","params":{"frameId":"not a number"}}',
+        '{"id":4,"method":"Page.getResourceContent"}',
+        '{"id":5,"method":"Page.getResourceContent","params":[]}',
+        '{"id":6,"method":"Page.getResourceContent","params":{}}',
+        '{"id":7,"method":"Page.getResourceContent","params":{"frameId":"not a number"}}',
     ];
     var numberOfReports = 0;
 
index 57f5ae8..3f042d9 100644 (file)
 
         Reviewed by Yury Semikhatsky.
 
+        Web Inspector: move Frame and Resource Tree management into the Page agent.
+        https://bugs.webkit.org/show_bug.cgi?id=59321
+
+        Network agent should only handle network-related activities.
+        Frame structure should be managed by the Page agent instead.
+
+        * inspector/Inspector.json:
+        * inspector/InspectorAgent.cpp:
+        (WebCore::InspectorAgent::InspectorAgent):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::InspectorDOMAgent):
+        (WebCore::InspectorDOMAgent::setFrontend):
+        (WebCore::InspectorDOMAgent::restore):
+        (WebCore::InspectorDOMAgent::highlightFrame):
+        * inspector/InspectorDOMAgent.h:
+        (WebCore::InspectorDOMAgent::create):
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::domContentLoadedEventFiredImpl):
+        (WebCore::InspectorInstrumentation::loadEventFiredImpl):
+        (WebCore::InspectorInstrumentation::frameDetachedFromParentImpl):
+        (WebCore::InspectorInstrumentation::didCommitLoadImpl):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::create):
+        (WebCore::InspectorPageAgent::resourceContent):
+        (WebCore::InspectorPageAgent::resourceContentBase64):
+        (WebCore::InspectorPageAgent::resourceData):
+        (WebCore::InspectorPageAgent::cachedResource):
+        (WebCore::InspectorPageAgent::resourceTypeString):
+        (WebCore::InspectorPageAgent::cachedResourceType):
+        (WebCore::InspectorPageAgent::cachedResourceTypeString):
+        (WebCore::InspectorPageAgent::InspectorPageAgent):
+        (WebCore::InspectorPageAgent::setFrontend):
+        (WebCore::InspectorPageAgent::reload):
+        (WebCore::InspectorPageAgent::open):
+        (WebCore::InspectorPageAgent::getCookies):
+        (WebCore::InspectorPageAgent::deleteCookie):
+        (WebCore::InspectorPageAgent::getResourceTree):
+        (WebCore::InspectorPageAgent::getResourceContent):
+        (WebCore::InspectorPageAgent::restore):
+        (WebCore::InspectorPageAgent::domContentEventFired):
+        (WebCore::InspectorPageAgent::loadEventFired):
+        (WebCore::InspectorPageAgent::frameNavigated):
+        (WebCore::InspectorPageAgent::frameDetached):
+        (WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
+        (WebCore::InspectorPageAgent::mainFrame):
+        (WebCore::pointerAsId):
+        (WebCore::InspectorPageAgent::frameForId):
+        (WebCore::InspectorPageAgent::frameId):
+        (WebCore::InspectorPageAgent::loaderId):
+        (WebCore::InspectorPageAgent::buildObjectForFrame):
+        (WebCore::InspectorPageAgent::buildObjectForFrameTree):
+        * inspector/InspectorPageAgent.h:
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::buildObjectForCachedResource):
+        (WebCore::InspectorResourceAgent::willSendRequest):
+        (WebCore::InspectorResourceAgent::didReceiveResponse):
+        (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache):
+        (WebCore::InspectorResourceAgent::setInitialScriptContent):
+        (WebCore::InspectorResourceAgent::setInitialXHRContent):
+        (WebCore::InspectorResourceAgent::InspectorResourceAgent):
+        * inspector/InspectorResourceAgent.h:
+        (WebCore::InspectorResourceAgent::create):
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyleSheet::resourceStyleSheetText):
+        * inspector/front-end/NetworkManager.js:
+        (WebInspector.NetworkManager.prototype.requestContent):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel):
+        (WebInspector.NetworkPanel.prototype.frameNavigated):
+        * inspector/front-end/ResourceTreeModel.js:
+        (WebInspector.ResourceTreeModel):
+        (WebInspector.ResourceTreeModel.prototype.frontendReused):
+        (WebInspector.ResourceTreeModel.prototype.frameNavigated):
+        (WebInspector.ResourceTreeModel.prototype.frameDetached):
+        * inspector/front-end/inspector.js:
+        (WebInspector.domContentEventFired):
+        (WebInspector.loadEventFired):
+        (WebInspector.frameNavigated):
+        (WebInspector.frameDetached):
+
+2011-04-25  Pavel Feldman  <pfeldman@google.com>
+
+        Reviewed by Yury Semikhatsky.
+
         Web Inspector: few protocol improvements.
         https://bugs.webkit.org/show_bug.cgi?id=59319
 
index ce8817a..2994506 100644 (file)
     {
         "domain": "Page",
         "description": "Actions and events related to the inspected page belong to the page domain.",
-        "types": [],
+        "types": [
+            {
+                "id": "ResourceType",
+                "type": "string",
+                "enum": ["Document", "Stylesheet", "Image", "Font", "Script", "XHR", "WebSocket", "Other"],
+                "description": "Resource type as it was perceived by the rendering enging."
+            },
+            {
+                "id": "Frame",
+                "type": "object",
+                "description": "Information about the Frame on the page.",
+                "properties": [
+                    { "name": "id", "type": "string", "description": "Frame unique identifier." },
+                    { "name": "parentId", "type": "string", "description": "Parent frame identifier." },
+                    { "name": "loaderId", "type": "string", "description": "Identifier of the loader associated with this frame." },
+                    { "name": "name", "type": "string", "optional": true, "description": "Frame's name as specified in the tag." },
+                    { "name": "url", "type": "string", "description": "Frame document's URL." }
+                ]
+            },
+            {
+                "id": "FrameResourceTree",
+                "type": "object",
+                "description": "Information about the Frame hierarchy along with their cached resources.",
+                "properties": [
+                    { "name": "frame", "$ref": "Frame", "description": "Frame information for this tree item." },
+                    { "name": "childFrames", "type": "array", "optional": true, "items": { "$ref": "FrameResourceTree" }, "description": "Child frames." },
+                    { "name": "resources", "type": "array",
+                        "items": {
+                            "type": "object",
+                            "properties": [
+                                { "name": "url", "type": "string", "description": "Resource URL." },
+                                { "name": "type", "$ref": "ResourceType", "description": "Type of this resource." }
+                            ]
+                        },
+                        "description": "Information about frame resources."
+                    }
+                ]
+            }
+        ],
         "commands": [
             {
                 "name": "addScriptToEvaluateOnLoad",
                     { "name": "domain", "type": "string", "description": "Domain of the cookie to remove." }
                 ],
                 "description": "Deletes browser cookie with given name for the given domain."
+            },
+            {
+                "name": "getResourceTree",
+                "description": "Returns present frame / resource tree structure.",
+                "returns": [
+                    { "name": "frameTree", "$ref": "FrameResourceTree", "description": "Present frame / resource tree structure." }
+                ]
+            },
+            {
+                "name": "getResourceContent",
+                "description": "Returns content of the given resource.",
+                "parameters": [
+                    { "name": "frameId", "type": "string", "description": "Frame id to get resource for." },
+                    { "name": "url", "type": "string", "description": "URL of the resource to get content for." },
+                    { "name": "base64Encode", "type": "boolean", "optional": true, "description": "Requests that resource content is served as base64." }
+                ],
+                "returns": [
+                    { "name": "content", "type": "string", "description": "Resource content." }
+                ]
             }
         ],
         "events": [
                 "parameters": [
                     { "name": "timestamp", "type": "number" }
                 ]
+            },
+            {
+                "name": "frameNavigated",
+                "description": "Fired once navigation of the frame has completed. Frame is now associated with the new loader.",
+                "parameters": [
+                    { "name": "frame", "$ref": "Frame", "description": "Frame object." },
+                    { "name": "loaderId", "type": "string", "description": "Loader identifier." }
+                ]
+            },
+            {
+                "name": "frameDetached",
+                "description": "Fired when frame has been detached from its parent.",
+                "parameters": [
+                    { "name": "frameId", "type": "string", "description": "Id of the frame that has been detached." }
+                ]
             }
         ]
     },
                 ]
             },
             {
-                "id": "ResourceType",
-                "type": "string",
-                "enum": ["Document", "Stylesheet", "Image", "Font", "Script", "XHR", "WebSocket", "Other"],
-                "description": "Resource type as it was perceived by the rendering enging."
-            },
-            {
                 "id": "CachedResource",
                 "type": "object",
                 "description": "Information about the cached resource.",
                 "properties": [
                     { "name": "url", "type": "string", "description": "Resource URL." },
-                    { "name": "type", "$ref": "ResourceType", "description": "Type of this resource." },
+                    { "name": "type", "$ref": "Page.ResourceType", "description": "Type of this resource." },
                     { "name": "response", "$ref": "ResourceResponse", "description": "Cached response data." },
                     { "name": "bodySize", "type": "number", "description": "Cached response body size." }
                 ]
-            },
-            {
-                "id": "Frame",
-                "type": "object",
-                "description": "Information about the Frame on the page.",
-                "properties": [
-                    { "name": "id", "type": "string", "description": "Frame unique identifier." },
-                    { "name": "parentId", "type": "string", "description": "Parent frame identifier." },
-                    { "name": "loaderId", "type": "string", "description": "Identifier of the loader associated with this frame." },
-                    { "name": "name", "type": "string", "optional": true, "description": "Frame's name as specified in the tag." },
-                    { "name": "url", "type": "string", "description": "Frame document's URL." }
-                ]
-            },
-            {
-                "id": "FrameResourceTree",
-                "type": "object",
-                "description": "Information about the Frame hierarchy along with their cached resources.",
-                "properties": [
-                    { "name": "frame", "$ref": "Frame", "description": "Frame information for this tree item." },
-                    { "name": "childFrames", "type": "array", "optional": true, "items": { "$ref": "FrameResourceTree" }, "description": "Child frames." },
-                    { "name": "resources", "type": "array",
-                        "items": {
-                            "type": "object",
-                            "properties": [
-                                { "name": "url", "type": "string", "description": "Resource URL." },
-                                { "name": "type", "$ref": "ResourceType", "description": "Type of this resource." }
-                            ]
-                        },
-                        "description": "Information about frame resources."
-                    }
-                ]
             }
         ],
         "commands": [
                 "description": "Disables network tracking, prevents network events from being sent to the client."
             },
             {
-                "name": "getCachedResources",
-                "description": "Returns present frame / resource tree structure.",
-                "returns": [
-                    { "name": "frameTree", "$ref": "FrameResourceTree", "description": "Present frame / resource tree structure." }
-                ]
-            },
-            {
-                "name": "getResourceContent",
-                "description": "Returns content of the given resource.",
-                "parameters": [
-                    { "name": "frameId", "type": "string", "description": "Frame id to get resource for." },
-                    { "name": "url", "type": "string", "description": "URL of the resource to get content for." },
-                    { "name": "base64Encode", "type": "boolean", "optional": true, "description": "Requests that resource content is served as base64." }
-                ],
-                "returns": [
-                    { "name": "content", "type": "string", "description": "Resource content." }
-                ]
-            },
-            {
                 "name": "setUserAgentOverride",
                 "description": "Allows overriding user agent with the given string.",
                 "parameters": [
         ],
         "events": [
             {
-                "name": "domContentEventFired",
-                "parameters": [
-                    { "name": "time", "type": "number" }
-                ]
-            },
-            {
-                "name": "loadEventFired",
-                "parameters": [
-                    { "name": "time", "type": "number" }
-                ]
-            },
-            {
-                "name": "frameDetached",
-                "description": "Fired when frame has been detached from its parent.",
-                "parameters": [
-                    { "name": "frameId", "type": "string", "description": "Id of the frame that has been detached." }
-                ]
-            },
-            {
                 "name": "requestWillBeSent",
                 "description": "Fired when page is about to send HTTP request.",
                 "parameters": [
                 "parameters": [
                     { "name": "identifier", "type": "integer", "description": "Request identifier." },
                     { "name": "timestamp", "type": "number", "description": "Timestamp." },
-                    { "name": "type", "$ref": "ResourceType", "description": "Resource type." },
+                    { "name": "type", "$ref": "Page.ResourceType", "description": "Resource type." },
                     { "name": "response", "$ref": "ResourceResponse", "description": "Response data." }
                 ]
             },
                 "parameters": [
                     { "name": "identifier", "type": "integer", "description": "Request identifier." },
                     { "name": "content", "type": "string", "description": "Resource content." },
-                    { "name": "type", "$ref": "ResourceType", "description": "Resource type." }
-                ]
-            },
-            {
-                "name": "frameNavigated",
-                "description": "Fired once navigation of the frame has completed. Frame is now associated with the new loader.",
-                "parameters": [
-                    { "name": "frame", "$ref": "Frame", "description": "Frame identifier." },
-                    { "name": "loaderId", "type": "string", "description": "Loader identifier." }
+                    { "name": "type", "$ref": "Page.ResourceType", "description": "Resource type." }
                 ]
             },
             {
index 8492367..f53ff3c 100644 (file)
@@ -114,7 +114,7 @@ InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScri
     , m_injectedScriptManager(injectedScriptManager)
     , m_state(new InspectorState(client))
     , m_pageAgent(InspectorPageAgent::create(m_instrumentingAgents.get(), page, injectedScriptManager))
-    , m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), page, m_client, m_state.get(), injectedScriptManager))
+    , m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), m_pageAgent.get(), m_client, m_state.get(), injectedScriptManager))
     , m_cssAgent(new InspectorCSSAgent(m_instrumentingAgents.get(), m_domAgent.get()))
 #if ENABLE(DATABASE)
     , m_databaseAgent(InspectorDatabaseAgent::create(m_instrumentingAgents.get(), m_state.get()))
@@ -126,7 +126,7 @@ InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScri
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
     , m_applicationCacheAgent(new InspectorApplicationCacheAgent(m_instrumentingAgents.get(), page))
 #endif
-    , m_resourceAgent(InspectorResourceAgent::create(m_instrumentingAgents.get(), page, m_state.get()))
+    , m_resourceAgent(InspectorResourceAgent::create(m_instrumentingAgents.get(), m_pageAgent.get(), m_state.get()))
     , m_runtimeAgent(adoptPtr(new PageRuntimeAgent(m_injectedScriptManager, page)))
     , m_consoleAgent(new InspectorConsoleAgent(m_instrumentingAgents.get(), this, m_state.get(), injectedScriptManager, m_domAgent.get()))
 #if ENABLE(JAVASCRIPT_DEBUGGER)
index bf89eb6..8db6574 100644 (file)
@@ -64,7 +64,7 @@
 #include "InjectedScriptManager.h"
 #include "InspectorClient.h"
 #include "InspectorFrontend.h"
-#include "InspectorResourceAgent.h"
+#include "InspectorPageAgent.h"
 #include "InspectorState.h"
 #include "InstrumentingAgents.h"
 #include "MutationEvent.h"
@@ -257,9 +257,9 @@ void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*)
     m_elements.clear();
 }
 
-InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, Page* inspectedPage, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
+InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
     : m_instrumentingAgents(instrumentingAgents)
-    , m_inspectedPage(inspectedPage)
+    , m_pageAgent(pageAgent)
     , m_client(client)
     , m_inspectorState(inspectorState)
     , m_injectedScriptManager(injectedScriptManager)
@@ -283,7 +283,7 @@ void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend)
     ASSERT(!m_frontend);
     m_frontend = frontend->dom();
     m_instrumentingAgents->setInspectorDOMAgent(this);
-    m_document = m_inspectedPage->mainFrame()->document();
+    m_document = m_pageAgent->mainFrame()->document();
 
     if (m_nodeToFocus)
         focusNode();
@@ -307,7 +307,7 @@ void InspectorDOMAgent::restore()
 {
     // Reset document to avoid early return from setDocument.
     m_document = 0;
-    setDocument(m_inspectedPage->mainFrame()->document());
+    setDocument(m_pageAgent->mainFrame()->document());
 }
 
 Vector<Document*> InspectorDOMAgent::documents()
@@ -962,7 +962,7 @@ void InspectorDOMAgent::highlightNode(ErrorString* error, int nodeId, String* mo
 
 void InspectorDOMAgent::highlightFrame(ErrorString* error, const String& frameId)
 {
-    Frame* frame = m_instrumentingAgents->inspectorResourceAgent()->frameForId(frameId);
+    Frame* frame = m_pageAgent->frameForId(frameId);
     if (frame && frame->ownerElement())
         highlight(error, frame->ownerElement(), "all");
 }
index 2849490..e47a094 100644 (file)
@@ -57,6 +57,7 @@ class GraphicsContext;
 class InspectorClient;
 class InspectorDOMAgent;
 class InspectorFrontend;
+class InspectorPageAgent;
 class HitTestResult;
 class MatchJob;
 class HTMLElement;
@@ -64,7 +65,6 @@ class InspectorState;
 class InstrumentingAgents;
 class NameNodeMap;
 class Node;
-class Page;
 class RevalidateStyleAttributeTask;
 class ScriptValue;
 
@@ -96,9 +96,9 @@ public:
         virtual void didModifyDOMAttr(Element*) = 0;
     };
 
-    static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
+    static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
     {
-        return adoptPtr(new InspectorDOMAgent(instrumentingAgents, page, client, inspectorState, injectedScriptManager));
+        return adoptPtr(new InspectorDOMAgent(instrumentingAgents, pageAgent, client, inspectorState, injectedScriptManager));
     }
 
     ~InspectorDOMAgent();
@@ -175,7 +175,7 @@ public:
     static bool isWhitespace(Node*);
 
 private:
-    InspectorDOMAgent(InstrumentingAgents*, Page*, InspectorClient*, InspectorState*, InjectedScriptManager*);
+    InspectorDOMAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorClient*, InspectorState*, InjectedScriptManager*);
 
     void setSearchingForNode(bool enabled);
     void highlight(ErrorString*, Node*, const String& mode);
@@ -208,7 +208,7 @@ private:
     void discardBindings();
 
     InstrumentingAgents* m_instrumentingAgents;
-    Page* m_inspectedPage;
+    InspectorPageAgent* m_pageAgent;
     InspectorClient* m_client;
     InspectorState* m_inspectorState;
     InjectedScriptManager* m_injectedScriptManager;
index 23e96fc..ec00c23 100644 (file)
@@ -531,9 +531,6 @@ void InspectorInstrumentation::domContentLoadedEventFiredImpl(InspectorAgent* in
     if (InspectorTimelineAgent* timelineAgent = inspectorAgent->instrumentingAgents()->inspectorTimelineAgent())
         timelineAgent->didMarkDOMContentEvent();
 
-    if (InspectorResourceAgent* resourceAgent = inspectorAgent->instrumentingAgents()->inspectorResourceAgent())
-        resourceAgent->domContentEventFired();
-
     if (InspectorPageAgent* pageAgent = inspectorAgent->instrumentingAgents()->inspectorPageAgent())
         pageAgent->domContentEventFired();
 }
@@ -552,17 +549,14 @@ void InspectorInstrumentation::loadEventFiredImpl(InspectorAgent* inspectorAgent
     if (InspectorTimelineAgent* timelineAgent = inspectorAgent->instrumentingAgents()->inspectorTimelineAgent())
         timelineAgent->didMarkLoadEvent();
 
-    if (InspectorResourceAgent* resourceAgent = inspectorAgent->instrumentingAgents()->inspectorResourceAgent())
-        resourceAgent->loadEventFired();
-
     if (InspectorPageAgent* pageAgent = inspectorAgent->instrumentingAgents()->inspectorPageAgent())
         pageAgent->loadEventFired();
 }
 
 void InspectorInstrumentation::frameDetachedFromParentImpl(InspectorAgent* inspectorAgent, Frame* frame)
 {
-    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(inspectorAgent))
-        resourceAgent->frameDetachedFromParent(frame);
+    if (InspectorPageAgent* pageAgent = inspectorAgent->instrumentingAgents()->inspectorPageAgent())
+        pageAgent->frameDetached(frame);
 }
 
 void InspectorInstrumentation::didCommitLoadImpl(Page* page, InspectorAgent* inspectorAgent, DocumentLoader* loader)
@@ -571,8 +565,9 @@ void InspectorInstrumentation::didCommitLoadImpl(Page* page, InspectorAgent* ins
         return;
 
     InstrumentingAgents* instrumentingAgents = inspectorAgent->instrumentingAgents();
-    if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
-        resourceAgent->didCommitLoad(loader);
+
+    if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
+        pageAgent->frameNavigated(loader);
 
     Frame* mainFrame = page->mainFrame();
     if (loader->frame() != mainFrame)
@@ -605,9 +600,6 @@ void InspectorInstrumentation::didCommitLoadImpl(Page* page, InspectorAgent* ins
     if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
         domAgent->setDocument(mainFrame->document());
 
-    if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
-        pageAgent->inspectedURLChanged(loader->url().string());
-
     inspectorAgent->didCommitLoad();
 }
 
index 8ff2f10..df20bf1 100644 (file)
 
 #if ENABLE(INSPECTOR)
 
+#include "Base64.h"
 #include "CachedResourceLoader.h"
 #include "Cookie.h"
 #include "CookieJar.h"
+#include "Document.h"
 #include "DocumentLoader.h"
 #include "Frame.h"
 #include "FrameLoadRequest.h"
+#include "HTMLFrameOwnerElement.h"
+#include "HTMLNames.h"
 #include "InjectedScriptManager.h"
 #include "InspectorFrontend.h"
 #include "InspectorValues.h"
 #include "InstrumentingAgents.h"
+#include "MemoryCache.h"
 #include "Page.h"
 #include "ScriptObject.h"
+#include "SharedBuffer.h"
+#include "TextEncoding.h"
 #include "UserGestureIndicator.h"
 #include "WindowFeatures.h"
+
 #include <wtf/CurrentTime.h>
 #include <wtf/ListHashSet.h>
 
 namespace WebCore {
 
-PassOwnPtr<InspectorPageAgent> InspectorPageAgent::create(InstrumentingAgents* instrumentingAgents, Page* inspectedPage, InjectedScriptManager* injectedScriptManager)
+PassOwnPtr<InspectorPageAgent> InspectorPageAgent::create(InstrumentingAgents* instrumentingAgents, Page* page, InjectedScriptManager* injectedScriptManager)
+{
+    return adoptPtr(new InspectorPageAgent(instrumentingAgents, page, injectedScriptManager));
+}
+
+void InspectorPageAgent::resourceContent(ErrorString* errorString, Frame* frame, const KURL& url, String* result)
+{
+    if (!frame) {
+        *errorString = "No frame to get resource content for";
+        return;
+    }
+
+    String textEncodingName;
+    RefPtr<SharedBuffer> buffer = InspectorPageAgent::resourceData(frame, url, &textEncodingName);
+
+    if (buffer) {
+        TextEncoding encoding(textEncodingName);
+        if (!encoding.isValid())
+            encoding = WindowsLatin1Encoding();
+        *result = encoding.decode(buffer->data(), buffer->size());
+        return;
+    }
+    *errorString = "No resource with given URL found";
+}
+
+void InspectorPageAgent::resourceContentBase64(ErrorString* errorString, Frame* frame, const KURL& url, String* result)
 {
-    return adoptPtr(new InspectorPageAgent(instrumentingAgents, inspectedPage, injectedScriptManager));
+    String textEncodingName;
+    RefPtr<SharedBuffer> data = InspectorPageAgent::resourceData(frame, url, &textEncodingName);
+    if (!data) {
+        *result = String();
+        *errorString = "No resource with given URL found";
+        return;
+    }
+
+    *result = base64Encode(data->data(), data->size());
 }
 
-InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* inspectedPage, InjectedScriptManager* injectedScriptManager)
+PassRefPtr<SharedBuffer> InspectorPageAgent::resourceData(Frame* frame, const KURL& url, String* textEncodingName)
+{
+    FrameLoader* frameLoader = frame->loader();
+    DocumentLoader* loader = frameLoader->documentLoader();
+    if (equalIgnoringFragmentIdentifier(url, loader->url())) {
+        *textEncodingName = frame->document()->inputEncoding();
+        return frameLoader->documentLoader()->mainResourceData();
+    }
+
+    CachedResource* cachedResource = InspectorPageAgent::cachedResource(frame, url);
+    if (!cachedResource)
+        return 0;
+
+    // Zero-sized resources don't have data at all -- so fake the empty buffer, insted of indicating error by returning 0.
+    if (!cachedResource->encodedSize())
+        return SharedBuffer::create();
+
+    if (cachedResource->isPurgeable()) {
+        // If the resource is purgeable then make it unpurgeable to get
+        // get its data. This might fail, in which case we return an
+        // empty String.
+        // FIXME: should we do something else in the case of a purged
+        // resource that informs the user why there is no data in the
+        // inspector?
+        if (!cachedResource->makePurgeable(false))
+            return 0;
+    }
+
+    *textEncodingName = cachedResource->encoding();
+    return cachedResource->data();
+}
+
+CachedResource* InspectorPageAgent::cachedResource(Frame* frame, const KURL& url)
+{
+    CachedResource* cachedResource = frame->document()->cachedResourceLoader()->cachedResource(url);
+    if (!cachedResource)
+        cachedResource = memoryCache()->resourceForURL(url);
+    return cachedResource;
+}
+
+String InspectorPageAgent::resourceTypeString(InspectorPageAgent::ResourceType resourceType)
+{
+    switch (resourceType) {
+    case DocumentResource:
+        return "Document";
+    case ImageResource:
+        return "Image";
+    case FontResource:
+        return "Font";
+    case StylesheetResource:
+        return "Stylesheet";
+    case ScriptResource:
+        return "Script";
+    case XHRResource:
+        return "XHR";
+    case WebSocketResource:
+        return "WebSocket";
+    case OtherResource:
+        return "Other";
+    }
+    return "Other";
+}
+
+InspectorPageAgent::ResourceType InspectorPageAgent::cachedResourceType(const CachedResource& cachedResource)
+{
+    switch (cachedResource.type()) {
+    case CachedResource::ImageResource:
+        return InspectorPageAgent::ImageResource;
+    case CachedResource::FontResource:
+        return InspectorPageAgent::FontResource;
+    case CachedResource::CSSStyleSheet:
+        // Fall through.
+#if ENABLE(XSLT)
+    case CachedResource::XSLStyleSheet:
+#endif
+        return InspectorPageAgent::StylesheetResource;
+    case CachedResource::Script:
+        return InspectorPageAgent::ScriptResource;
+    default:
+        break;
+    }
+    return InspectorPageAgent::OtherResource;
+}
+
+String InspectorPageAgent::cachedResourceTypeString(const CachedResource& cachedResource)
+{
+    return resourceTypeString(cachedResourceType(cachedResource));
+}
+
+InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* page, InjectedScriptManager* injectedScriptManager)
     : m_instrumentingAgents(instrumentingAgents)
-    , m_inspectedPage(inspectedPage)
+    , m_page(page)
     , m_injectedScriptManager(injectedScriptManager)
     , m_frontend(0)
 {
@@ -68,12 +198,11 @@ InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents,
 
 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend)
 {
-    m_frontend = frontend;
+    m_frontend = frontend->page();
     m_instrumentingAgents->setInspectorPageAgent(this);
 
     // Initialize Web Inspector title.
-    m_frontend->page()->inspectedURLChanged(m_inspectedPage->mainFrame()->document()->url().string());
-
+    m_frontend->inspectedURLChanged(m_page->mainFrame()->document()->url().string());
 }
 
 void InspectorPageAgent::clearFrontend()
@@ -94,12 +223,12 @@ void InspectorPageAgent::removeAllScriptsToEvaluateOnLoad(ErrorString*)
 
 void InspectorPageAgent::reload(ErrorString*, const bool* const optionalIgnoreCache)
 {
-    m_inspectedPage->mainFrame()->loader()->reload(optionalIgnoreCache ? *optionalIgnoreCache : false);
+    m_page->mainFrame()->loader()->reload(optionalIgnoreCache ? *optionalIgnoreCache : false);
 }
 
 void InspectorPageAgent::open(ErrorString*, const String& url, const bool* const inNewWindow)
 {
-    Frame* mainFrame = m_inspectedPage->mainFrame();
+    Frame* mainFrame = m_page->mainFrame();
     Frame* frame;
     if (inNewWindow && *inNewWindow) {
         FrameLoadRequest request(mainFrame->document()->securityOrigin(), ResourceRequest(), "_blank");
@@ -159,7 +288,7 @@ void InspectorPageAgent::getCookies(ErrorString*, RefPtr<InspectorArray>* cookie
     // always return the same true/false value.
     bool rawCookiesImplemented = false;
 
-    for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree()->traverseNext(m_inspectedPage->mainFrame())) {
+    for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext(mainFrame())) {
         Document* document = frame->document();
         const CachedResourceLoader::DocumentResourceMap& allResources = document->cachedResourceLoader()->allCachedResources();
         CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
@@ -192,7 +321,7 @@ void InspectorPageAgent::getCookies(ErrorString*, RefPtr<InspectorArray>* cookie
 
 void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, const String& domain)
 {
-    for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree()->traverseNext(m_inspectedPage->mainFrame())) {
+    for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame())) {
         Document* document = frame->document();
         if (document->url().host() != domain)
             continue;
@@ -203,29 +332,48 @@ void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co
     }
 }
 
-void InspectorPageAgent::inspectedURLChanged(const String& url)
+void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<InspectorObject>* object)
 {
-    m_frontend->page()->inspectedURLChanged(url);
+    *object = buildObjectForFrameTree(m_page->mainFrame());
 }
 
-void InspectorPageAgent::restore()
+void InspectorPageAgent::getResourceContent(ErrorString* errorString, const String& frameId, const String& url, const bool* const optionalBase64Encode, String* content)
 {
-    inspectedURLChanged(m_inspectedPage->mainFrame()->document()->url().string());
+    Frame* frame = frameForId(frameId);
+    if (!frame) {
+        *errorString = "No frame for given id found";
+        return;
+    }
+    if (optionalBase64Encode ? *optionalBase64Encode : false)
+        InspectorPageAgent::resourceContentBase64(errorString, frame, KURL(ParsedURLString, url), content);
+    else
+        InspectorPageAgent::resourceContent(errorString, frame, KURL(ParsedURLString, url), content);
 }
 
-void InspectorPageAgent::didCommitLoad(const String& url)
+void InspectorPageAgent::restore()
 {
-    inspectedURLChanged(url);
+    m_frontend->inspectedURLChanged(mainFrame()->document()->url().string());
 }
 
 void InspectorPageAgent::domContentEventFired()
 {
-     m_frontend->page()->domContentEventFired(currentTime());
+     m_frontend->domContentEventFired(currentTime());
 }
 
 void InspectorPageAgent::loadEventFired()
 {
-     m_frontend->page()->loadEventFired(currentTime());
+     m_frontend->loadEventFired(currentTime());
+}
+
+void InspectorPageAgent::frameNavigated(DocumentLoader* loader)
+{
+    m_frontend->frameNavigated(buildObjectForFrame(loader->frame()), loaderId(loader));
+    m_frontend->inspectedURLChanged(loader->url().string());
+}
+
+void InspectorPageAgent::frameDetached(Frame* frame)
+{
+    m_frontend->frameDetached(frameId(frame));
 }
 
 void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world)
@@ -233,7 +381,7 @@ void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWor
     if (world != mainThreadNormalWorld())
         return;
 
-    if (frame == m_inspectedPage->mainFrame())
+    if (frame == m_page->mainFrame())
         m_injectedScriptManager->discardInjectedScripts();
 
     if (m_scriptsToEvaluateOnLoad.size()) {
@@ -245,6 +393,84 @@ void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWor
     }
 }
 
+Frame* InspectorPageAgent::mainFrame()
+{
+    return m_page->mainFrame();
+}
+
+static String pointerAsId(void* pointer)
+{
+    unsigned long long address = reinterpret_cast<uintptr_t>(pointer);
+    // We want 0 to be "", so that JavaScript checks for if (frameId) worked.
+    return String::format("%.0llX", address);
+}
+
+Frame* InspectorPageAgent::frameForId(const String& frameId)
+{
+    Frame* mainFrame = m_page->mainFrame();
+    for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext(mainFrame)) {
+        if (pointerAsId(frame) == frameId)
+            return frame;
+    }
+    return 0;
+}
+
+String InspectorPageAgent::frameId(Frame* frame)
+{
+    return pointerAsId(frame);
+}
+
+String InspectorPageAgent::loaderId(DocumentLoader* loader)
+{
+    return pointerAsId(loader);
+}
+
+PassRefPtr<InspectorObject> InspectorPageAgent::buildObjectForFrame(Frame* frame)
+{
+    RefPtr<InspectorObject> frameObject = InspectorObject::create();
+    frameObject->setString("id", frameId(frame));
+    frameObject->setString("parentId", frameId(frame->tree()->parent()));
+    if (frame->ownerElement()) {
+        String name = frame->ownerElement()->getAttribute(HTMLNames::nameAttr);
+        if (name.isEmpty())
+            name = frame->ownerElement()->getAttribute(HTMLNames::idAttr);
+        frameObject->setString("name", name);
+    }
+    frameObject->setString("url", frame->document()->url().string());
+    frameObject->setString("loaderId", loaderId(frame->loader()->documentLoader()));
+
+    return frameObject;
+}
+
+PassRefPtr<InspectorObject> InspectorPageAgent::buildObjectForFrameTree(Frame* frame)
+{
+    RefPtr<InspectorObject> result = InspectorObject::create();
+    RefPtr<InspectorObject> frameObject = buildObjectForFrame(frame);
+    result->setObject("frame", frameObject);
+
+    RefPtr<InspectorArray> subresources = InspectorArray::create();
+    result->setArray("resources", subresources);
+    const CachedResourceLoader::DocumentResourceMap& allResources = frame->document()->cachedResourceLoader()->allCachedResources();
+    CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
+    for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
+        CachedResource* cachedResource = it->second.get();
+        RefPtr<InspectorObject> resourceObject = InspectorObject::create();
+        resourceObject->setString("url", cachedResource->url());
+        resourceObject->setString("type", cachedResourceTypeString(*cachedResource));
+        subresources->pushValue(resourceObject);
+    }
+
+    RefPtr<InspectorArray> childrenArray;
+    for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
+        if (!childrenArray) {
+            childrenArray = InspectorArray::create();
+            result->setArray("childFrames", childrenArray);
+        }
+        childrenArray->pushObject(buildObjectForFrameTree(child));
+    }
+    return result;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index b95cc18..689f3e5 100644 (file)
 
 #if ENABLE(INSPECTOR)
 
+#include "InspectorFrontend.h"
 #include "PlatformString.h"
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
 
+class CachedResource;
 class DOMWrapperWorld;
+class DocumentLoader;
 class Frame;
 class Frontend;
 class InjectedScriptManager;
 class InspectorArray;
-class InspectorFrontend;
+class InspectorObject;
 class InstrumentingAgents;
+class KURL;
 class Page;
 
 typedef String ErrorString;
@@ -53,8 +57,29 @@ typedef String ErrorString;
 class InspectorPageAgent {
     WTF_MAKE_NONCOPYABLE(InspectorPageAgent);
 public:
+
+    enum ResourceType {
+        DocumentResource,
+        StylesheetResource,
+        ImageResource,
+        FontResource,
+        ScriptResource,
+        XHRResource,
+        WebSocketResource,
+        OtherResource
+    };
+
     static PassOwnPtr<InspectorPageAgent> create(InstrumentingAgents*, Page*, InjectedScriptManager*);
 
+    static void resourceContent(ErrorString*, Frame*, const KURL&, String* result);
+    static void resourceContentBase64(ErrorString*, Frame*, const KURL&, String* result);
+
+    static PassRefPtr<SharedBuffer> resourceData(Frame*, const KURL&, String* textEncodingName);
+    static CachedResource* cachedResource(Frame*, const KURL&);
+    static String resourceTypeString(ResourceType);
+    static ResourceType cachedResourceType(const CachedResource&);
+    static String cachedResourceTypeString(const CachedResource&);
+
     // Page API for InspectorFrontend
     void addScriptToEvaluateOnLoad(ErrorString*, const String& source);
     void removeAllScriptsToEvaluateOnLoad(ErrorString*);
@@ -62,26 +87,38 @@ public:
     void open(ErrorString*, const String& url, const bool* const inNewWindow);
     void getCookies(ErrorString*, RefPtr<InspectorArray>* cookies, WTF::String* cookiesString);
     void deleteCookie(ErrorString*, const String& cookieName, const String& domain);
+    void getResourceTree(ErrorString*, RefPtr<InspectorObject>*);
+    void getResourceContent(ErrorString*, const String& frameId, const String& url, const bool* const base64Encode, String* content);
 
     // InspectorInstrumentation API
-    void inspectedURLChanged(const String& url);
     void didCommitLoad(const String& url);
     void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
     void domContentEventFired();
     void loadEventFired();
+    void frameNavigated(DocumentLoader*);
+    void frameDetached(Frame*);
 
+    // Inspector Controller API
     void setFrontend(InspectorFrontend*);
     void clearFrontend();
     void restore();
-    void applyUserAgentOverride(String* userAgent) const;
+
+    // Cross-agents API
+    Frame* mainFrame();
+    Frame* frameForId(const String& frameId);
+    String frameId(Frame*);
+    String loaderId(DocumentLoader*);
 
 private:
     InspectorPageAgent(InstrumentingAgents*, Page*, InjectedScriptManager*);
 
+    PassRefPtr<InspectorObject> buildObjectForFrame(Frame*);
+    PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame*);
+
     InstrumentingAgents* m_instrumentingAgents;
-    Page* m_inspectedPage;
+    Page* m_page;
     InjectedScriptManager* m_injectedScriptManager;
-    InspectorFrontend* m_frontend;
+    InspectorFrontend::Page* m_frontend;
     Vector<String> m_scriptsToEvaluateOnLoad;
 };
 
index 5bbd360..1a8b729 100644 (file)
 
 #if ENABLE(INSPECTOR)
 
-#include "Base64.h"
 #include "CachedResource.h"
 #include "CachedResourceLoader.h"
-#include "Document.h"
 #include "DocumentLoader.h"
 #include "EventsCollector.h"
 #include "Frame.h"
 #include "FrameLoader.h"
-#include "HTMLFrameOwnerElement.h"
-#include "HTMLNames.h"
 #include "HTTPHeaderMap.h"
 #include "InspectorFrontend.h"
 #include "InspectorFrontendChannel.h"
 #include "InspectorFrontendProxy.h"
+#include "InspectorPageAgent.h"
 #include "InspectorState.h"
 #include "InspectorValues.h"
 #include "InstrumentingAgents.h"
 #include "KURL.h"
-#include "MemoryCache.h"
-#include "Page.h"
 #include "ProgressTracker.h"
 #include "ResourceError.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
 #include "ScriptCallStack.h"
 #include "ScriptCallStackFactory.h"
-#include "SharedBuffer.h"
-#include "TextEncoding.h"
 #include "WebSocketHandshakeRequest.h"
 #include "WebSocketHandshakeResponse.h"
 
@@ -77,17 +70,6 @@ static const char resourceAgentEnabled[] = "resourceAgentEnabled";
 static const char extraRequestHeaders[] = "extraRequestHeaders";
 }
 
-namespace ResourceType {
-static const char document[] = "Document";
-static const char stylesheet[] = "Stylesheet";
-static const char image[] = "Image";
-static const char font[] = "Font";
-static const char script[] = "Script";
-static const char xhr[] = "XHR";
-static const char websocket[] = "WebSocket";
-static const char other[] = "Other";
-}
-
 void InspectorResourceAgent::setFrontend(InspectorFrontend* frontend)
 {
     m_frontend = frontend->network();
@@ -118,79 +100,6 @@ void InspectorResourceAgent::restore()
         enable();
 }
 
-void InspectorResourceAgent::resourceContent(ErrorString* errorString, Frame* frame, const KURL& url, String* result)
-{
-    if (!frame) {
-        *errorString = "No frame to get resource content for";
-        return;
-    }
-
-    String textEncodingName;
-    RefPtr<SharedBuffer> buffer = InspectorResourceAgent::resourceData(frame, url, &textEncodingName);
-
-    if (buffer) {
-        TextEncoding encoding(textEncodingName);
-        if (!encoding.isValid())
-            encoding = WindowsLatin1Encoding();
-        *result = encoding.decode(buffer->data(), buffer->size());
-        return;
-    }
-    *errorString = "No resource with given URL found"; 
-}
-
-void InspectorResourceAgent::resourceContentBase64(ErrorString* errorString, Frame* frame, const KURL& url, String* result)
-{
-    String textEncodingName;
-    RefPtr<SharedBuffer> data = InspectorResourceAgent::resourceData(frame, url, &textEncodingName);
-    if (!data) {
-        *result = String();
-        *errorString = "No resource with given URL found"; 
-        return;
-    }
-
-    *result = base64Encode(data->data(), data->size());
-}
-
-PassRefPtr<SharedBuffer> InspectorResourceAgent::resourceData(Frame* frame, const KURL& url, String* textEncodingName)
-{
-    FrameLoader* frameLoader = frame->loader();
-    DocumentLoader* loader = frameLoader->documentLoader();
-    if (equalIgnoringFragmentIdentifier(url, loader->url())) {
-        *textEncodingName = frame->document()->inputEncoding();
-        return frameLoader->documentLoader()->mainResourceData();
-    }
-
-    CachedResource* cachedResource = InspectorResourceAgent::cachedResource(frame, url);
-    if (!cachedResource)
-        return 0;
-
-    // Zero-sized resources don't have data at all -- so fake the empty buffer, insted of indicating error by returning 0.
-    if (!cachedResource->encodedSize())
-        return SharedBuffer::create();
-
-    if (cachedResource->isPurgeable()) {
-        // If the resource is purgeable then make it unpurgeable to get
-        // get its data. This might fail, in which case we return an
-        // empty String.
-        // FIXME: should we do something else in the case of a purged
-        // resource that informs the user why there is no data in the
-        // inspector?
-        if (!cachedResource->makePurgeable(false))
-            return 0;
-    }
-
-    *textEncodingName = cachedResource->encoding();
-    return cachedResource->data();
-}
-
-CachedResource* InspectorResourceAgent::cachedResource(Frame* frame, const KURL& url)
-{
-    CachedResource* cachedResource = frame->document()->cachedResourceLoader()->cachedResource(url);
-    if (!cachedResource)
-        cachedResource = memoryCache()->resourceForURL(url);
-    return cachedResource;
-}
-
 static PassRefPtr<InspectorObject> buildObjectForHeaders(const HTTPHeaderMap& headers)
 {
     RefPtr<InspectorObject> headersObject = InspectorObject::create();
@@ -259,39 +168,11 @@ static PassRefPtr<InspectorObject> buildObjectForResourceResponse(const Resource
     return responseObject;
 }
 
-static String pointerAsId(void* pointer)
-{
-    unsigned long long address = reinterpret_cast<uintptr_t>(pointer);
-    // We want 0 to be "", so that JavaScript checks for if (frameId) worked.
-    return String::format("%.0llX", address);
-}
-
-static String cachedResourceTypeString(const CachedResource& cachedResource)
-{
-    switch (cachedResource.type()) {
-    case CachedResource::ImageResource:
-        return ResourceType::image;
-    case CachedResource::FontResource:
-        return ResourceType::font;
-    case CachedResource::CSSStyleSheet:
-        // Fall through.
-#if ENABLE(XSLT)
-    case CachedResource::XSLStyleSheet:
-#endif
-        return ResourceType::stylesheet;
-    case CachedResource::Script:
-        return ResourceType::script;
-    default:
-        break;
-    }
-    return ResourceType::other;
-}
-
 static PassRefPtr<InspectorObject> buildObjectForCachedResource(const CachedResource& cachedResource)
 {
     RefPtr<InspectorObject> resourceObject = InspectorObject::create();
     resourceObject->setString("url", cachedResource.url());
-    resourceObject->setString("type", cachedResourceTypeString(cachedResource));
+    resourceObject->setString("type", InspectorPageAgent::cachedResourceTypeString(cachedResource));
     resourceObject->setNumber("bodySize", cachedResource.encodedSize());
     RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(cachedResource.response());
     if (resourceResponse)
@@ -330,7 +211,7 @@ void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentL
         callStackValue = callStack->buildInspectorArray();
     else
         callStackValue = InspectorArray::create();
-    m_frontend->requestWillBeSent(static_cast<int>(identifier), pointerAsId(loader->frame()), pointerAsId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), callStackValue, buildObjectForResourceResponse(redirectResponse));
+    m_frontend->requestWillBeSent(static_cast<int>(identifier), m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), callStackValue, buildObjectForResourceResponse(redirectResponse));
 }
 
 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier)
@@ -341,24 +222,24 @@ void InspectorResourceAgent::markResourceAsCached(unsigned long identifier)
 void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
 {
     RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(response);
-    String type = "Other";
+    InspectorPageAgent::ResourceType type = InspectorPageAgent::OtherResource;
     long cachedResourceSize = 0;
 
     if (loader) {
-        CachedResource* cachedResource = InspectorResourceAgent::cachedResource(loader->frame(), response.url());
+        CachedResource* cachedResource = InspectorPageAgent::cachedResource(loader->frame(), response.url());
         if (cachedResource) {
-            type = cachedResourceTypeString(*cachedResource);
+            type = InspectorPageAgent::cachedResourceType(*cachedResource);
             cachedResourceSize = cachedResource->encodedSize();
             // Use mime type from cached resource in case the one in response is empty.
             if (response.mimeType().isEmpty())
                 resourceResponse->setString("mimeType", cachedResource->response().mimeType());
         }
         if (equalIgnoringFragmentIdentifier(response.url(), loader->frameLoader()->iconURL()))
-            type = ResourceType::image;
-        else if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && type == "Other")
-            type = ResourceType::document;
+            type = InspectorPageAgent::ImageResource;
+        else if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && type == InspectorPageAgent::OtherResource)
+            type = InspectorPageAgent::DocumentResource;
     }
-    m_frontend->responseReceived(static_cast<int>(identifier), currentTime(), type, resourceResponse);
+    m_frontend->responseReceived(static_cast<int>(identifier), currentTime(), InspectorPageAgent::resourceTypeString(type), resourceResponse);
     // If we revalidated the resource and got Not modified, send content length following didReceiveResponse
     // as there will be no calls to didReceiveContentLength from the network stack.
     if (cachedResourceSize && response.httpStatusCode() == 304)
@@ -385,83 +266,17 @@ void InspectorResourceAgent::didFailLoading(unsigned long identifier, const Reso
 
 void InspectorResourceAgent::didLoadResourceFromMemoryCache(DocumentLoader* loader, const CachedResource* resource)
 {
-    m_frontend->resourceLoadedFromMemoryCache(pointerAsId(loader->frame()), pointerAsId(loader), loader->url().string(), currentTime(), buildObjectForCachedResource(*resource));
+    m_frontend->resourceLoadedFromMemoryCache(m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), currentTime(), buildObjectForCachedResource(*resource));
 }
 
 void InspectorResourceAgent::setInitialScriptContent(unsigned long identifier, const String& sourceString)
 {
-    m_frontend->initialContentSet(static_cast<int>(identifier), sourceString, ResourceType::script);
+    m_frontend->initialContentSet(static_cast<int>(identifier), sourceString, InspectorPageAgent::resourceTypeString(InspectorPageAgent::ScriptResource));
 }
 
 void InspectorResourceAgent::setInitialXHRContent(unsigned long identifier, const String& sourceString)
 {
-    m_frontend->initialContentSet(static_cast<int>(identifier), sourceString, ResourceType::xhr);
-}
-
-void InspectorResourceAgent::domContentEventFired()
-{
-    m_frontend->domContentEventFired(currentTime());
-}
-
-void InspectorResourceAgent::loadEventFired()
-{
-    m_frontend->loadEventFired(currentTime());
-}
-
-static PassRefPtr<InspectorObject> buildObjectForFrame(Frame* frame)
-{
-    RefPtr<InspectorObject> frameObject = InspectorObject::create();
-    frameObject->setString("id", pointerAsId(frame));
-    frameObject->setString("parentId", pointerAsId(frame->tree()->parent()));
-    if (frame->ownerElement()) {
-        String name = frame->ownerElement()->getAttribute(HTMLNames::nameAttr);
-        if (name.isEmpty())
-            name = frame->ownerElement()->getAttribute(HTMLNames::idAttr);
-        frameObject->setString("name", name);
-    }
-    frameObject->setString("url", frame->document()->url().string());
-    frameObject->setString("loaderId", pointerAsId(frame->loader()->documentLoader()));
-
-    return frameObject;
-}
-
-static PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame* frame)
-{
-    RefPtr<InspectorObject> result = InspectorObject::create();
-    RefPtr<InspectorObject> frameObject = buildObjectForFrame(frame);
-    result->setObject("frame", frameObject);
-
-    RefPtr<InspectorArray> subresources = InspectorArray::create();
-    result->setArray("resources", subresources);
-    const CachedResourceLoader::DocumentResourceMap& allResources = frame->document()->cachedResourceLoader()->allCachedResources();
-    CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
-    for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
-        CachedResource* cachedResource = it->second.get();
-        RefPtr<InspectorObject> resourceObject = InspectorObject::create();
-        resourceObject->setString("url", cachedResource->url());
-        resourceObject->setString("type", cachedResourceTypeString(*cachedResource));
-        subresources->pushValue(resourceObject);
-    }
-
-    RefPtr<InspectorArray> childrenArray;
-    for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
-        if (!childrenArray) {
-            childrenArray = InspectorArray::create();
-            result->setArray("childFrames", childrenArray);
-        }
-        childrenArray->pushObject(buildObjectForFrameTree(child));
-    }
-    return result;
-}
-
-void InspectorResourceAgent::didCommitLoad(DocumentLoader* loader)
-{
-    m_frontend->frameNavigated(buildObjectForFrame(loader->frame()), pointerAsId(loader));
-}
-
-void InspectorResourceAgent::frameDetachedFromParent(Frame* frame)
-{
-    m_frontend->frameDetached(pointerAsId(frame));
+    m_frontend->initialContentSet(static_cast<int>(identifier), sourceString, InspectorPageAgent::resourceTypeString(InspectorPageAgent::XHRResource));
 }
 
 void InspectorResourceAgent::applyUserAgentOverride(String* userAgent)
@@ -516,16 +331,6 @@ void InspectorResourceAgent::didCloseWebSocket(unsigned long identifier)
 }
 #endif // ENABLE(WEB_SOCKETS)
 
-Frame* InspectorResourceAgent::frameForId(const String& frameId)
-{
-    Frame* mainFrame = m_page->mainFrame();
-    for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext(mainFrame)) {
-        if (pointerAsId(frame) == frameId)
-            return frame;
-    }
-    return 0;
-}
-
 bool InspectorResourceAgent::backgroundEventsCollectionEnabled()
 {
     // FIXME (https://bugs.webkit.org/show_bug.cgi?id=58652)
@@ -553,24 +358,6 @@ void InspectorResourceAgent::disable(ErrorString*)
     m_instrumentingAgents->setInspectorResourceAgent(0);
 }
 
-void InspectorResourceAgent::getCachedResources(ErrorString*, RefPtr<InspectorObject>* object)
-{
-    *object = buildObjectForFrameTree(m_page->mainFrame());
-}
-
-void InspectorResourceAgent::getResourceContent(ErrorString* errorString, const String& frameId, const String& url, const bool* const optionalBase64Encode, String* content)
-{
-    Frame* frame = frameForId(frameId);
-    if (!frame) {
-        *errorString = "No frame for given id found";
-        return;
-    }
-    if (optionalBase64Encode ? *optionalBase64Encode : false)
-        InspectorResourceAgent::resourceContentBase64(errorString, frame, KURL(ParsedURLString, url), content);
-    else
-        InspectorResourceAgent::resourceContent(errorString, frame, KURL(ParsedURLString, url), content);
-}
-
 void InspectorResourceAgent::setUserAgentOverride(ErrorString*, const String& userAgent)
 {
     m_userAgentOverride = userAgent;
@@ -581,9 +368,9 @@ void InspectorResourceAgent::setExtraHeaders(ErrorString*, PassRefPtr<InspectorO
     m_state->setObject(ResourceAgentState::extraRequestHeaders, headers);
 }
 
-InspectorResourceAgent::InspectorResourceAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* state)
+InspectorResourceAgent::InspectorResourceAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorState* state)
     : m_instrumentingAgents(instrumentingAgents)
-    , m_page(page)
+    , m_pageAgent(pageAgent)
     , m_state(state)
 {
     if (backgroundEventsCollectionEnabled()) {
index 7e2f07c..d60d21f 100644 (file)
@@ -54,6 +54,7 @@ class InspectorArray;
 class InspectorFrontend;
 class InspectorFrontendProxy;
 class InspectorObject;
+class InspectorPageAgent;
 class InspectorState;
 class InstrumentingAgents;
 class KURL;
@@ -73,9 +74,9 @@ typedef String ErrorString;
 
 class InspectorResourceAgent : public RefCounted<InspectorResourceAgent> {
 public:
-    static PassRefPtr<InspectorResourceAgent> create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* state)
+    static PassRefPtr<InspectorResourceAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorState* state)
     {
-        return adoptRef(new InspectorResourceAgent(instrumentingAgents, page, state));
+        return adoptRef(new InspectorResourceAgent(instrumentingAgents, pageAgent, state));
     }
 
     void setFrontend(InspectorFrontend*);
@@ -84,12 +85,6 @@ public:
 
     static PassRefPtr<InspectorResourceAgent> restore(Page*, InspectorState*, InspectorFrontend*);
 
-    static void resourceContent(ErrorString*, Frame*, const KURL&, String* result);
-    static void resourceContentBase64(ErrorString*, Frame*, const KURL&, String* result);
-
-    static PassRefPtr<SharedBuffer> resourceData(Frame*, const KURL&, String* textEncodingName);
-    static CachedResource* cachedResource(Frame*, const KURL&);
-
     ~InspectorResourceAgent();
 
     void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
@@ -101,10 +96,6 @@ public:
     void didLoadResourceFromMemoryCache(DocumentLoader*, const CachedResource*);
     void setInitialScriptContent(unsigned long identifier, const String& sourceString);
     void setInitialXHRContent(unsigned long identifier, const String& sourceString);
-    void domContentEventFired();
-    void loadEventFired();
-    void didCommitLoad(DocumentLoader*);
-    void frameDetachedFromParent(Frame*);
     void applyUserAgentOverride(String* userAgent);
 
 #if ENABLE(WEB_SOCKETS)
@@ -114,25 +105,22 @@ public:
     void didCloseWebSocket(unsigned long identifier);
 #endif
 
-    Frame* frameForId(const String& frameId);
     bool backgroundEventsCollectionEnabled();
 
     // Called from frontend 
     void enable(ErrorString*);
     void disable(ErrorString*);
-    void getCachedResources(ErrorString*, RefPtr<InspectorObject>*);
-    void getResourceContent(ErrorString*, const String& frameId, const String& url, const bool* const base64Encode, String* content);
     void setUserAgentOverride(ErrorString*, const String& userAgent);
     void setExtraHeaders(ErrorString*, PassRefPtr<InspectorObject>);
 
 
 private:
-    InspectorResourceAgent(InstrumentingAgents*, Page*, InspectorState*);
+    InspectorResourceAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*);
 
     void enable();
 
     InstrumentingAgents* m_instrumentingAgents;
-    Page* m_page;
+    InspectorPageAgent* m_pageAgent;
     InspectorState* m_state;
     OwnPtr<EventsCollector> m_eventsCollector;
     InspectorFrontend::Network* m_frontend;
index 2edb8a1..7c43e1f 100644 (file)
@@ -41,7 +41,7 @@
 #include "HTMLHeadElement.h"
 #include "HTMLParserIdioms.h"
 #include "InspectorCSSAgent.h"
-#include "InspectorResourceAgent.h"
+#include "InspectorPageAgent.h"
 #include "InspectorValues.h"
 #include "Node.h"
 #include "StyleSheetList.h"
@@ -1072,7 +1072,7 @@ bool InspectorStyleSheet::resourceStyleSheetText(String* result) const
         return false;
 
     String error;
-    InspectorResourceAgent::resourceContent(&error, ownerDocument()->frame(), m_pageStyleSheet->finalURL(), result);
+    InspectorPageAgent::resourceContent(&error, ownerDocument()->frame(), m_pageStyleSheet->finalURL(), result);
     return error.isEmpty();
 }
 
index 399f110..e657134 100644 (file)
@@ -38,9 +38,7 @@ WebInspector.NetworkManager = function()
 WebInspector.NetworkManager.EventTypes = {
     ResourceStarted: "ResourceStarted",
     ResourceUpdated: "ResourceUpdated",
-    ResourceFinished: "ResourceFinished",
-    FrameCommittedLoad: "FrameCommittedLoad",
-    FrameDetached: "FrameDetached"
+    ResourceFinished: "ResourceFinished"
 }
 
 WebInspector.NetworkManager.prototype = {
@@ -55,7 +53,7 @@ WebInspector.NetworkManager.prototype = {
         {
             callback(!error ? content : null);
         }
-        NetworkAgent.getResourceContent(resource.frameId, resource.url, base64Encode, callbackWrapper);
+        PageAgent.getResourceContent(resource.frameId, resource.url, base64Encode, callbackWrapper);
     },
 
     inflightResourceForURL: function(url)
@@ -153,18 +151,6 @@ WebInspector.NetworkDispatcher.prototype = {
         this._updateResource(resource);
     },
 
-    domContentEventFired: function(time)
-    {
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.mainResourceDOMContentTime = time;
-    },
-
-    loadEventFired: function(time)
-    {
-        if (WebInspector.panels.network)
-            WebInspector.panels.network.mainResourceLoadTime = time;
-    },
-
     dataReceived: function(identifier, time, dataLength, encodedDataLength)
     {
         var resource = this._inflightResourcesById[identifier];
@@ -211,11 +197,6 @@ WebInspector.NetworkDispatcher.prototype = {
         this._finishResource(resource, time);
     },
 
-    frameDetached: function(frameId)
-    {
-        this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.FrameDetached, frameId);
-    },
-
     initialContentSet: function(identifier, sourceString, type)
     {
         var resource = WebInspector.networkResourceById(identifier);
@@ -227,11 +208,6 @@ WebInspector.NetworkDispatcher.prototype = {
         this._updateResource(resource);
     },
 
-    frameNavigated: function(frame, loaderId)
-    {
-        this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.FrameCommittedLoad, { frame: frame, loaderId: loaderId });
-    },
-
     webSocketCreated: function(identifier, requestURL)
     {
         var resource = this._createResource(identifier, null, null, requestURL);
index 2840721..0d8b881 100644 (file)
@@ -83,7 +83,6 @@ WebInspector.NetworkPanel = function()
     WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this);
     WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._onResourceUpdated, this);
     WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceUpdated, this);
-    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.FrameCommittedLoad, this._onFrameCommitLoad, this);
 
     this.registerShortcuts();
 }
@@ -807,9 +806,9 @@ WebInspector.NetworkPanel.prototype = {
         this._reset();
     },
 
-    _onFrameCommitLoad: function(event)
+    frameNavigated: function(frame, loaderId)
     {
-        if (event.data.frame.parentId)
+        if (frame.parentId)
             return;
 
         // Main frame committed load.
@@ -817,7 +816,6 @@ WebInspector.NetworkPanel.prototype = {
             return;
 
         // Preserve provisional load resources.
-        var loaderId = event.data.loaderId;
         var resourcesToPreserve = [];
         for (var i = 0; i < this._resources.length; ++i) {
             var resource = this._resources[i];
index c0dd691..09cd2dc 100644 (file)
@@ -34,8 +34,6 @@ WebInspector.ResourceTreeModel = function(networkManager)
     WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this);
     WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._onResourceUpdated, this);
     WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceUpdated, this);
-    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.FrameDetached, this._onFrameDetachedFromParent, this);
-    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.FrameCommittedLoad, this._onCommitLoad, this);
 
     this.frontendReused();
 }
@@ -54,7 +52,7 @@ WebInspector.ResourceTreeModel.prototype = {
         this._resourcesByURL = {};
         this._resourcesByFrameId = {};
         this._subframes = {};
-        NetworkAgent.getCachedResources(this._processCachedResources.bind(this));
+        PageAgent.getResourceTree(this._processCachedResources.bind(this));
     },
 
     _processCachedResources: function(error, mainFramePayload)
@@ -101,13 +99,11 @@ WebInspector.ResourceTreeModel.prototype = {
         return result;
     },
 
-    _onCommitLoad: function(event)
+    frameNavigated: function(frame, loaderId)
     {
         if (!this._cachedResourcesProcessed)
             return;
 
-        var frame = event.data.frame;
-        var loaderId = event.data.loaderId;
         var isMainFrame = !frame.parentId;
 
         // frame.parentId === 0 is when main frame navigation happens.
@@ -128,12 +124,11 @@ WebInspector.ResourceTreeModel.prototype = {
             WebInspector.Resource.clearRevisionHistory();
     },
 
-    _onFrameDetachedFromParent: function(event)
+    frameDetached: function(frameId)
     {
         if (!this._cachedResourcesProcessed)
             return;
 
-        var frameId = event.data;
         this._clearChildFramesAndResources(frameId, 0);
         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, frameId);
     },
index 701f4a8..522b5f4 100644 (file)
@@ -983,24 +983,29 @@ WebInspector.startUserInitiatedDebugging = function()
 WebInspector.domContentEventFired = function(time)
 {
     this.panels.audits.mainResourceDOMContentTime = time;
+    this.panels.network.mainResourceDOMContentTime = time;
+
     this.mainResourceDOMContentTime = time;
 }
 
 WebInspector.loadEventFired = function(time)
 {
     this.panels.audits.mainResourceLoadTime = time;
+    this.panels.network.mainResourceLoadTime = time;
     this.panels.resources.loadEventFired();
+
     this.mainResourceLoadTime = time;
 }
 
-WebInspector.searchingForNodeWasEnabled = function()
+// FIXME: move these into the dedicated dispatcher.
+WebInspector.frameNavigated = function(frame, loaderId)
 {
-    this.panels.elements.searchingForNodeWasEnabled();
+    this.resourceTreeModel.frameNavigated(frame, loaderId);
+    this.panels.network.frameNavigated(frame, loaderId);
 }
-
-WebInspector.searchingForNodeWasDisabled = function()
+WebInspector.frameDetached = function(frameId)
 {
-    this.panels.elements.searchingForNodeWasDisabled();
+    this.resourceTreeModel.frameDetached(loaderId);
 }
 
 WebInspector.reset = function()