2011-03-27 Pavel Feldman <pfeldman@chromium.org>
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Mar 2011 12:18:02 +0000 (12:18 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Mar 2011 12:18:02 +0000 (12:18 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: refactor ResourceTreeModel to remove poor dependencies.
        https://bugs.webkit.org/show_bug.cgi?id=57186

        * http/tests/inspector/console-resource-errors-expected.txt:
        * http/tests/inspector/console-resource-errors.html:
        * http/tests/inspector/resources/console-resource-errors-iframe.html: Added.
        * inspector/report-protocol-errors.html:
        * inspector/storage-panel-dom-storage.html:
2011-03-27  Pavel Feldman  <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: refactor ResourceTreeModel to remove poor dependencies.
        https://bugs.webkit.org/show_bug.cgi?id=57186

        - ResourceTreeModel is now event target (Object)
        - There is no ResourceTreeModel -> UI dependencies
        - NetworkManager -> ResourceTreeModel dependencies has been removed
        - NetworkManager is no longer dealing with the resources tree, it is only responsible for network events
        - ResourceTreeModel requests tree structure from the backend separately
        - Cached resources tree payload is now limited to url and type (no headers involved)
        - Resources tree is being rendered lazily upon request from the panel.

        * inspector/Inspector.json:
        * inspector/InspectorResourceAgent.cpp:
        (WebCore::InspectorResourceAgent::resourceContent):
        (WebCore::InspectorResourceAgent::resourceContentBase64):
        (WebCore::buildObjectForFrameTree):
        (WebCore::InspectorResourceAgent::enable):
        (WebCore::InspectorResourceAgent::getCachedResources):
        (WebCore::InspectorResourceAgent::getResourceContent):
        * inspector/InspectorResourceAgent.h:
        * inspector/InspectorStyleSheet.cpp:
        (WebCore::InspectorStyleSheet::resourceStyleSheetText):
        * inspector/front-end/InspectorFrontendHostStub.js:
        (.WebInspector.InspectorFrontendHostStub.prototype.sendMessageToBackend):
        (.WebInspector.InspectorFrontendHostStub.prototype.loadSessionSetting):
        * inspector/front-end/NetworkManager.js:
        (WebInspector.NetworkManager):
        (WebInspector.NetworkManager.prototype.frontendReused):
        (WebInspector.NetworkManager.prototype.requestContent):
        (WebInspector.NetworkDispatcher):
        (WebInspector.NetworkDispatcher.prototype.didReceiveResponse):
        (WebInspector.NetworkDispatcher.prototype.didLoadResourceFromMemoryCache):
        (WebInspector.NetworkDispatcher.prototype.frameDetachedFromParent):
        (WebInspector.NetworkDispatcher.prototype.didCommitLoadForFrame):
        * inspector/front-end/NetworkPanel.js:
        (WebInspector.NetworkPanel):
        (WebInspector.NetworkPanel.prototype._updateSummaryBar):
        (WebInspector.NetworkPanel.prototype._onFrameCommitLoad):
        * inspector/front-end/ResourceTreeModel.js:
        (WebInspector.ResourceTreeModel):
        (WebInspector.ResourceTreeModel.prototype.frontendReused):
        (WebInspector.ResourceTreeModel.prototype._processCachedResources):
        (WebInspector.ResourceTreeModel.prototype._addOrUpdateFrame):
        (WebInspector.ResourceTreeModel.prototype.frames):
        (WebInspector.ResourceTreeModel.prototype.subframes):
        (WebInspector.ResourceTreeModel.prototype.resources):
        (WebInspector.ResourceTreeModel.prototype._onCommitLoad):
        (WebInspector.ResourceTreeModel.prototype._onFrameDetachedFromParent):
        (WebInspector.ResourceTreeModel.prototype._onResourceUpdated):
        (WebInspector.ResourceTreeModel.prototype._addResourceToFrame):
        (WebInspector.ResourceTreeModel.prototype.resourceForURL):
        (WebInspector.ResourceTreeModel.prototype._bindResourceURL):
        (WebInspector.ResourceTreeModel.prototype._clearChildFramesAndResources):
        (WebInspector.ResourceTreeModel.prototype._clearResources):
        (WebInspector.ResourceTreeModel.prototype._callForFrameResources):
        (WebInspector.ResourceTreeModel.prototype._unbindResourceURL):
        (WebInspector.ResourceTreeModel.prototype._addFramesRecursively):
        (WebInspector.ResourceTreeModel.prototype._createResource):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.ResourcesPanel):
        (WebInspector.ResourcesPanel.prototype.show):
        (WebInspector.ResourcesPanel.prototype._populateResourceTree.populateFrame):
        (WebInspector.ResourcesPanel.prototype._populateResourceTree):
        (WebInspector.ResourcesPanel.prototype._frameAdded):
        (WebInspector.ResourcesPanel.prototype._frameDetached):
        (WebInspector.ResourcesPanel.prototype._resourceAdded):
        (WebInspector.ResourcesPanel.prototype._frameNavigated):
        (WebInspector.FrameTreeElement.prototype.setTitles):
        * inspector/front-end/inspector.js:
        (WebInspector.frontendReused):

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/console-resource-errors-expected.txt
LayoutTests/http/tests/inspector/console-resource-errors.html
LayoutTests/http/tests/inspector/resources/console-resource-errors-iframe.html [new file with mode: 0644]
LayoutTests/inspector/report-protocol-errors.html
LayoutTests/inspector/storage-panel-dom-storage.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorResourceAgent.cpp
Source/WebCore/inspector/InspectorResourceAgent.h
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js
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/ResourcesPanel.js
Source/WebCore/inspector/front-end/inspector.js

index 8a885b8..4f49d44 100644 (file)
@@ -1,3 +1,16 @@
+2011-03-27  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: refactor ResourceTreeModel to remove poor dependencies.
+        https://bugs.webkit.org/show_bug.cgi?id=57186
+
+        * http/tests/inspector/console-resource-errors-expected.txt:
+        * http/tests/inspector/console-resource-errors.html:
+        * http/tests/inspector/resources/console-resource-errors-iframe.html: Added.
+        * inspector/report-protocol-errors.html:
+        * inspector/storage-panel-dom-storage.html:
+
 2011-03-27  Ryosuke Niwa  <rniwa@webkit.org>
 
         Reviewed by Eric Seidel.
index 12ddf8d..36c56d9 100644 (file)
@@ -1,7 +1,6 @@
- Tests that errors to load a resource cause error messages to be logged to console.
+Tests that errors to load a resource cause error messages to be logged to console.
+
 
- download
-Page reloaded.
 missing.cssGET http://127.0.0.1:8000/inspector/missing.css 404 (Not Found) console-message console-error-level
 non-existent-iframe.htmlGET http://127.0.0.1:8000/inspector/non-existent-iframe.html 404 (Not Found) console-message console-error-level
 non-existent-script.jsGET http://127.0.0.1:8000/inspector/non-existent-script.js 404 (Not Found) console-message console-error-level
index 2acec1c..71795ac 100644 (file)
@@ -3,41 +3,43 @@
 <script src="console-test.js"></script>
 <script src="inspector-test.js"></script>
 
-<link rel="stylesheet" type="text/css" href="missing.css">
-
 <script>
-var xhr = new XMLHttpRequest();
-xhr.open("GET","non-existent-xhr", false);
-xhr.send(null);
 
-function performDownload()
+function performActions()
+{
+    loadXHR();
+    loadIframe();
+}
+
+function loadXHR()
+{
+    var xhr = new XMLHttpRequest();
+    xhr.open("GET","non-existent-xhr", false);
+    xhr.send(null);
+}
+
+function loadIframe()
 {
-    var a = document.body.getElementsByTagName("a")[0];
-    var event = document.createEvent("UIEvents");
-    event.initUIEvent("click", true, true, window, 1);
-    a.dispatchEvent(event);
+    var iframe = document.createElement("iframe");
+    iframe.src = "resources/console-resource-errors-iframe.html";
+    document.body.appendChild(iframe);
 }
 
 function test()
 {
-    function onResource(event)
+    InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "addMessage", addMessage, true);
+
+    var messageCount = 0;
+    function addMessage(message)
     {
-        var resource = event.data;
-        if (/\/empty\.zip$/.test(resource.url)) {
-            InspectorTest.expandConsoleMessages();
-            InspectorTest.dumpConsoleMessagesWithClasses(true);
-            InspectorTest.completeTest();
+       if (message.toString().indexOf("non-existent-iframe") !== -1) {
+           InspectorTest.expandConsoleMessages();
+           InspectorTest.dumpConsoleMessagesWithClasses(true);
+           InspectorTest.completeTest();
         }
     }
-    function onMainResourceCommitLoad()
-    {
-        WebInspector.console.clearMessages();
-        WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, onResource, this);
-    }
-    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, onMainResourceCommitLoad, this);
-    InspectorTest.reloadPage(function() {
-        InspectorTest.evaluateInPageWithTimeout("performDownload();");
-    });
+
+    InspectorTest.evaluateInPage("performActions()");
 }
 
 </script>
