2011-03-24 Pavel Feldman <pfeldman@chromium.org>
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Mar 2011 13:27:57 +0000 (13:27 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Mar 2011 13:27:57 +0000 (13:27 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: brush up Network agent API.
        https://bugs.webkit.org/show_bug.cgi?id=57001

        * http/tests/inspector/network/network-redirect-expected.txt: Added.
        * http/tests/inspector/network/network-redirect.html: Added.
        * inspector/timeline/timeline-network-resource-expected.txt:
        * platform/chromium/inspector/timeline/timeline-network-resource-expected.txt:
2011-03-24  Pavel Feldman  <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: brush up Network agent API.
        https://bugs.webkit.org/show_bug.cgi?id=57001

        * inspector/Inspector.json:
        * inspector/InspectorInstrumentation.cpp:
        (WebCore::InspectorInstrumentation::willSendRequestImpl):
        * inspector/InspectorInstrumentation.h:
        (WebCore::InspectorInstrumentation::willSendRequest):
        * inspector/InspectorResourceAgent.cpp:
        (WebCore::buildObjectForResourceRequest):
        (WebCore::buildObjectForResourceResponse):
        (WebCore::buildObjectForCachedResource):
        (WebCore::InspectorResourceAgent::willSendRequest):
        (WebCore::InspectorResourceAgent::willSendWebSocketHandshakeRequest):
        (WebCore::InspectorResourceAgent::didReceiveWebSocketHandshakeResponse):
        (WebCore::InspectorResourceAgent::setExtraHeaders):
        * inspector/InspectorResourceAgent.h:
        * inspector/TimelineRecordFactory.cpp:
        (WebCore::TimelineRecordFactory::createResourceReceiveResponseData):
        * inspector/front-end/NetworkManager.js:
        (WebInspector.NetworkDispatcher.prototype._updateResourceWithRequest):
        (WebInspector.NetworkDispatcher.prototype._updateResourceWithResponse):
        (WebInspector.NetworkDispatcher.prototype._updateResourceWithCachedResource):
        (WebInspector.NetworkDispatcher.prototype.willSendRequest):
        (WebInspector.NetworkDispatcher.prototype.didReceiveWebSocketHandshakeResponse):
        (WebInspector.NetworkDispatcher.prototype.didCloseWebSocket):
        * inspector/front-end/Resource.js:
        * inspector/front-end/TimelinePanel.js:
        (WebInspector.TimelinePanel.FormattedRecord.prototype._generatePopupContent):
        * loader/ResourceLoadNotifier.cpp:
        (WebCore::ResourceLoadNotifier::assignIdentifierToInitialRequest):
        (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
        * loader/appcache/ApplicationCacheGroup.cpp:
        (WebCore::ApplicationCacheGroup::createResourceHandle):
2011-03-24  Pavel Feldman  <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: brush up Network agent API.
        https://bugs.webkit.org/show_bug.cgi?id=57001

        * public/WebDevToolsAgent.h:
        * src/WebDevToolsAgentImpl.cpp:
        (WebKit::WebDevToolsAgentImpl::identifierForInitialRequest):
        (WebKit::WebDevToolsAgentImpl::willSendRequest):
        * src/WebDevToolsAgentImpl.h:

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

22 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/network-redirect-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/network-redirect.html [new file with mode: 0644]
LayoutTests/inspector/timeline/timeline-network-resource-expected.txt
LayoutTests/platform/chromium/inspector/timeline/timeline-network-resource-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorResourceAgent.cpp
Source/WebCore/inspector/InspectorResourceAgent.h
Source/WebCore/inspector/TimelineRecordFactory.cpp
Source/WebCore/inspector/front-end/NetworkManager.js
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/Resource.js
Source/WebCore/inspector/front-end/TimelinePanel.js
Source/WebCore/loader/ResourceLoadNotifier.cpp
Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebDevToolsAgent.h
Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp
Source/WebKit/chromium/src/WebDevToolsAgentImpl.h

index 83fe487..86059ab 100644 (file)
@@ -1,3 +1,15 @@
+2011-03-24  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: brush up Network agent API.
+        https://bugs.webkit.org/show_bug.cgi?id=57001
+
+        * http/tests/inspector/network/network-redirect-expected.txt: Added.
+        * http/tests/inspector/network/network-redirect.html: Added.
+        * inspector/timeline/timeline-network-resource-expected.txt:
+        * platform/chromium/inspector/timeline/timeline-network-resource-expected.txt:
+
 2011-03-24  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, skipping 3 xmlhttprequest tests timing out on GTK, see
diff --git a/LayoutTests/http/tests/inspector/network/network-redirect-expected.txt b/LayoutTests/http/tests/inspector/network/network-redirect-expected.txt
new file mode 100644 (file)
index 0000000..f24c7da
--- /dev/null
@@ -0,0 +1,11 @@
+CONSOLE MESSAGE: line 15: Done.
+Tests network panel redirect.
+
+
+Model data:
+GET: http://127.0.0.1:8000/inspector/network/resources/redirect.php?status=302 -> 302
+GET: http://127.0.0.1:8000/inspector/network/resources/redirect.php?redirected=true -> 200
+Grid data:
+GET: http://127.0.0.1:8000/inspector/network/resources/redirect.php?status=302 -> 302
+GET: http://127.0.0.1:8000/inspector/network/resources/redirect.php?redirected=true -> 200
+
diff --git a/LayoutTests/http/tests/inspector/network/network-redirect.html b/LayoutTests/http/tests/inspector/network/network-redirect.html
new file mode 100644 (file)
index 0000000..120a511
--- /dev/null
@@ -0,0 +1,53 @@
+<html>
+<head>
+<script src="../inspector-test.js"></script>
+<script>
+function loadIframe()
+{
+    var iframe = document.createElement("iframe");
+    iframe.src = "resources/redirect.php?status=302";
+    iframe.onload = iframeLoaded;
+    document.body.appendChild(iframe);
+}
+
+function iframeLoaded()
+{
+    console.log("Done.");
+}
+
+function test()
+{
+    InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "addMessage", step2);
+    InspectorTest.evaluateInPage("loadIframe()");
+
+    function step2()
+    {
+        // inspector-test.js appears in network panel occasionally in Safari on
+        // Mac, so checking two last resources.
+
+        InspectorTest.addResult("Model data:");
+
+        var resources = WebInspector.panels.network.resources;
+        for (var i = resources.length - 2; i < resources.length; ++i)
+            printResource(resources[i]);
+
+        InspectorTest.addResult("Grid data:");
+
+        var dataGridNodes = WebInspector.panels.network._dataGrid.children;
+        WebInspector.panels.network.refresh();
+        for (var i = dataGridNodes.length - 2; i < dataGridNodes.length; ++i)
+            printResource(dataGridNodes[i]._resource);
+        InspectorTest.completeTest();
+    }
+
+    function printResource(resource)
+    {
+        InspectorTest.addResult(resource.requestMethod + ": " + resource.url + " -> " + resource.statusCode);
+    }
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests network panel redirect.</p>
+</body>
+</html>
index c470acf..b26e699 100644 (file)
@@ -23,7 +23,6 @@ ResourceReceiveResponse Properties:
         identifier : <number>
         statusCode : 0
         mimeType : <string>
-        expectedContentLength : 213
         url : <string>
     }
     children : <object>
index 1485a13..d94c7df 100644 (file)
@@ -24,7 +24,6 @@ ResourceReceiveResponse Properties:
         identifier : <number>
         statusCode : 0
         mimeType : <string>
-        expectedContentLength : 213
         url : <string>
     }
     children : <object>
index d07afa3..beb2ba1 100644 (file)
@@ -1,3 +1,42 @@
+2011-03-24  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: brush up Network agent API.
+        https://bugs.webkit.org/show_bug.cgi?id=57001
+
+        * inspector/Inspector.json:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::willSendRequestImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::willSendRequest):
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::buildObjectForResourceRequest):
+        (WebCore::buildObjectForResourceResponse):
+        (WebCore::buildObjectForCachedResource):
+        (WebCore::InspectorResourceAgent::willSendRequest):
+        (WebCore::InspectorResourceAgent::willSendWebSocketHandshakeRequest):
+        (WebCore::InspectorResourceAgent::didReceiveWebSocketHandshakeResponse):
+        (WebCore::InspectorResourceAgent::setExtraHeaders):
+        * inspector/InspectorResourceAgent.h:
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore::TimelineRecordFactory::createResourceReceiveResponseData):
+        * inspector/front-end/NetworkManager.js:
+        (WebInspector.NetworkDispatcher.prototype._updateResourceWithRequest):
+        (WebInspector.NetworkDispatcher.prototype._updateResourceWithResponse):
+        (WebInspector.NetworkDispatcher.prototype._updateResourceWithCachedResource):
+        (WebInspector.NetworkDispatcher.prototype.willSendRequest):
+        (WebInspector.NetworkDispatcher.prototype.didReceiveWebSocketHandshakeResponse):
+        (WebInspector.NetworkDispatcher.prototype.didCloseWebSocket):
+        * inspector/front-end/Resource.js:
+        * inspector/front-end/TimelinePanel.js:
+        (WebInspector.TimelinePanel.FormattedRecord.prototype._generatePopupContent):
+        * loader/ResourceLoadNotifier.cpp:
+        (WebCore::ResourceLoadNotifier::assignIdentifierToInitialRequest):
+        (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::createResourceHandle):
+
 2011-03-11  Steve Block  <steveblock@google.com>
 
         Reviewed by Jeremy Orlow.