@@ -45,14 +47,7 @@ function test()
 
 <body onload="runTest()">
 <p>
-<script src="non-existent-script.js"></script>
-
-<iframe src="non-existent-iframe.html"></iframe>
-
 Tests that errors to load a resource cause error messages to be logged to console.
 </p>
-
-<iframe name="frame"></iframe>
-<a href="resources/empty.zip" target="frame">download</a>
 </body>
-</html>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/inspector/resources/console-resource-errors-iframe.html b/LayoutTests/http/tests/inspector/resources/console-resource-errors-iframe.html
new file mode 100644 (file)
index 0000000..473172b
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="../missing.css">
+<script src="../non-existent-script.js"></script>
+</head>
+
+<body>
+<iframe src="../non-existent-iframe.html"></iframe>
+</body>
+</html>
index eedbed4..69e3af3 100644 (file)
@@ -12,10 +12,10 @@ function test()
         '{"domain":"Network","command":"resourceContent"}',
         '{"id":"not a number","domain":"Network","command":"resourceContent"}',
         '{"id":1,"domain":"DOM","command":"test"}',
-        '{"id":2,"domain":"Network","command":"resourceContent"}',
-        '{"id":3,"domain":"Network","command":"resourceContent","arguments":[]}',
-        '{"id":4,"domain":"Network","command":"resourceContent","arguments":{}}',
-        '{"id":5,"domain":"Network","command":"resourceContent","arguments":{"identifier":"not a number"}}',
+        '{"id":2,"domain":"Network","command":"getResourceContent"}',
+        '{"id":3,"domain":"Network","command":"getResourceContent","arguments":[]}',
+        '{"id":4,"domain":"Network","command":"getResourceContent","arguments":{}}',
+        '{"id":5,"domain":"Network","command":"getResourceContent","arguments":{"identifier":"not a number"}}',
     ];
     var numberOfReports = 0;
 
index 8a74f41..6ff0385 100644 (file)
@@ -1,7 +1,6 @@
 <html>
 <head>
 <script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/debugger-test.js"></script>
 <script>
 
 function populateDOMStorage()
index f62eb51..e4f9228 100644 (file)
@@ -1,3 +1,78 @@
+2011-03-27  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: refactor ResourceTreeModel to remove poor dependencies.
+        https://bugs.webkit.org/show_bug.cgi?id=57186
+
+        - ResourceTreeModel is now event target (Object)
+        - There is no ResourceTreeModel -> UI dependencies
+        - NetworkManager -> ResourceTreeModel dependencies has been removed
+        - NetworkManager is no longer dealing with the resources tree, it is only responsible for network events
+        - ResourceTreeModel requests tree structure from the backend separately
+        - Cached resources tree payload is now limited to url and type (no headers involved)
+        - Resources tree is being rendered lazily upon request from the panel.
+
+        * inspector/Inspector.json:
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::resourceContent):
+        (WebCore::InspectorResourceAgent::resourceContentBase64):
+        (WebCore::buildObjectForFrameTree):
+        (WebCore::InspectorResourceAgent::enable):
+        (WebCore::InspectorResourceAgent::getCachedResources):
+        (WebCore::InspectorResourceAgent::getResourceContent):
+        * inspector/InspectorResourceAgent.h:
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyleSheet::resourceStyleSheetText):
+        * inspector/front-end/InspectorFrontendHostStub.js:
+        (.WebInspector.InspectorFrontendHostStub.prototype.sendMessageToBackend):
+        (.WebInspector.InspectorFrontendHostStub.prototype.loadSessionSetting):
+        * inspector/front-end/NetworkManager.js:
+        (WebInspector.NetworkManager):
+        (WebInspector.NetworkManager.prototype.frontendReused):
+        (WebInspector.NetworkManager.prototype.requestContent):
+        (WebInspector.NetworkDispatcher):
+        (WebInspector.NetworkDispatcher.prototype.didReceiveResponse):
+        (WebInspector.NetworkDispatcher.prototype.didLoadResourceFromMemoryCache):
+        (WebInspector.NetworkDispatcher.prototype.frameDetachedFromParent):
+        (WebInspector.NetworkDispatcher.prototype.didCommitLoadForFrame):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel):
+        (WebInspector.NetworkPanel.prototype._updateSummaryBar):
+        (WebInspector.NetworkPanel.prototype._onFrameCommitLoad):
+        * inspector/front-end/ResourceTreeModel.js:
+        (WebInspector.ResourceTreeModel):
+        (WebInspector.ResourceTreeModel.prototype.frontendReused):
+        (WebInspector.ResourceTreeModel.prototype._processCachedResources):
+        (WebInspector.ResourceTreeModel.prototype._addOrUpdateFrame):
+        (WebInspector.ResourceTreeModel.prototype.frames):
+        (WebInspector.ResourceTreeModel.prototype.subframes):
+        (WebInspector.ResourceTreeModel.prototype.resources):
+        (WebInspector.ResourceTreeModel.prototype._onCommitLoad):
+        (WebInspector.ResourceTreeModel.prototype._onFrameDetachedFromParent):
+        (WebInspector.ResourceTreeModel.prototype._onResourceUpdated):
+        (WebInspector.ResourceTreeModel.prototype._addResourceToFrame):
+        (WebInspector.ResourceTreeModel.prototype.resourceForURL):
+        (WebInspector.ResourceTreeModel.prototype._bindResourceURL):
+        (WebInspector.ResourceTreeModel.prototype._clearChildFramesAndResources):
+        (WebInspector.ResourceTreeModel.prototype._clearResources):
+        (WebInspector.ResourceTreeModel.prototype._callForFrameResources):
+        (WebInspector.ResourceTreeModel.prototype._unbindResourceURL):
+        (WebInspector.ResourceTreeModel.prototype._addFramesRecursively):
+        (WebInspector.ResourceTreeModel.prototype._createResource):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel):
+        (WebInspector.ResourcesPanel.prototype.show):
+        (WebInspector.ResourcesPanel.prototype._populateResourceTree.populateFrame):
+        (WebInspector.ResourcesPanel.prototype._populateResourceTree):
+        (WebInspector.ResourcesPanel.prototype._frameAdded):
+        (WebInspector.ResourcesPanel.prototype._frameDetached):
+        (WebInspector.ResourcesPanel.prototype._resourceAdded):
+        (WebInspector.ResourcesPanel.prototype._frameNavigated):
+        (WebInspector.FrameTreeElement.prototype.setTitles):
+        * inspector/front-end/inspector.js:
+        (WebInspector.frontendReused):
+
 2011-03-27  Ryosuke Niwa  <rniwa@webkit.org>
 
         Reviewed by Eric Seidel.
index a66331a..b51b7be 100644 (file)
     },
     {
         "domain": "Network",
+        "description": "Network domain allows tracking network activities of the page. It exposes information about HTTP and WebSocket requests and responses, their headers, bodies, timing, etc. It also allows getting the tree of the Frames on the page along with information about their resources.",
         "types": [
             {
                 "id": "ResourceTiming",
                 "type": "object",
+                "description": "Timing information for the request.",
                 "properties": {
-                    "requestTime": { "type": "number" },
-                    "proxyStart": { "type": "number" },
-                    "proxyEnd": { "type": "number" },
-                    "dnsStart": { "type": "number" },
-                    "dnsEnd": { "type": "number" },
-                    "connectStart": { "type": "number" },
-                    "connectEnd": { "type": "number" },
-                    "sslStart": { "type": "number" },
-                    "sslEnd": { "type": "number" },
-                    "sendStart": { "type": "number" },
-                    "sendEnd": { "type": "number" },
-                    "receiveHeadersEnd": { "type": "number" }
+                    "requestTime": { "type": "number", "description": "Timing's requestTime is a baseline in seconds, while the other numbers are ticks in milliseconds relatively to this requestTime." },
+                    "proxyStart": { "type": "number", "description": "Started resolving proxy." },
+                    "proxyEnd": { "type": "number", "description": "Finished resolving proxy." },
+                    "dnsStart": { "type": "number", "description": "Started DNS address resolve." },
+                    "dnsEnd": { "type": "number", "description": "Finished DNS address resolve." },
+                    "connectStart": { "type": "number", "description": "Started connecting to the remote host." },
+                    "connectEnd": { "type": "number", "description": "Connected to the remote host." },
+                    "sslStart": { "type": "number", "description": "Started SSL handshake." },
+                    "sslEnd": { "type": "number", "description": "Finished SSL handshake." },
+                    "sendStart": { "type": "number", "description": "Started sending request." },
+                    "sendEnd": { "type": "number", "description": "Finished sending request." },
+                    "receiveHeadersEnd": { "type": "number", "description": "Finished receiving response headers." }
                 }
             },
             {
                 "id": "ResourceRequest",
                 "type": "object",
+                "description": "HTTP request data.",
                 "properties": {
-                    "url": { "type": "string" },
-                    "method": { "type": "string" },
-                    "headers": { "type": "object" },
-                    "postData": { "type": "string", "optional": true }
+                    "url": { "type": "string", "description": "Request URL." },
+                    "method": { "type": "string", "description": "HTTP request method." },
+                    "headers": { "type": "object", "description": "HTTP request headers." },
+                    "postData": { "type": "string", "optional": true, "description": "HTTP POST request data." }
                 }
             },
             {
                 "id": "ResourceResponse",
                 "type": "object",
+                "description": "HTTP response data.",
                 "properties": {
-                    "status": { "type": "number" },
-                    "statusText": { "type": "string" },
-                    "headers": { "type": "object" },
-                    "mimeType": { "type": "string" },
-                    "requestHeaders": { "type": "object" },
-                    "connectionReused": { "type": "boolean" },
-                    "connectionID": { "type": "number" },
-                    "fromDiskCache": { "type": "boolean" },
-                    "timing": { "$ref": "ResourceTiming", "optional": true }
+                    "status": { "type": "number", "description": "HTTP response status code." },
+                    "statusText": { "type": "string", "description": "HTTP response status text." },
+                    "headers": { "type": "object", "description": "HTTP response headers." },
+                    "mimeType": { "type": "string", "description": "Resource mimeType as determined by the browser." },
+                    "requestHeaders": { "type": "object", "optional": true, "description": "Refined HTTP request headers that were actually transmitted over the network." },
+                    "connectionReused": { "type": "boolean", "description": "Specifies whether physical connection was actually reused for this request." },
+                    "connectionID": { "type": "number", "description": "Physical connection id that was actually used for this request." },
+                    "fromDiskCache": { "type": "boolean", "optional": true, "description": "Specifies that the resource was loaded from the disk cache." },
+                    "timing": { "$ref": "ResourceTiming", "optional": true, "description": "Timing information for the given request." }
                 }
             },
             {
                 "id": "CachedResource",
                 "type": "object",
+                "description": "Information about the cached resource.",
                 "properties": {
-                    "url": { "type": "string" },
-                    "type": { "type": "string" },
-                    "response": { "$ref": "ResourceResponse" },
-                    "bodySize": { "type": "number" },
+                    "url": { "type": "string", "description": "Resource URL." },
+                    "type": { "type": "string", "description": "Type of this resource. // FIXME" },
+                    "response": { "$ref": "ResourceResponse", "description": "Cached response data." },
+                    "bodySize": { "type": "number", "description": "Cached response body size." }
                 }
             },
             {
                 "id": "Frame",
                 "type": "object",
+                "description": "Information about the Frame on the page.",
                 "properties": {
-                    "id": { "type": "string" },
-                    "parentId": { "type": "string" },
-                    "loaderId": { "type": "string" },
-                    "name": { "type": "string", "optional": true },
-                    "url": { "type": "string" }
+                    "id": { "type": "string", "description": "Frame unique identifier." },
+                    "parentId": { "type": "string", "description": "Parent frame identifier." },
+                    "loaderId": { "type": "string", "description": "Identifier of the loader associated with this frame." },
+                    "name": { "type": "string", "optional": true, "description": "Frame's name as specified in the tag." },
+                    "url": { "type": "string", "description": "Frame document's URL." }
                 }
             },
             {
                 "id": "FrameResourceTree",
                 "type": "object",
+                "description": "Information about the Frame hierarchy along with their cached resources.",
                 "properties": {
-                    "frame": { "$ref": "Frame" },
-                    "childFrames": { "type": "array", "optional": true, "items": { "$ref": "FrameResourceTree" } },
-                    "mainResource": { "$ref": "FrameResource" },
-                    "subresources": { "type": "array", "items": { "$ref": "CachedResource" } }
-                }
-            },
-            {
-                "id": "FrameResource",
-                "type": "object",
-                "properties": {
-                    "url": { "type": "string" },
-                    "request": { "$ref": "ResourceRequest" },
-                    "response": { "$ref": "ResourceResponse" }
+                    "frame": { "$ref": "Frame", "description": "Frame information for this tree item." },
+                    "childFrames": { "type": "array", "optional": true, "items": { "$ref": "FrameResourceTree" }, "description": "Child frames." },
+                    "resources": { "type": "array",
+                        "items": {
+                            "type": "object",
+                            "properties": {
+                                "url": { "type": "string", "description": "Resource URL." },
+                                "type": { "type": "string", "description": "Type of this resource. // FIXME" }
+                            }
+                        },
+                        "description": "Information about frame resources."
+                    }
                 }
             }
         ],
         "commands": [
             {
                 "name": "enable",
-                "returns": [
-                    { "name": "resources", "$ref": "FrameResourceTree" }
-                ]
+                "description": "Enables network tracking, network events will now be delivered to the client."
             },
             {
-                "name": "disable"
+                "name": "disable",
+                "description": "Disables network tracking, prevents network events from being sent to the client."
             },
             {
-                "name": "resourceContent",
+                "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" },
-                    { "name": "url", "type": "string" },
-                    { "name": "base64Encode", "type": "boolean" }
+                    { "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": "success", "type": "boolean" },
-                    { "name": "content", "type": "string" }
+                    { "name": "content", "type": "string", "description": "Resource content." }
                 ]
             },
             {
                 "name": "setExtraHeaders",
+                "description": "Allows sending extra HTTP headers with the requests from this page.",
                 "parameters": [
-                    { "name": "headers", "type": "object" }
+                    { "name": "headers", "type": "object", "description": "Map with extra HTTP headers." }
                 ]
             }
         ],
         "events": [
             {
                 "name": "frameDetachedFromParent",
+                "description": "Fired when frame has been detached from its parent.",
                 "parameters": [
-                    { "name": "frameId", "type": "string" }
+                    { "name": "frameId", "type": "string", "description": "If of the frame that has been detached." }
                 ]
             },
             {
                 "name": "willSendRequest",
+                "description": "Fired when page is about to send HTTP request.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "frameId", "type": "string" },
-                    { "name": "loaderId", "type": "string" },
-                    { "name": "documentURL", "type": "string" },
-                    { "name": "request", "$ref": "ResourceRequest" },
-                    { "name": "redirectResponse", "$ref": "ResourceResponse" },
-                    { "name": "time", "type": "number" },
-                    { "name": "callStack", "type": "array", "items": { "$ref" : "DebuggerStackFrame"} }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "frameId", "type": "string", "description": "Frame identifier." },
+                    { "name": "loaderId", "type": "string", "description": "Loader identifier." },
+                    { "name": "documentURL", "type": "string", "description": "URL of the document this resource is loaded for." },
+                    { "name": "request", "$ref": "ResourceRequest", "description": "Request data." },
+                    { "name": "redirectResponse", "$ref": "ResourceResponse", "description": "Redirect response data." },
+                    { "name": "time", "type": "number", "description": "Timestamp." },
+                    { "name": "callStack", "type": "array", "items": { "$ref" : "DebuggerStackFrame"}, "description": "JavaScript stack trace upon issuing this request." }
                 ]
             },
             {
                 "name": "markResourceAsCached",
+                "description": "Fired when request is known to be served from memory cache.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." }
                 ]
             },
             {
                 "name": "didReceiveResponse",
+                "description": "Fired when HTTP response is available.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "time", "type": "number" },
-                    { "name": "resourceType", "type": "string" },
-                    { "name": "response", "$ref": "ResourceResponse" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "time", "type": "number", "description": "Timestamp." },
+                    { "name": "resourceType", "type": "string", "description": "Resource type. // FIXME" },
+                    { "name": "response", "$ref": "ResourceResponse", "description": "Response data." }
                 ]
             },
             {
                 "name": "didReceiveContentLength",
+                "description": "Fired when data chunk was received over the network.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "time", "type": "number" },
-                    { "name": "dataLength", "type": "integer" },
-                    { "name": "lengthReceived", "type": "integer" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "time", "type": "number", "description": "Timestamp." },
+                    { "name": "dataLength", "type": "integer", "description": "Data chunk length." },
+                    { "name": "lengthReceived", "type": "integer", "description": "Actual bytes received (might be less than dataLength for compressed encodings)." }
                 ]
             },
             {
                 "name": "didFinishLoading",
+                "description": "Fired when HTTP request has finished loading.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "finishTime", "type": "number" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "finishTime", "type": "number", "description": "Timestamp." }
                 ]
             },
             {
                 "name": "didFailLoading",
+                "description": "Fired when HTTP request has failed to load.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "time", "type": "number" },
-                    { "name": "errorText", "type": "string" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "time", "type": "number", "description": "Timestamp." },
+                    { "name": "errorText", "type": "string", "description": "User friendly error message." }
                 ]
             },
             {
                 "name": "didLoadResourceFromMemoryCache",
+                "description": "Fired when HTTP request has been served from memory cache.",
                 "parameters": [
-                    { "name": "frameId", "type": "string" },
-                    { "name": "loaderId", "type": "string" },
-                    { "name": "documentURL", "type": "string" },
-                    { "name": "time", "type": "number" },
-                    { "name": "resource", "$ref": "CachedResource" }
+                    { "name": "frameId", "type": "string", "description": "Frame identifier." },
+                    { "name": "loaderId", "type": "string", "description": "Loader identifier." },
+                    { "name": "documentURL", "type": "string", "description": "URL of the document this resource is loaded for." },
+                    { "name": "time", "type": "number", "description": "Timestamp." },
+                    { "name": "resource", "$ref": "CachedResource", "description": "Cached resource data." }
                 ]
             },
             {
                 "name": "setInitialContent",
+                "description": "Fired for XMLHttpRequests when their content becomes available.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "sourceString", "type": "string" },
-                    { "name": "type", "type": "string" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "content", "type": "string", "description": "Resource content." },
+                    { "name": "type", "type": "string", "description": "Resource type. // FIXME" }
                 ]
             },
             {
                 "name": "didCommitLoadForFrame",
+                "description": "Fired once navigation of the frame has completed. Frame is now associated with the new loader.",
                 "parameters": [
-                    { "name": "frame", "$ref": "Frame" },
-                    { "name": "loaderId", "type": "string" }
+                    { "name": "frame", "$ref": "Frame", "description": "Frame identifier." },
+                    { "name": "loaderId", "type": "string", "description": "Loader identifier." }
                 ]
             },
             {
                 "name": "didCreateWebSocket",
+                "description": "Fired upon WebSocket creation.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "requestURL", "type": "string" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "url", "type": "string", "description": "WebSocket request URL." }
                 ]
             },
             {
                 "name": "willSendWebSocketHandshakeRequest",
+                "description": "Fired when WebSocket is about to initiate handshake.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "time", "type": "number" },
-                    { "name": "request", "$ref": "WebSocketRequest" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "time", "type": "number", "description": "Timestamp." },
+                    { "name": "request", "type": "object", "description": "WebSocket request data." }
                 ]
             },
             {
                 "name": "didReceiveWebSocketHandshakeResponse",
+                "description": "Fired when WebSocket handshake response becomes available.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "time", "type": "number" },
-                    { "name": "response", "$ref": "WebSocketResponse" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "time", "type": "number", "description": "Timestamp." },
+                    { "name": "response", "type": "object", "description": "WebSocket response data." }
                 ]
             },
             {
                 "name": "didCloseWebSocket",
+                "description": "Fired when WebSocket is closed.",
                 "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "time", "type": "number" }
+                    { "name": "identifier", "type": "integer", "description": "Request identifier." },
+                    { "name": "time", "type": "number", "description": "Timestamp." }
                 ]
             }
         ]