index 8fb231f..4193939 100644 (file)
     },
     {
         "domain": "Network",
-        "types": [],
+        "types": [
+            {
+                "id": "ResourceTiming",
+                "type": "object",
+                "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" }
+                }
+            },
+            {
+                "id": "ResourceRequest",
+                "type": "object",
+                "properties": {
+                    "url": { "type": "string" },
+                    "method": { "type": "string" },
+                    "headers": { "type": "object" },
+                    "postData": { "type": "string", "optional": true }
+                }
+            },
+            {
+                "id": "ResourceResponse",
+                "type": "object",
+                "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 }
+                }
+            },
+            {
+                "id": "CachedResource",
+                "type": "object",
+                "properties": {
+                    "url": { "type": "string" },
+                    "type": { "type": "string" },
+                    "response": { "$ref": "ResourceResponse" },
+                    "bodySize": { "type": "number" },
+                    "loader": { "$ref": "DocumentLoader" }
+                }
+            },
+            {
+                "id": "DocumentLoader",
+                "type": "object",
+                "properties": {
+                    "frameId": { "type": "string" },
+                    "loaderId": { "type": "string" },
+                    "url": { "type": "string" }
+                }
+            },
+            {
+                "id": "FrameResource",
+                "type": "object",
+                "properties": {
+                    "url": { "type": "string" },
+                    "loader": { "$ref": "DocumentLoader" },
+                    "request": { "$ref": "ResourceRequest" },
+                    "response": { "$ref": "ResourceResponse" }
+                }
+            }
+        ],
         "commands": [
             {
                 "name": "enable",
                 "returns": [
-                    { "name": "resources", "$ref": "NetworkResourceTree" }
+                    { "name": "resources", "$ref": "FrameResourceTree" }
                 ]
             },
             {
                 ]
             },
             {
-                "name": "identifierForInitialRequest",
-                "parameters": [
-                    { "name": "identifier", "type": "integer" },
-                    { "name": "url", "type": "string" },
-                    { "name": "loader", "$ref": "NetworkLoader" },
-                    { "name": "callStack", "type": "array", "items": { "$ref" : "DebuggerStackFrame"} }
-                ]
-            },
-            {
                 "name": "willSendRequest",
                 "parameters": [
                     { "name": "identifier", "type": "integer" },
+                    { "name": "loader", "$ref": "NetworkLoader" },
+                    { "name": "request", "$ref": "ResourceRequest" },
+                    { "name": "redirectResponse", "$ref": "ResourceResponse" },
                     { "name": "time", "type": "number" },
-                    { "name": "request", "$ref": "NetworkRequest" },
-                    { "name": "redirectResponse", "$ref": "NetworkResponse" }
+                    { "name": "callStack", "type": "array", "items": { "$ref" : "DebuggerStackFrame"} }
                 ]
             },
             {
                     { "name": "identifier", "type": "integer" },
                     { "name": "time", "type": "number" },
                     { "name": "resourceType", "type": "string" },
-                    { "name": "response", "$ref": "NetworkResponse" }
+                    { "name": "response", "$ref": "ResourceResponse" }
                 ]
             },
             {
                     "nodeValue": { "type": "string", "description": "<code>Node</code>'s nodeValue." },
                     "childNodeCount": { "type": "integer", "optional": true, "description": "Child count for <code>Container</code> nodes." },
                     "children": { "type": "array", "optional": true, "items": { "$ref" : "DOMNode" }, "description": "Child nodes of this node when requested with children." },
-                    "attributes": { "type": "array", "optional": true, "items": { "type" : "string" }, "description": "Attributes of the <code>Element</code> node in the form of flat array <code>[name1, value1, name2, value2]." },
+                    "attributes": { "type": "array", "optional": true, "items": { "type" : "string" }, "description": "Attributes of the <code>Element</code> node in the form of flat array <code>[name1, value1, name2, value2]</code>." },
                     "documentURL": { "type": "string", "optional": true, "description": "Document URL that <code>Document</code> or <code>FrameOwner</code> node points to." },
                     "publicId": { "type": "string", "optional": true, "description": "<code>DocumentType</code>'s publicId. // FIXME" },
                     "systemId": { "type": "string", "optional": true, "description": "<code>DocumentType</code>'s systemId. // FIXME" },
index dd581d7..3e34424 100644 (file)
@@ -385,26 +385,17 @@ void InspectorInstrumentation::didRecalculateStyleImpl(const InspectorInstrument
         timelineAgent->didRecalculateStyle();
 }
 
-void InspectorInstrumentation::identifierForInitialRequestImpl(InspectorAgent* inspectorAgent, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
-{
-    if (!inspectorAgent->enabled())
-        return;
-
-    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(inspectorAgent))
-        resourceAgent->identifierForInitialRequest(identifier, request.url(), loader);
-}
-
 void InspectorInstrumentation::applyUserAgentOverrideImpl(InspectorAgent* inspectorAgent, String* userAgent)
 {
     inspectorAgent->applyUserAgentOverride(userAgent);
 }
 
-void InspectorInstrumentation::willSendRequestImpl(InspectorAgent* inspectorAgent, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
+void InspectorInstrumentation::willSendRequestImpl(InspectorAgent* inspectorAgent, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
 {
     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorAgent))
         timelineAgent->willSendResourceRequest(identifier, request);
     if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(inspectorAgent))
-        resourceAgent->willSendRequest(identifier, request, redirectResponse);
+        resourceAgent->willSendRequest(identifier, loader, request, redirectResponse);
 }
 
 void InspectorInstrumentation::markResourceAsCachedImpl(InspectorAgent* inspectorAgent, unsigned long identifier)
index fc56eeb..5ce4a0f 100644 (file)
@@ -110,8 +110,7 @@ public:
     static void didRecalculateStyle(const InspectorInstrumentationCookie&);
 
     static void applyUserAgentOverride(Frame*, String*);
-    static void identifierForInitialRequest(Frame*, unsigned long identifier, DocumentLoader*, const ResourceRequest&);
-    static void willSendRequest(Frame*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
+    static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
     static void markResourceAsCached(Page*, unsigned long identifier);
     static void didLoadResourceFromMemoryCache(Page*, DocumentLoader*, const CachedResource*);
     static InspectorInstrumentationCookie willReceiveResourceData(Frame*, unsigned long identifier);
@@ -227,8 +226,7 @@ private:
     static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
 
     static void applyUserAgentOverrideImpl(InspectorAgent*, String*);
-    static void identifierForInitialRequestImpl(InspectorAgent*, unsigned long identifier, DocumentLoader*, const ResourceRequest&);
-    static void willSendRequestImpl(InspectorAgent*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
+    static void willSendRequestImpl(InspectorAgent*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
     static void markResourceAsCachedImpl(InspectorAgent*, unsigned long identifier);
     static void didLoadResourceFromMemoryCacheImpl(InspectorAgent*, DocumentLoader*, const CachedResource*);
     static InspectorInstrumentationCookie willReceiveResourceDataImpl(InspectorAgent*, unsigned long identifier);
@@ -601,17 +599,6 @@ inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrum
 #endif
 }
 
-inline void InspectorInstrumentation::identifierForInitialRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
-{
-#if ENABLE(INSPECTOR)
-    // This notification should be procecessed even in cases there is no frontend.
-    if (!frame)
-        return;
-    if (InspectorAgent* ic = inspectorAgentForPage(frame->page()))
-        identifierForInitialRequestImpl(ic, identifier, loader, request);
-#endif
-}
-
 inline void InspectorInstrumentation::applyUserAgentOverride(Frame* frame, String* userAgent)
 {
 #if ENABLE(INSPECTOR)
@@ -620,11 +607,11 @@ inline void InspectorInstrumentation::applyUserAgentOverride(Frame* frame, Strin
 #endif
 }
 
-inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
+inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
 {
 #if ENABLE(INSPECTOR)
     if (InspectorAgent* ic = inspectorAgentWithFrontendForFrame(frame))
-        willSendRequestImpl(ic, identifier, request, redirectResponse);
+        willSendRequestImpl(ic, identifier, loader, request, redirectResponse);
 #endif
 }
 
index 2bc82a3..9b3df69 100644 (file)
@@ -193,41 +193,33 @@ static PassRefPtr<InspectorObject> buildObjectForResourceRequest(const ResourceR
 {
     RefPtr<InspectorObject> requestObject = InspectorObject::create();
     requestObject->setString("url", request.url().string());
-    requestObject->setString("httpMethod", request.httpMethod());
-    requestObject->setObject("httpHeaderFields", buildObjectForHeaders(request.httpHeaderFields()));
+    requestObject->setString("method", request.httpMethod());
+    requestObject->setObject("headers", buildObjectForHeaders(request.httpHeaderFields()));
     if (request.httpBody() && !request.httpBody()->isEmpty())
-        requestObject->setString("requestFormData", request.httpBody()->flattenToString());
+        requestObject->setString("postData", request.httpBody()->flattenToString());
     return requestObject;
 }
 
 static PassRefPtr<InspectorObject> buildObjectForResourceResponse(const ResourceResponse& response)
 {
     RefPtr<InspectorObject> responseObject = InspectorObject::create();
-    if (response.isNull()) {
-        responseObject->setBoolean("isNull", true);
+    if (response.isNull())
         return responseObject;
-    }
-    responseObject->setString("url", response.url().string());
+
+    responseObject->setNumber("status", response.resourceLoadInfo() ? response.resourceLoadInfo()->httpStatusCode : response.httpStatusCode());
+    responseObject->setString("statusText", response.resourceLoadInfo() ? response.resourceLoadInfo()->httpStatusText : response.httpStatusText());
+    responseObject->setObject("headers", buildObjectForHeaders(response.resourceLoadInfo() ? response.resourceLoadInfo()->responseHeaders : response.httpHeaderFields()));
+
     responseObject->setString("mimeType", response.mimeType());
-    responseObject->setNumber("expectedContentLength", response.expectedContentLength());
-    responseObject->setString("textEncodingName", response.textEncodingName());
-    responseObject->setString("suggestedFilename", response.suggestedFilename());
-    responseObject->setNumber("httpStatusCode", response.httpStatusCode());
-    responseObject->setString("httpStatusText", response.httpStatusText());
-    responseObject->setObject("httpHeaderFields", buildObjectForHeaders(response.httpHeaderFields()));
     responseObject->setBoolean("connectionReused", response.connectionReused());
     responseObject->setNumber("connectionID", response.connectionID());
-    responseObject->setBoolean("wasCached", response.wasCached());
+    responseObject->setBoolean("fromDiskCache", response.wasCached());
     if (response.resourceLoadTiming())
         responseObject->setObject("timing", buildObjectForTiming(*response.resourceLoadTiming()));
-    if (response.resourceLoadInfo()) {
-        RefPtr<InspectorObject> loadInfoObject = InspectorObject::create();
-        loadInfoObject->setNumber("httpStatusCode", response.resourceLoadInfo()->httpStatusCode);
-        loadInfoObject->setString("httpStatusText", response.resourceLoadInfo()->httpStatusText);
-        loadInfoObject->setObject("requestHeaders", buildObjectForHeaders(response.resourceLoadInfo()->requestHeaders));
-        loadInfoObject->setObject("responseHeaders", buildObjectForHeaders(response.resourceLoadInfo()->responseHeaders));
-        responseObject->setObject("loadInfo", loadInfoObject);
-    }
+
+    if (response.resourceLoadInfo())
+        responseObject->setObject("requestHeaders", buildObjectForHeaders(response.resourceLoadInfo()->requestHeaders));
+
     return responseObject;
 }
 
@@ -286,7 +278,7 @@ static PassRefPtr<InspectorObject> buildObjectForCachedResource(DocumentLoader*
     RefPtr<InspectorObject> resourceObject = InspectorObject::create();
     resourceObject->setString("url", cachedResource.url());
     resourceObject->setString("type", cachedResourceTypeString(cachedResource));
-    resourceObject->setNumber("encodedSize", cachedResource.encodedSize());
+    resourceObject->setNumber("bodySize", cachedResource.encodedSize());
     resourceObject->setObject("response", buildObjectForResourceResponse(cachedResource.response()));
     resourceObject->setObject("loader", buildObjectForDocumentLoader(loader));
     return resourceObject;
@@ -312,25 +304,7 @@ InspectorResourceAgent::~InspectorResourceAgent()
     ASSERT(!m_instrumentingAgents->inspectorResourceAgent());
 }
 
-void InspectorResourceAgent::identifierForInitialRequest(unsigned long identifier, const KURL& url, DocumentLoader* loader)
-{
-    RefPtr<InspectorObject> loaderObject = buildObjectForDocumentLoader(loader);
-    RefPtr<ScriptCallStack> callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true);
-    RefPtr<InspectorArray> callStackValue;
-    if (callStack)
-        callStackValue = callStack->buildInspectorArray();
-    else
-        callStackValue = InspectorArray::create();
-    m_frontend->identifierForInitialRequest(static_cast<int>(identifier), url.string(), loaderObject, callStackValue);
-}
-
-void InspectorResourceAgent::setExtraHeaders(ErrorString*, PassRefPtr<InspectorObject> headers)
-{
-    m_state->setObject(ResourceAgentState::extraRequestHeaders, headers);
-}
-
-
-void InspectorResourceAgent::willSendRequest(unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
+void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
 {
     RefPtr<InspectorObject> headers = m_state->getObject(ResourceAgentState::extraRequestHeaders);
 
@@ -346,7 +320,15 @@ void InspectorResourceAgent::willSendRequest(unsigned long identifier, ResourceR
     request.setReportLoadTiming(true);
     request.setReportRawHeaders(true);
 
-    m_frontend->willSendRequest(static_cast<int>(identifier), currentTime(), buildObjectForResourceRequest(request), buildObjectForResourceResponse(redirectResponse));
+    RefPtr<InspectorObject> loaderObject = buildObjectForDocumentLoader(loader);
+    RefPtr<ScriptCallStack> callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true);
+    RefPtr<InspectorArray> callStackValue;
+    if (callStack)
+        callStackValue = callStack->buildInspectorArray();
+    else
+        callStackValue = InspectorArray::create();
+
+    m_frontend->willSendRequest(static_cast<int>(identifier), loaderObject, buildObjectForResourceRequest(request), buildObjectForResourceResponse(redirectResponse), currentTime(), callStackValue);
 }
 
 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier)
@@ -480,18 +462,18 @@ void InspectorResourceAgent::didCreateWebSocket(unsigned long identifier, const
 void InspectorResourceAgent::willSendWebSocketHandshakeRequest(unsigned long identifier, const WebSocketHandshakeRequest& request)
 {
     RefPtr<InspectorObject> requestObject = InspectorObject::create();
-    requestObject->setObject("webSocketHeaderFields", buildObjectForHeaders(request.headerFields()));
-    requestObject->setString("webSocketRequestKey3", createReadableStringFromBinary(request.key3().value, sizeof(request.key3().value)));
+    requestObject->setObject("headers", buildObjectForHeaders(request.headerFields()));
+    requestObject->setString("requestKey3", createReadableStringFromBinary(request.key3().value, sizeof(request.key3().value)));
     m_frontend->willSendWebSocketHandshakeRequest(static_cast<int>(identifier), currentTime(), requestObject);
 }
 
 void InspectorResourceAgent::didReceiveWebSocketHandshakeResponse(unsigned long identifier, const WebSocketHandshakeResponse& response)
 {
     RefPtr<InspectorObject> responseObject = InspectorObject::create();
-    responseObject->setNumber("statusCode", response.statusCode());
+    responseObject->setNumber("status", response.statusCode());
     responseObject->setString("statusText", response.statusText());
-    responseObject->setObject("webSocketHeaderFields", buildObjectForHeaders(response.headerFields()));
-    responseObject->setString("webSocketChallengeResponse", createReadableStringFromBinary(response.challengeResponse().value, sizeof(response.challengeResponse().value)));
+    responseObject->setObject("headers", buildObjectForHeaders(response.headerFields()));
+    responseObject->setString("challengeResponse", createReadableStringFromBinary(response.challengeResponse().value, sizeof(response.challengeResponse().value)));
     m_frontend->didReceiveWebSocketHandshakeResponse(static_cast<int>(identifier), currentTime(), responseObject);
 }
 
@@ -544,6 +526,11 @@ void InspectorResourceAgent::resourceContent(ErrorString*, const String& frameId
         *success = InspectorResourceAgent::resourceContent(frame, KURL(ParsedURLString, url), content);
 }
 
+void InspectorResourceAgent::setExtraHeaders(ErrorString*, PassRefPtr<InspectorObject> headers)
+{
+    m_state->setObject(ResourceAgentState::extraRequestHeaders, headers);
+}
+
 InspectorResourceAgent::InspectorResourceAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* state)
     : m_instrumentingAgents(instrumentingAgents)
     , m_page(page)
index 6c4e05b..fb3aeb6 100644 (file)
@@ -88,8 +88,7 @@ public:
 
     ~InspectorResourceAgent();
 
-    void identifierForInitialRequest(unsigned long identifier, const KURL&, DocumentLoader*);
-    void willSendRequest(unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
+    void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
     void markResourceAsCached(unsigned long identifier);
     void didReceiveResponse(unsigned long identifier, DocumentLoader* laoder, const ResourceResponse&);
     void didReceiveContentLength(unsigned long identifier, int dataLength, int lengthReceived);
index 6f61fdb..ff47ed4 100644 (file)
@@ -144,7 +144,6 @@ PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceReceiveResponse
     data->setNumber("identifier", identifier);
     data->setNumber("statusCode", response.httpStatusCode());
     data->setString("mimeType", response.mimeType());
-    data->setNumber("expectedContentLength", response.expectedContentLength());
     return data.release();
 }
 
index 5fc85ca..a997bdc 100644 (file)
@@ -90,75 +90,53 @@ WebInspector.NetworkDispatcher = function(resourceTreeModel, manager)
 WebInspector.NetworkDispatcher.prototype = {
     _updateResourceWithRequest: function(resource, request)
     {
-        resource.requestMethod = request.httpMethod;
-        resource.requestHeaders = request.httpHeaderFields;
-        resource.requestFormData = request.requestFormData;
+        resource.requestMethod = request.method;
+        resource.requestHeaders = request.headers;
+        resource.requestFormData = request.postData;
     },
 
     _updateResourceWithResponse: function(resource, response)
     {
-        if (resource.isNull)
+        if (!("status" in response))
             return;
 
         resource.mimeType = response.mimeType;
-        resource.expectedContentLength = response.expectedContentLength;
-        resource.textEncodingName = response.textEncodingName;
-        resource.suggestedFilename = response.suggestedFilename;
-        resource.statusCode = response.httpStatusCode;
-        resource.statusText = response.httpStatusText;
+        resource.statusCode = response.status;
+        resource.statusText = response.statusText;
+        resource.responseHeaders = response.headers;
+        // Raw request headers can be a part of response as well.
+        if (response.requestHeaders)
+            resource.requestHeaders = response.requestHeaders;
 
-        resource.responseHeaders = response.httpHeaderFields;
         resource.connectionReused = response.connectionReused;
         resource.connectionID = response.connectionID;
 
-        if (response.wasCached)
+        if (response.fromDiskCache)
             resource.cached = true;
         else
             resource.timing = response.timing;
-
-        if (response.loadInfo) {
-            if (response.loadInfo.httpStatusCode)
-                resource.statusCode = response.loadInfo.httpStatusCode;
-            if (response.loadInfo.httpStatusText)
-                resource.statusText = response.loadInfo.httpStatusText;
-            resource.requestHeaders = response.loadInfo.requestHeaders;
-            resource.responseHeaders = response.loadInfo.responseHeaders;
-        }
     },
 
     _updateResourceWithCachedResource: function(resource, cachedResource)
     {
         resource.type = WebInspector.Resource.Type[cachedResource.type];
-        resource.resourceSize = cachedResource.encodedSize;
+        resource.resourceSize = cachedResource.bodySize;
         this._updateResourceWithResponse(resource, cachedResource.response);
     },
 
-    identifierForInitialRequest: function(identifier, url, loader, callStack)
-    {
-        this._startResource(this._createResource(identifier, url, loader, callStack));
-    },
-
-    willSendRequest: function(identifier, time, request, redirectResponse)
+    willSendRequest: function(identifier, loader, request, redirectResponse, time, callStack)
     {
         var resource = this._inflightResourcesById[identifier];
-        if (!resource)
-            return;
-
-        // Redirect may have empty URL and we'd like to not crash with invalid HashMap entry.
-        // See http/tests/misc/will-send-request-returns-null-on-redirect.html
-        var isRedirect = !redirectResponse.isNull && request.url.length;
-        if (isRedirect) {
+        if (resource) {
             this.didReceiveResponse(identifier, time, "Other", redirectResponse);
-            resource = this._appendRedirect(resource.identifier, time, request.url);
-        }
+            resource = this._appendRedirect(identifier, time, request.url);
+        } else
+            resource = this._createResource(identifier, request.url, loader, callStack);
 
         this._updateResourceWithRequest(resource, request);
         resource.startTime = time;
 
-        if (isRedirect)
-            this._startResource(resource);
-        else
-            this._updateResource(resource);
+        this._startResource(resource);
     },
 
     markResourceAsCached: function(identifier)
@@ -275,8 +253,8 @@ WebInspector.NetworkDispatcher.prototype = {
             return;
 
         resource.requestMethod = "GET";
-        resource.requestHeaders = request.webSocketHeaderFields;
-        resource.webSocketRequestKey3 = request.webSocketRequestKey3;
+        resource.requestHeaders = request.headers;
+        resource.webSocketRequestKey3 = request.requestKey3;
         resource.startTime = time;
 
         this._updateResource(resource);
@@ -288,10 +266,10 @@ WebInspector.NetworkDispatcher.prototype = {
         if (!resource)
             return;
 
-        resource.statusCode = response.statusCode;
+        resource.statusCode = response.status;
         resource.statusText = response.statusText;
-        resource.responseHeaders = response.webSocketHeaderFields;
-        resource.webSocketChallengeResponse = response.webSocketChallengeResponse;
+        resource.responseHeaders = response.headers;
+        resource.webSocketChallengeResponse = response.challengeResponse;
         resource.responseReceivedTime = time;
 
         this._updateResource(resource);
index c35d9e2..b0561c9 100644 (file)
@@ -40,6 +40,7 @@ WebInspector.NetworkPanel = function()
     this._resourcesByURL = {};
     this._staleResources = [];
     this._resourceGridNodes = {};
+    this._lastResourceGridNodeId = 0;
     this._mainResourceLoadTime = -1;
     this._mainResourceDOMContentTime = -1;
     this._hiddenCategories = {};
@@ -564,7 +565,15 @@ WebInspector.NetworkPanel.prototype = {
 
     _resourceGridNode: function(resource)
     {
-        return this._resourceGridNodes[resource.identifier];
+        return this._resourceGridNodes[resource.__gridNodeId];
+    },
+
+    _createResourceGridNode: function(resource)
+    {
+        var node = new WebInspector.NetworkDataGridNode(this, resource);
+        resource.__gridNodeId = this._lastResourceGridNodeId++;
+        this._resourceGridNodes[resource.__gridNodeId] = node;
+        return node;
     },
 
     revealAndSelectItem: function(resource)
@@ -671,8 +680,7 @@ WebInspector.NetworkPanel.prototype = {
             var node = this._resourceGridNode(resource);
             if (!node) {
                 // Create the timeline tree element and graph.
-                node = new WebInspector.NetworkDataGridNode(this, resource);
-                this._resourceGridNodes[resource.identifier] = node;
+                node = this._createResourceGridNode(resource);
                 this._dataGrid.appendChild(node);
             }
             node.refreshResource();
@@ -800,9 +808,12 @@ WebInspector.NetworkPanel.prototype = {
             return;
 
         this._reset();
+
         // Now resurrect the main resource along with all redirects that lead to it.
-        var resourcesToAppend = (WebInspector.mainResource.redirects || []).concat(WebInspector.mainResource);
-        resourcesToAppend.forEach(this._appendResource, this);
+        this._appendResource(WebInspector.mainResource);
+        var redirects = WebInspector.mainResource.redirects;
+        for (var i = 0; redirects && i < redirects.length; ++i)
+            this._appendResource(redirect);
     },
 
     canShowSourceLine: function(url, line)
index 2bf5d9f..8035fd8 100644 (file)
@@ -262,16 +262,6 @@ WebInspector.Resource.prototype = {
         this._transferSize = (this._transferSize || 0) + x;
     },
 
-    get expectedContentLength()
-    {
-        return this._expectedContentLength || 0;
-    },
-
-    set expectedContentLength(x)
-    {
-        this._expectedContentLength = x;
-    },
-
     get finished()
     {
         return this._finished;
index dd8963a..afa6ec0 100644 (file)
@@ -985,8 +985,6 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = {
                     contentHelper._appendTextRow(WebInspector.UIString("Status Code"), this.data.statusCode);
                 if (this.data.mimeType)
                     contentHelper._appendTextRow(WebInspector.UIString("MIME Type"), this.data.mimeType);
-                if (typeof this.data.expectedContentLength === "number" && this.data.expectedContentLength !== -1)
-                    contentHelper._appendTextRow(WebInspector.UIString("Expected Content Length"), this.data.expectedContentLength);
                 break;
             case recordTypes.EvaluateScript:
                 if (this.data && this.data.url)
index 4d6ce4a..0896e04 100644 (file)
@@ -103,8 +103,6 @@ void ResourceLoadNotifier::didFailToLoad(ResourceLoader* loader, const ResourceE
 void ResourceLoadNotifier::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
 {
     m_frame->loader()->client()->assignIdentifierToInitialRequest(identifier, loader, request);
-
-    InspectorInstrumentation::identifierForInitialRequest(m_frame, identifier, loader, request);
 }
 
 void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
@@ -118,7 +116,7 @@ void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsig
     if (!request.isNull() && oldRequestURL != request.url().string().impl())
         m_frame->loader()->documentLoader()->didTellClientAboutLoad(request.url());
 
-    InspectorInstrumentation::willSendRequest(m_frame, identifier, request, redirectResponse);
+    InspectorInstrumentation::willSendRequest(m_frame, identifier, loader, request, redirectResponse);
 
     // Report WebTiming for all frames.
     if (loader && !request.isNull() && request.url() == loader->requestURL())
index d3075e4..669740c 100644 (file)
@@ -474,9 +474,8 @@ PassRefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const KUR
     // Because willSendRequest only gets called during redirects, we initialize
     // the identifier and the first willSendRequest here.
     m_currentResourceIdentifier = m_frame->page()->progress()->createUniqueIdentifier();
-    InspectorInstrumentation::identifierForInitialRequest(m_frame, m_currentResourceIdentifier, m_frame->loader()->documentLoader(), handle->firstRequest());
     ResourceResponse redirectResponse = ResourceResponse();
-    InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifier, request, redirectResponse);
+    InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifier, m_frame->loader()->documentLoader(), request, redirectResponse);
 #endif
     return handle;
 }
index 0591a7e..3d46f24 100644 (file)
@@ -1,3 +1,16 @@
+2011-03-24  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: brush up Network agent API.
+        https://bugs.webkit.org/show_bug.cgi?id=57001
+
+        * public/WebDevToolsAgent.h:
+        * src/WebDevToolsAgentImpl.cpp:
+        (WebKit::WebDevToolsAgentImpl::identifierForInitialRequest):
+        (WebKit::WebDevToolsAgentImpl::willSendRequest):
+        * src/WebDevToolsAgentImpl.h:
+
 2011-03-24  Noel Gordon  <noel.gordon@gmail.com>
 
         Reviewed by Ojan Vafai.
index cac5f83..df0ab9b 100644 (file)
@@ -89,8 +89,11 @@ public:
     // while on a breakpoint.
     WEBKIT_API static void setMessageLoopDispatchHandler(MessageLoopDispatchHandler);
 
-    virtual void identifierForInitialRequest(unsigned long resourceId, WebFrame*, const WebURLRequest&) = 0;
-    virtual void willSendRequest(unsigned long resourceId, WebURLRequest&) = 0;
+    // FIXME: remove once not used downstream.
+    virtual void identifierForInitialRequest(unsigned long resourceId, WebFrame*, const WebURLRequest&);
+    virtual void willSendRequest(unsigned long resourceId, WebURLRequest&);
+
+    virtual void willSendRequest(unsigned long resourceId, WebFrame*, WebURLRequest&) = 0;
     virtual void didReceiveData(unsigned long resourceId, int length) = 0;
     virtual void didReceiveResponse(unsigned long resourceId, const WebURLResponse&) = 0;
     virtual void didFinishLoading(unsigned long resourceId) = 0;
index c018d66..4a4414b 100644 (file)
@@ -250,24 +250,28 @@ Frame* WebDevToolsAgentImpl::mainFrame()
 
 
 //------- plugin resource load notifications ---------------
-void WebDevToolsAgentImpl::identifierForInitialRequest(
-    unsigned long resourceId,
-    WebFrame* webFrame,
-    const WebURLRequest& request)
+
+// FIXME: remove once not user downstream.
+
+static WebFrame* lastWebFrame;
+
+void WebDevToolsAgentImpl::identifierForInitialRequest(unsigned long resourceId, WebFrame* webFrame, const WebURLRequest&)
 {
-    WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(webFrame);
-    Frame* frame = webFrameImpl->frame();
-    DocumentLoader* loader = frame->loader()->activeDocumentLoader();
-    InspectorInstrumentation::identifierForInitialRequest(frame, resourceId, loader, request.toResourceRequest());
+    lastWebFrame = webFrame;
 }
 
 void WebDevToolsAgentImpl::willSendRequest(unsigned long resourceId, WebURLRequest& request)
 {
-    if (InspectorController* ic = inspectorController()) {
-        InspectorInstrumentation::willSendRequest(mainFrame(), resourceId, request.toMutableResourceRequest(), ResourceResponse());
-        if (ic->hasFrontend() && request.reportLoadTiming())
-            request.setReportRawHeaders(true);
-    }
+    // We know that identifierForInitialRequest and willSendRequest are called synchronously.
+    willSendRequest(resourceId, lastWebFrame, request);
+}
+
+void WebDevToolsAgentImpl::willSendRequest(unsigned long resourceId, WebFrame* webFrame, WebURLRequest& request)
+{
+    WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(webFrame);
+    Frame* frame = webFrameImpl->frame();
+    DocumentLoader* loader = frame->loader()->activeDocumentLoader();
+    InspectorInstrumentation::willSendRequest(mainFrame(), resourceId, loader, request.toMutableResourceRequest(), ResourceResponse());
 }
 
 void WebDevToolsAgentImpl::didReceiveData(unsigned long resourceId, int length)
index b639a1b..2b88d78 100644 (file)
@@ -79,8 +79,11 @@ public:
     virtual void setRuntimeProperty(const WebString& name, const WebString& value);
     virtual void setTimelineProfilingEnabled(bool enable);
 
-    virtual void identifierForInitialRequest(unsigned long, WebFrame*, const WebURLRequest&);
-    virtual void willSendRequest(unsigned long, WebURLRequest&);
+    // FIXME: remove once not used.
+    virtual void identifierForInitialRequest(unsigned long resourceId, WebFrame*, const WebURLRequest&);
+    virtual void willSendRequest(unsigned long resourceId, WebURLRequest&);
+
+    virtual void willSendRequest(unsigned long, WebFrame*, WebURLRequest&);
     virtual void didReceiveData(unsigned long, int length);
     virtual void didReceiveResponse(unsigned long, const WebURLResponse&);
     virtual void didFinishLoading(unsigned long);