index 64ed11e..2e74fdb 100644 (file)
@@ -91,10 +91,12 @@ void InspectorResourceAgent::restore()
         enable();
 }
 
-bool InspectorResourceAgent::resourceContent(Frame* frame, const KURL& url, String* result)
+void InspectorResourceAgent::resourceContent(ErrorString* errorString, Frame* frame, const KURL& url, String* result)
 {
-    if (!frame)
-        return false;
+    if (!frame) {
+        *errorString = "No frame to get resource content for."; 
+        return;
+    }
 
     String textEncodingName;
     RefPtr<SharedBuffer> buffer = InspectorResourceAgent::resourceData(frame, url, &textEncodingName);
@@ -104,23 +106,22 @@ bool InspectorResourceAgent::resourceContent(Frame* frame, const KURL& url, Stri
         if (!encoding.isValid())
             encoding = WindowsLatin1Encoding();
         *result = encoding.decode(buffer->data(), buffer->size());
-        return true;
+        return;
     }
-
-    return false;
+    *errorString = "No resource with given URL found."; 
 }
 
-bool InspectorResourceAgent::resourceContentBase64(Frame* frame, const KURL& url, String* result)
+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();
-        return false;
+        *errorString = "No resource with given URL found."; 
+        return;
     }
 
     *result = base64Encode(data->data(), data->size());
-    return true;
 }
 
 PassRefPtr<SharedBuffer> InspectorResourceAgent::resourceData(Frame* frame, const KURL& url, String* textEncodingName)
@@ -231,18 +232,6 @@ static String pointerAsId(void* pointer)
     return String::format("%.0llX", address);
 }
 
-static PassRefPtr<InspectorObject> buildObjectForFrameResource(Frame* frame)
-{
-    FrameLoader* frameLoader = frame->loader();
-    DocumentLoader* loader = frameLoader->documentLoader();
-
-    RefPtr<InspectorObject> resourceObject = InspectorObject::create();
-    resourceObject->setString("url", loader->url().string());
-    resourceObject->setObject("request", buildObjectForResourceRequest(loader->request()));
-    resourceObject->setObject("response", buildObjectForResourceResponse(loader->response()));
-    return resourceObject;
-}
-
 static String cachedResourceTypeString(const CachedResource& cachedResource)
 {
     switch (cachedResource.type()) {
@@ -387,16 +376,16 @@ static PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame* frame)
     RefPtr<InspectorObject> frameObject = buildObjectForFrame(frame);
     result->setObject("frame", frameObject);
 
-    result->setObject("mainResource", buildObjectForFrameResource(frame));
     RefPtr<InspectorArray> subresources = InspectorArray::create();
-    result->setArray("subresources", subresources);
-
+    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> cachedResourceObject = buildObjectForCachedResource(*cachedResource);
-        subresources->pushValue(cachedResourceObject);
+        RefPtr<InspectorObject> resourceObject = InspectorObject::create();
+        resourceObject->setString("url", cachedResource->url());
+        resourceObject->setString("type", cachedResourceTypeString(*cachedResource));
+        subresources->pushValue(resourceObject);
     }
 
     RefPtr<InspectorArray> childrenArray;
@@ -476,10 +465,9 @@ Frame* InspectorResourceAgent::frameForId(const String& frameId)
     return 0;
 }
 
-void InspectorResourceAgent::enable(ErrorString*, RefPtr<InspectorObject>* object)
+void InspectorResourceAgent::enable(ErrorString*)
 {
     enable();
-    *object = buildObjectForFrameTree(m_page->mainFrame());
 }
 
 void InspectorResourceAgent::enable()
@@ -496,17 +484,22 @@ void InspectorResourceAgent::disable(ErrorString*)
     m_instrumentingAgents->setInspectorResourceAgent(0);
 }
 
-void InspectorResourceAgent::resourceContent(ErrorString*, const String& frameId, const String& url, bool base64Encode, bool* success, String* content)
+void InspectorResourceAgent::getCachedResources(ErrorString*, RefPtr<InspectorObject>* object)
+{
+    *object = buildObjectForFrameTree(m_page->mainFrame());
+}
+
+void InspectorResourceAgent::getResourceContent(ErrorString* errorString, const String& frameId, const String& url, bool base64Encode, String* content)
 {
     Frame* frame = frameForId(frameId);
     if (!frame) {
-        *success = false;
+        *errorString = "No frame for given id found.";
         return;
     }
     if (base64Encode)
-        *success = InspectorResourceAgent::resourceContentBase64(frame, KURL(ParsedURLString, url), content);
+        InspectorResourceAgent::resourceContentBase64(errorString, frame, KURL(ParsedURLString, url), content);
     else
-        *success = InspectorResourceAgent::resourceContent(frame, KURL(ParsedURLString, url), content);
+        InspectorResourceAgent::resourceContent(errorString, frame, KURL(ParsedURLString, url), content);
 }
 
 void InspectorResourceAgent::setExtraHeaders(ErrorString*, PassRefPtr<InspectorObject> headers)
index fb3aeb6..c919469 100644 (file)
@@ -81,8 +81,8 @@ public:
 
     static PassRefPtr<InspectorResourceAgent> restore(Page*, InspectorState*, InspectorFrontend*);
 
-    static bool resourceContent(Frame*, const KURL&, String* result);
-    static bool resourceContentBase64(Frame*, const KURL&, String* result);
+    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&);
 
@@ -109,9 +109,10 @@ public:
     Frame* frameForId(const String& frameId);
 
     // Called from frontend 
-    void enable(ErrorString*, RefPtr<InspectorObject>*);
+    void enable(ErrorString*);
     void disable(ErrorString*);
-    void resourceContent(ErrorString*, const String& frameId, const String& url, bool base64Encode, bool* resourceFound, String* content);
+    void getCachedResources(ErrorString*, RefPtr<InspectorObject>*);
+    void getResourceContent(ErrorString*, const String& frameId, const String& url, bool base64Encode, String* content);
     void setExtraHeaders(ErrorString*, PassRefPtr<InspectorObject>);
 
 private:
index 77ccde0..d418d71 100644 (file)
@@ -1033,7 +1033,9 @@ bool InspectorStyleSheet::resourceStyleSheetText(String* result) const
     if (!m_pageStyleSheet || !ownerDocument())
         return false;
 
-    return InspectorResourceAgent::resourceContent(ownerDocument()->frame(), m_pageStyleSheet->finalURL(), result);
+    String error;
+    InspectorResourceAgent::resourceContent(&error, ownerDocument()->frame(), m_pageStyleSheet->finalURL(), result);
+    return error.isEmpty();
 }
 
 bool InspectorStyleSheet::inlineStyleSheetText(String* result) const
index 07f392d..c0bc273 100644 (file)
@@ -122,6 +122,10 @@ WebInspector.InspectorFrontendHostStub.prototype = {
 
     sendMessageToBackend: function(message)
     {
+    },
+
+    loadSessionSetting: function()
+    {
     }
 }
 
index 7444632..3905ab3 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.NetworkManager = function(resourceTreeModel)
+WebInspector.NetworkManager = function()
 {
     WebInspector.Object.call(this);
-    this._resourceTreeModel = resourceTreeModel;
-    this._dispatcher = new WebInspector.NetworkDispatcher(resourceTreeModel, this);
-    NetworkAgent.enable(this._processCachedResources.bind(this));
+    this._dispatcher = new WebInspector.NetworkDispatcher(this);
+    NetworkAgent.enable();
 }
 
 WebInspector.NetworkManager.EventTypes = {
     ResourceStarted: "ResourceStarted",
     ResourceUpdated: "ResourceUpdated",
     ResourceFinished: "ResourceFinished",
-    MainResourceCommitLoad: "MainResourceCommitLoad"
+    FrameCommittedLoad: "FrameCommittedLoad",
+    FrameDetached: "FrameDetached"
 }
 
 WebInspector.NetworkManager.prototype = {
     frontendReused: function()
     {
-        WebInspector.panels.network.clear();
-        this._resourceTreeModel.reset();
-        NetworkAgent.enable(this._processCachedResources.bind(this));
+        NetworkAgent.enable();
     },
 
     requestContent: function(resource, base64Encode, callback)
     {
-        function callbackWrapper(error, success, content)
+        function callbackWrapper(error, content)
         {
-            callback((!error && success) ? content : null);
+            callback(!error ? content : null);
         }
-        NetworkAgent.resourceContent(resource.frameId, resource.url, base64Encode, callbackWrapper);
-    },
-
-    _processCachedResources: function(error, mainFramePayload)
-    {
-        if (error)
-            return;
-        var mainResource = this._dispatcher._addFramesRecursively(mainFramePayload);
-        WebInspector.mainResource = mainResource;
-        mainResource.isMainResource = true;
+        NetworkAgent.getResourceContent(resource.frameId, resource.url, base64Encode, callbackWrapper);
     },
 
     inflightResourceForURL: function(url)
@@ -77,12 +66,11 @@ WebInspector.NetworkManager.prototype = {
 
 WebInspector.NetworkManager.prototype.__proto__ = WebInspector.Object.prototype;
 
-WebInspector.NetworkDispatcher = function(resourceTreeModel, manager)
+WebInspector.NetworkDispatcher = function(manager)
 {
     this._manager = manager;
     this._inflightResourcesById = {};
     this._inflightResourcesByURL = {};
-    this._resourceTreeModel = resourceTreeModel;
     this._lastIdentifierForCachedResource = 0;
     InspectorBackend.registerDomainDispatcher("Network", this);
 }
@@ -160,7 +148,6 @@ WebInspector.NetworkDispatcher.prototype = {
         this._updateResourceWithResponse(resource, response);
 
         this._updateResource(resource);
-        this._resourceTreeModel.addResourceToFrame(resource.frameId, resource);
     },
 
     didReceiveContentLength: function(identifier, time, dataLength, lengthReceived)
@@ -206,12 +193,11 @@ WebInspector.NetworkDispatcher.prototype = {
         this._startResource(resource);
         resource.startTime = resource.responseReceivedTime = time;
         this._finishResource(resource, time);
-        this._resourceTreeModel.addResourceToFrame(resource.frameId, resource);
     },
 
     frameDetachedFromParent: function(frameId)
     {
-        this._resourceTreeModel.frameDetachedFromParent(frameId);
+        this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.FrameDetached, frameId);
     },
 
     setInitialContent: function(identifier, sourceString, type)
@@ -227,16 +213,7 @@ WebInspector.NetworkDispatcher.prototype = {
 
     didCommitLoadForFrame: function(frame, loaderId)
     {
-        this._resourceTreeModel.didCommitLoadForFrame(frame, loaderId);
-        if (!frame.parentId) {
-            var mainResource = this._resourceTreeModel.resourceForURL(frame.url);
-            if (mainResource) {
-                WebInspector.mainResource = mainResource;
-                mainResource.isMainResource = true;
-                mainResource.documentURL = frame.url;
-                this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, mainResource);
-            }
-        }
+        this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.FrameCommittedLoad, { frame: frame, loaderId: loaderId });
     },
 
     didCreateWebSocket: function(identifier, requestURL)
@@ -317,36 +294,6 @@ WebInspector.NetworkDispatcher.prototype = {
         delete this._inflightResourcesByURL[resource.url];
     },
 
-    _addFramesRecursively: function(frameTreePayload)
-    {
-        var framePayload = frameTreePayload.frame;
-        var mainResource = frameTreePayload.mainResource;
-
-        var frameResource = this._createResource(null, framePayload.id, framePayload.loaderId, mainResource.url, framePayload.url);
-        this._updateResourceWithRequest(frameResource, mainResource.request);
-        this._updateResourceWithResponse(frameResource, mainResource.response);
-        frameResource.type = WebInspector.Resource.Type["Document"];
-        frameResource.finished = true;
-
-        this._resourceTreeModel.addOrUpdateFrame(framePayload);
-        this._resourceTreeModel.addResourceToFrame(framePayload.id, frameResource);
-
-        for (var i = 0; frameTreePayload.childFrames && i < frameTreePayload.childFrames.length; ++i)
-            this._addFramesRecursively(frameTreePayload.childFrames[i]);
-
-        if (!frameTreePayload.subresources)
-            return;
-
-        for (var i = 0; i < frameTreePayload.subresources.length; ++i) {
-            var cachedResource = frameTreePayload.subresources[i];
-            var resource = this._createResource(null, framePayload.id, framePayload.loaderId, cachedResource.url, framePayload.url);
-            this._updateResourceWithCachedResource(resource, cachedResource);
-            resource.finished = true;
-            this._resourceTreeModel.addResourceToFrame(framePayload.id, resource);
-        }
-        return frameResource;
-    },
-
     _dispatchEventToListeners: function(eventType, resource)
     {
         this._manager.dispatchEventToListeners(eventType, resource);
index b0561c9..b5e66db 100644 (file)
@@ -83,7 +83,7 @@ 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.MainResourceCommitLoad, this._onMainResourceCommitLoad, this);
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.FrameCommittedLoad, this._onFrameCommitLoad, this);
 }
 
 WebInspector.NetworkPanel.prototype = {
@@ -368,7 +368,7 @@ WebInspector.NetworkPanel.prototype = {
         for (var i = 0; i < this._resources.length; ++i) {
             var resource = this._resources[i];
             transferSize += (resource.cached || !resource.transferSize) ? 0 : resource.transferSize;
-            if (resource.isMainResource)
+            if (resource === WebInspector.mainResource)
                 baseTime = resource.startTime;
             if (resource.endTime > maxTime)
                 maxTime = resource.endTime;
@@ -802,18 +802,29 @@ WebInspector.NetworkPanel.prototype = {
         this._reset();
     },
 
-    _onMainResourceCommitLoad: function()
+    _onFrameCommitLoad: function(event)
     {
+        if (event.data.frame.parentId)
+            return;
+
+        // Main frame committed load.
         if (this._preserveLogToggle.toggled)
             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];
+            if (resource.loaderId === loaderId)
+                resourcesToPreserve.push(resource);
+        }
+
         this._reset();
 
-        // Now resurrect the main resource along with all redirects that lead to it.
-        this._appendResource(WebInspector.mainResource);
-        var redirects = WebInspector.mainResource.redirects;
-        for (var i = 0; redirects && i < redirects.length; ++i)
-            this._appendResource(redirect);
+        // Restore preserved items.
+        for (var i = 0; i < resourcesToPreserve.length; ++i)
+            this._appendResource(resourcesToPreserve[i]);
     },
 
     canShowSourceLine: function(url, line)
index 6cfc9f6..5503fa6 100644 (file)
  */
 
 
-WebInspector.ResourceTreeModel = function()
+WebInspector.ResourceTreeModel = function(networkManager)
 {
-    this.reset();
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceUpdated, this);
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, 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();
+}
+
+WebInspector.ResourceTreeModel.EventTypes = {
+    FrameAdded: "FrameAdded",
+    FrameNavigated: "FrameNavigated",
+    FrameDetached: "FrameDetached",
+    ResourceAdded: "ResourceAdded"
 }
 
 WebInspector.ResourceTreeModel.prototype = {
-    reset: function()
+    frontendReused: function()
     {
         this._resourcesByURL = {};
         this._resourcesByFrameId = {};
         this._subframes = {};
-        if (WebInspector.panels)
-            WebInspector.panels.resources.clear();
+        NetworkAgent.getCachedResources(this._processCachedResources.bind(this));
+    },
+
+    _processCachedResources: function(error, mainFramePayload)
+    {
+        if (error)
+            return;
+
+        this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, 0);
+
+        WebInspector.mainResource = this._addFramesRecursively(mainFramePayload);
+        this._cachedResourcesProcessed = true;
     },
 
-    addOrUpdateFrame: function(frame)
+    _addOrUpdateFrame: function(frame)
     {
-        WebInspector.panels.resources.addOrUpdateFrame(frame);
+        this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, frame);
+
         var subframes = this._subframes[frame.parentId];
         if (!subframes) {
-            subframes = {};
+            subframes = [];
             this._subframes[frame.parentId || 0] = subframes;
         }
-        subframes[frame.id] = true;
+        subframes.push(frame);
     },
 
-    didCommitLoadForFrame: function(frame, loaderId)
+    frames: function(parentFrameId)
     {
+        return this._subframes[parentFrameId] || [];
+    },
+
+    subframes: function(parentFrameId)
+    {
+        return this._subframes[parentFrameId] || [];
+    },
+
+    resources: function(frameId)
+    {
+        var result = [];
+        var resources = this._resourcesByFrameId[frameId] || {};
+        for (var url in resources)
+            result.push(resources[url]);
+        return result;
+    },
+
+    _onCommitLoad: function(event)
+    {
+        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.
-        this._clearChildFramesAndResources(frame.parentId ? frame.id : 0, loaderId);
+        this._clearChildFramesAndResources(isMainFrame ? 0 : frame.id, loaderId);
 
-        this.addOrUpdateFrame(frame);
+        this._addOrUpdateFrame(frame);
 
         var resourcesForFrame = this._resourcesByFrameId[frame.id];
-        for (var i = 0; resourcesForFrame && i < resourcesForFrame.length; ++i)
-            WebInspector.panels.resources.addResourceToFrame(frame.id, resourcesForFrame[i]);
+        if (resourcesForFrame) {
+            for (var url in resourcesForFrame)
+                this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resourcesForFrame[url]);
+        }
+
+        if (isMainFrame && this.resourceForURL(frame.url))
+            WebInspector.mainResource = this.resourceForURL(frame.url);
     },
 
-    frameDetachedFromParent: function(frameId)
+    _onFrameDetachedFromParent: function(event)
     {
+        if (!this._cachedResourcesProcessed)
+            return;
+
+        var frameId = event.data;
         this._clearChildFramesAndResources(frameId, 0);
-        WebInspector.panels.resources.removeFrame(frameId);
+        this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, frameId);
     },
 
-    addResourceToFrame: function(frameId, resource)
+    _onResourceUpdated: function(event)
     {
+        if (!this._cachedResourcesProcessed)
+            return;
+        this._addResourceToFrame(event.data);
+    },
+
+    _addResourceToFrame: function(resource)
+    {
+        var frameId = resource.frameId;
         var resourcesForFrame = this._resourcesByFrameId[frameId];
         if (!resourcesForFrame) {
-            resourcesForFrame = [];
+            resourcesForFrame = {};
             this._resourcesByFrameId[frameId] = resourcesForFrame;
         }
-        resourcesForFrame.push(resource);
-        this._bindResourceURL(resource);
+        if (resourcesForFrame[resource.url] === resource) {
+            // Already in the tree, we just got an extra update.
+            return;
+        }
 
-        WebInspector.panels.resources.addResourceToFrame(frameId, resource);
+        resourcesForFrame[resource.url] = resource;
+        this._bindResourceURL(resource);
+        this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resource);
     },
 
     forAllResources: function(callback)
@@ -122,36 +192,23 @@ WebInspector.ResourceTreeModel.prototype = {
 
     resourceForURL: function(url)
     {
-        // FIXME: receive frameId here.
-        var entry = this._resourcesByURL[url];
-        if (entry instanceof Array)
-            return entry[0];
-        return entry;
+        return this._resourcesByURL[url];
     },
 
     _bindResourceURL: function(resource)
     {
-        var resourceForURL = this._resourcesByURL[resource.url];
-        if (!resourceForURL)
-            this._resourcesByURL[resource.url] = resource;
-        else if (resourceForURL instanceof Array)
-            resourceForURL.push(resource);
-        else
-            this._resourcesByURL[resource.url] = [resourceForURL, resource];
+        this._resourcesByURL[resource.url] = resource;
     },
 
     _clearChildFramesAndResources: function(frameId, loaderToPreserveId)
     {
-        WebInspector.panels.resources.removeResourcesFromFrame(frameId);
+        this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, frameId);
 
         this._clearResources(frameId, loaderToPreserveId);
         var subframes = this._subframes[frameId];
-        if (!subframes)
-            return;
-
-        for (var childFrameId in subframes) {
-            WebInspector.panels.resources.removeFrame(childFrameId);
-            this._clearChildFramesAndResources(childFrameId, loaderToPreserveId);
+        for (var i = 0; subframes && i < subframes.length; ++ i) {
+            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameRemoved, subframes[i].id);
+            this._clearChildFramesAndResources(subframes[i].id, loaderToPreserveId);
         }
         delete this._subframes[frameId];
     },
@@ -163,10 +220,10 @@ WebInspector.ResourceTreeModel.prototype = {
             return;
 
         var preservedResourcesForFrame = [];
-        for (var i = 0; i < resourcesForFrame.length; ++i) {
-            var resource = resourcesForFrame[i];
+        for (var url in resourcesForFrame) {
+            var resource = resourcesForFrame[url];
             if (resource.loaderId === loaderToPreserveId) {
-                preservedResourcesForFrame.push(resource);
+                preservedResourcesForFrame[url] = resource;
                 continue;
             }
             this._unbindResourceURL(resource);
@@ -181,34 +238,63 @@ WebInspector.ResourceTreeModel.prototype = {
     _callForFrameResources: function(frameId, callback)
     {
         var resources = this._resourcesByFrameId[frameId];
-        for (var i = 0; resources && i < resources.length; ++i) {
-            if (callback(resources[i]))
+        if (!resources)
+            return;
+
+        for (var url in resources) {
+            if (callback(resources[url]))
                 return true;
         }
         
         var frames = this._subframes[frameId];
-        if (frames) {
-            for (var id in frames) {
-                if (this._callForFrameResources(id, callback))
-                    return true;
-            }
+        for (var i = 0; frames && i < frames.length; ++i) {
+            if (this._callForFrameResources(frames[i].id, callback))
+                return true;
         }
         return false;
     },
 
     _unbindResourceURL: function(resource)
     {
-        var resourceForURL = this._resourcesByURL[resource.url];
-        if (!resourceForURL)
-            return;
+        delete this._resourcesByURL[resource.url];
+    },
+
+    _addFramesRecursively: function(frameTreePayload)
+    {
+        var framePayload = frameTreePayload.frame;
+
+        // Create frame resource.
+        var frameResource = this._createResource(framePayload, framePayload.url);
+        frameResource.type = WebInspector.Resource.Type.Document;
+        frameResource.finished = true;
+
+        this._addOrUpdateFrame(framePayload);
+        this._addResourceToFrame(frameResource);
 
-        if (resourceForURL instanceof Array) {
-            resourceForURL.remove(resource, true);
-            if (resourceForURL.length === 1)
-                this._resourcesByURL[resource.url] = resourceForURL[0];
+        for (var i = 0; frameTreePayload.childFrames && i < frameTreePayload.childFrames.length; ++i)
+            this._addFramesRecursively(frameTreePayload.childFrames[i]);
+
+        if (!frameTreePayload.resources)
             return;
+
+        // Create frame subresources.
+        for (var i = 0; i < frameTreePayload.resources.length; ++i) {
+            var subresource = frameTreePayload.resources[i];
+            var resource = this._createResource(framePayload, subresource.url);
+            resource.type = WebInspector.Resource.Type[subresource.type];
+            resource.finished = true;
+            this._addResourceToFrame(resource);
         }
+        return frameResource;
+    },
 
-        delete this._resourcesByURL[resource.url];
+    _createResource: function(frame, url)
+    {
+        var resource = new WebInspector.Resource(null, url);
+        resource.frameId = frame.id;
+        resource.loaderId = frame.loaderId;
+        return resource;
     }
 }
+
+WebInspector.ResourceTreeModel.prototype.__proto__ = WebInspector.Object.prototype;
index 60d7f67..8f1cb29 100644 (file)
@@ -42,7 +42,6 @@ WebInspector.ResourcesPanel = function(database)
 
     this.resourcesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Frames"), "Frames", ["frame-storage-tree-item"]);
     this.sidebarTree.appendChild(this.resourcesListTreeElement);
-    this._treeElementForFrameId = {};
 
     this.databasesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Databases"), "Databases", ["database-storage-tree-item"]);
     this.sidebarTree.appendChild(this.databasesListTreeElement);
@@ -99,10 +98,10 @@ WebInspector.ResourcesPanel.prototype = {
     {
         WebInspector.Panel.prototype.show.call(this);
 
+        this._populateResourceTree();
+
         if (this.visibleView && this.visibleView.resource)
             this._showResourceView(this.visibleView.resource);
-
-        this._initDefaultSelection();
     },
 
     loadEventFired: function()
@@ -168,15 +167,36 @@ WebInspector.ResourcesPanel.prototype = {
             this.sidebarTree.selectedTreeElement.deselect();
     },
 
-    clear: function()
+    _populateResourceTree: function()
     {
-        this.resourcesListTreeElement.removeChildren();
+        if (this._treeElementForFrameId)
+            return;
+
         this._treeElementForFrameId = {};
-        this.reset();
+        WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, this._frameAdded, this);
+        WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated, this);
+        WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, this);
+        WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
+
+        function populateFrame(frameId)
+        {
+            var subframes = WebInspector.resourceTreeModel.subframes(frameId);
+            for (var i = 0; i < subframes.length; ++i) {
+                this._frameAdded({data:subframes[i]});
+                populateFrame.call(this, subframes[i].id);
+            }
+
+            var resources = WebInspector.resourceTreeModel.resources(frameId);
+            for (var i = 0; i < resources.length; ++i)
+                this._resourceAdded({data:resources[i]});
+        }
+        populateFrame.call(this, 0);
+        this._initDefaultSelection();
     },
 
-    addOrUpdateFrame: function(frame)
+    _frameAdded: function(event)
     {
+        var frame = event.data;
         var frameId = frame.id;
         var parentFrameId = frame.parentId;
         var title = frame.name;
@@ -214,8 +234,9 @@ WebInspector.ResourcesPanel.prototype = {
         parentTreeElement.appendChild(frameTreeElement);
     },
 
-    removeFrame: function(frameId)
+    _frameDetached: function(event)
     {
+        var frameId = event.data;
         var frameTreeElement = this._treeElementForFrameId[frameId];
         if (!frameTreeElement)
             return;
@@ -224,8 +245,11 @@ WebInspector.ResourcesPanel.prototype = {
             frameTreeElement.parent.removeChild(frameTreeElement);
     },
 
-    addResourceToFrame: function(frameId, resource)
+    _resourceAdded: function(event)
     {
+        var resource = event.data;
+        var frameId = resource.frameId;
+
         if (resource.statusCode >= 301 && resource.statusCode <= 303)
             return;
 
@@ -254,11 +278,20 @@ WebInspector.ResourcesPanel.prototype = {
         frameTreeElement.appendChild(resourceTreeElement);
     },
 
-    removeResourcesFromFrame: function(frameId)
+    _frameNavigated: function(event)
     {
+        var frameId = event.data;
+        if (!frameId) {
+            // Total update.
+            this.resourcesListTreeElement.removeChildren();
+            this._treeElementForFrameId = {};
+            this.reset();
+            return;
+        }
+
         var frameTreeElement = this._treeElementForFrameId[frameId];
         if (frameTreeElement)
-            frameTreeElement.removeChildren();
+            frameTreeElement.removeChildren();        
     },
 
     _refreshResource: function(event)
@@ -926,10 +959,8 @@ WebInspector.FrameTreeElement.prototype = {
     {
         this._displayName = "";
         if (this.parent) {
-            if (title) {
-                this.titleElement.textContent = title;
-                this._displayName = title;
-            }
+            this.titleElement.textContent = title || "";
+            this._displayName = title || "";
             if (subtitle) {
                 var subtitleElement = document.createElement("span");
                 subtitleElement.className = "base-storage-tree-element-subtitle";
index eedb8ea..8e27670 100644 (file)
@@ -439,8 +439,8 @@ WebInspector.doLoadedDone = function()
     this.drawer = new WebInspector.Drawer();
     this.console = new WebInspector.ConsoleView(this.drawer);
     this.drawer.visibleView = this.console;
+    this.networkManager = new WebInspector.NetworkManager();
     this.resourceTreeModel = new WebInspector.ResourceTreeModel();
-    this.networkManager = new WebInspector.NetworkManager(this.resourceTreeModel);
     this.domAgent = new WebInspector.DOMAgent();
 
     InspectorBackend.registerDomainDispatcher("Inspector", this);
@@ -1397,6 +1397,8 @@ WebInspector.addMainEventListeners = function(doc)
 WebInspector.frontendReused = function()
 {
     this.networkManager.frontendReused();
+    this.resourceTreeModel.frontendReused();
+    WebInspector.panels.network.clear();
     this.reset();
 }