Source/WebCore: Web Inspector: Add data length to resource events on timeline to
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jun 2012 21:57:24 +0000 (21:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Jun 2012 21:57:24 +0000 (21:57 +0000)
keep track of the amount of data loaded and the total data length
https://bugs.webkit.org/show_bug.cgi?id=89244

Patch by Hanna Ma <Hanma@rim.com> on 2012-06-29
Reviewed by Pavel Feldman.

Added data length to inspector timeline popup
content for resources to keep track of the amount of data loaded.
Tests: inspector/timeline/timeline-network-received-data.html

* English.lproj/localizedStrings.js:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willReceiveResourceDataImpl):
* inspector/InspectorInstrumentation.h:
(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::willReceiveResourceData):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::willReceiveResourceData):
* inspector/InspectorTimelineAgent.h:
(InspectorTimelineAgent):
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::createReceiveResourceData):
* inspector/TimelineRecordFactory.h:
(TimelineRecordFactory):
* inspector/front-end/TimelinePanel.js:
(WebInspector.TimelinePanel.prototype._showPopover):
* inspector/front-end/TimelinePresentationModel.js:
(WebInspector.TimelinePresentationModel.prototype.reset):
(WebInspector.TimelinePresentationModel.Record):
(WebInspector.TimelinePresentationModel.Record.prototype.generatePopupContent):
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::didReceiveData):
* inspector/timeline/timeline-network-received-data.html: Added.
* inspector/timeline/timeline-network-received-data-expected.txt: Added.
* inspector/timeline/timeline-test.js:

LayoutTests: Web Inspector: Add data length to resource events on timeline to
keep track of the amount of data loaded and the total data length.
https://bugs.webkit.org/show_bug.cgi?id=89244

Patch by Hanna Ma <Hanma@rim.com> on 2012-06-29
Reviewed by Pavel Feldman.

Added tests for resource receive data events.

* inspector/timeline/timeline-network-received-data-expected.txt: Added.
* inspector/timeline/timeline-network-received-data.html: Added.
* inspector/timeline/timeline-test.js:

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/timeline/timeline-network-received-data-expected.txt [new file with mode: 0644]
LayoutTests/inspector/timeline/timeline-network-received-data.html [new file with mode: 0644]
LayoutTests/inspector/timeline/timeline-test.js
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebCore/inspector/TimelineRecordFactory.cpp
Source/WebCore/inspector/TimelineRecordFactory.h
Source/WebCore/inspector/front-end/TimelinePresentationModel.js
Source/WebCore/loader/ResourceLoader.cpp

index 1327704..c448a19 100644 (file)
@@ -1,3 +1,17 @@
+2012-06-29  Hanna Ma  <Hanma@rim.com>
+
+        Web Inspector: Add data length to resource events on timeline to
+        keep track of the amount of data loaded and the total data length.
+        https://bugs.webkit.org/show_bug.cgi?id=89244
+
+        Reviewed by Pavel Feldman.
+
+        Added tests for resource receive data events.
+
+        * inspector/timeline/timeline-network-received-data-expected.txt: Added.
+        * inspector/timeline/timeline-network-received-data.html: Added.
+        * inspector/timeline/timeline-test.js:
+
 2012-06-29  Emil A Eklund  <eae@chromium.org>
 
         Unreviewed chromium xp rebaseline.
diff --git a/LayoutTests/inspector/timeline/timeline-network-received-data-expected.txt b/LayoutTests/inspector/timeline/timeline-network-received-data-expected.txt
new file mode 100644 (file)
index 0000000..0cf0e34
--- /dev/null
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 7: Script evaluated
+Tests the Timeline API instrumentation of a network resource received data
+
+Script resource loaded
+Resource received data has length, test passed.
+
diff --git a/LayoutTests/inspector/timeline/timeline-network-received-data.html b/LayoutTests/inspector/timeline/timeline-network-received-data.html
new file mode 100644 (file)
index 0000000..4b8ccff
--- /dev/null
@@ -0,0 +1,57 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="timeline-test.js"></script>
+<script>
+
+var scriptUrl = "timeline-network-resource.js";
+
+function performActions() 
+{
+    var image = new Image();
+    image.src = "resources/anImage.png";
+    var script = document.createElement("script");
+    script.src = scriptUrl;
+    document.body.appendChild(script);
+}
+
+function test()
+{
+    var scriptUrl = "timeline-network-resource.js";
+
+    var calledOnce;
+
+    InspectorTest.startTimeline(function() {
+        InspectorTest.evaluateInPage("performActions()");
+    });
+
+    InspectorTest.waitForRecordType("ResourceReceivedData", finish);
+
+    function finish(object)
+    {
+        for (var prop in object) {
+            if (!InspectorTest.timelinePropertyFormatters[prop]) {
+                for (var property in object[prop]) {
+                    if (property === "encodedDataLength") {
+                        if (!calledOnce) {
+                            calledOnce = true;
+                            InspectorTest.addResult("Resource received data has length, test passed.");
+                            InspectorTest.completeTest();
+                        }
+                        return;
+                    }
+                }
+            }
+        }
+    }
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Tests the Timeline API instrumentation of a network resource received data
+</p>
+</body>
+</html>
index d0d92f2..c0b954b 100644 (file)
@@ -19,7 +19,8 @@ InspectorTest.timelinePropertyFormatters = {
     timerId: "formatAsTypeName",
     scriptLine: "formatAsTypeName",
     lineNumber: "formatAsTypeName",
-    frameId: "formatAsTypeName"
+    frameId: "formatAsTypeName",
+    encodedDataLength: "formatAsTypeName"
 };
 
 InspectorTest.startTimeline = function(callback)
index 03e872b..d9d9f49 100644 (file)
@@ -1,3 +1,41 @@
+2012-06-29  Hanna Ma  <Hanma@rim.com>
+
+        Web Inspector: Add data length to resource events on timeline to
+        keep track of the amount of data loaded and the total data length
+        https://bugs.webkit.org/show_bug.cgi?id=89244
+
+        Reviewed by Pavel Feldman.
+
+        Added data length to inspector timeline popup
+        content for resources to keep track of the amount of data loaded.
+        Tests: inspector/timeline/timeline-network-received-data.html
+
+        * English.lproj/localizedStrings.js:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::willReceiveResourceDataImpl):
+        * inspector/InspectorInstrumentation.h:
+        (InspectorInstrumentation):
+        (WebCore::InspectorInstrumentation::willReceiveResourceData):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::willReceiveResourceData):
+        * inspector/InspectorTimelineAgent.h:
+        (InspectorTimelineAgent):
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore::TimelineRecordFactory::createReceiveResourceData):
+        * inspector/TimelineRecordFactory.h:
+        (TimelineRecordFactory):
+        * inspector/front-end/TimelinePanel.js:
+        (WebInspector.TimelinePanel.prototype._showPopover):
+        * inspector/front-end/TimelinePresentationModel.js:
+        (WebInspector.TimelinePresentationModel.prototype.reset):
+        (WebInspector.TimelinePresentationModel.Record):
+        (WebInspector.TimelinePresentationModel.Record.prototype.generatePopupContent):
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::didReceiveData):
+        * inspector/timeline/timeline-network-received-data.html: Added.
+        * inspector/timeline/timeline-network-received-data-expected.txt: Added.
+        * inspector/timeline/timeline-test.js:
+
 2012-06-29  Shawn Singh  <shawnsingh@chromium.org>
 
         Unreviewed build fix after 121580.
index 8029f3e..8f0f289 100644 (file)
@@ -706,3 +706,5 @@ localizedStrings["apply original content"] = "apply original content";
 localizedStrings["apply revision content"] = "apply revision content";
 localizedStrings["revert"] = "revert";
 localizedStrings["CPU Time"] = "CPU Time";
+localizedStrings["Encoded Data Length"] = "Encoded Data Length";
+localizedStrings["%d Bytes"] = "%d Bytes";
index a65ff7e..a7accfb 100644 (file)
@@ -629,11 +629,11 @@ void InspectorInstrumentation::didLoadResourceFromMemoryCacheImpl(InstrumentingA
         resourceAgent->didLoadResourceFromMemoryCache(loader, cachedResource);
 }
 
-InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceDataImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, Frame* frame)
+InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceDataImpl(InstrumentingAgents* instrumentingAgents, unsigned long identifier, Frame* frame, int length)
 {
     int timelineAgentId = 0;
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
-        timelineAgent->willReceiveResourceData(identifier, frame);
+        timelineAgent->willReceiveResourceData(identifier, frame, length);
         timelineAgentId = timelineAgent->id();
     }
     return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
index 1d79f24..6d17fd1 100644 (file)
@@ -165,7 +165,7 @@ public:
     static void continueAfterPingLoader(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
     static void markResourceAsCached(Page*, unsigned long identifier);
     static void didLoadResourceFromMemoryCache(Page*, DocumentLoader*, CachedResource*);
-    static InspectorInstrumentationCookie willReceiveResourceData(Frame*, unsigned long identifier);
+    static InspectorInstrumentationCookie willReceiveResourceData(Frame*, unsigned long identifier, int length);
     static void didReceiveResourceData(const InspectorInstrumentationCookie&);
     static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*, unsigned long identifier, const ResourceResponse&);
     static void didReceiveResourceResponse(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&);
@@ -330,7 +330,7 @@ private:
     static void continueAfterPingLoaderImpl(InstrumentingAgents*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
     static void markResourceAsCachedImpl(InstrumentingAgents*, unsigned long identifier);
     static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents*, DocumentLoader*, CachedResource*);
-    static InspectorInstrumentationCookie willReceiveResourceDataImpl(InstrumentingAgents*, unsigned long identifier, Frame*);
+    static InspectorInstrumentationCookie willReceiveResourceDataImpl(InstrumentingAgents*, unsigned long identifier, Frame*, int length);
     static void didReceiveResourceDataImpl(const InspectorInstrumentationCookie&);
     static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InstrumentingAgents*, unsigned long identifier, const ResourceResponse&, Frame*);
     static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&);
@@ -1014,12 +1014,12 @@ inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page* page,
 #endif
 }
 
-inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceData(Frame* frame, unsigned long identifier)
+inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceData(Frame* frame, unsigned long identifier, int length)
 {
 #if ENABLE(INSPECTOR)
     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
-        return willReceiveResourceDataImpl(instrumentingAgents, identifier, frame);
+        return willReceiveResourceDataImpl(instrumentingAgents, identifier, frame, length);
 #endif
     return InspectorInstrumentationCookie();
 }
index 47282e9..c568037 100644 (file)
@@ -346,10 +346,10 @@ void InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, c
     m_frontend->eventRecorded(record.release());
 }
 
-void InspectorTimelineAgent::willReceiveResourceData(unsigned long identifier, Frame* frame)
+void InspectorTimelineAgent::willReceiveResourceData(unsigned long identifier, Frame* frame, int length)
 {
     String requestId = IdentifiersFactory::requestId(identifier);
-    pushCurrentRecord(TimelineRecordFactory::createReceiveResourceData(requestId), TimelineRecordType::ResourceReceivedData, false, frame);
+    pushCurrentRecord(TimelineRecordFactory::createReceiveResourceData(requestId, length), TimelineRecordType::ResourceReceivedData, false, frame);
 }
 
 void InspectorTimelineAgent::didReceiveResourceData()
index 94c7fca..1898f6f 100644 (file)
@@ -130,7 +130,7 @@ public:
     void willReceiveResourceResponse(unsigned long, const ResourceResponse&, Frame*);
     void didReceiveResourceResponse();
     void didFinishLoadingResource(unsigned long, bool didFail, double finishTime, Frame*);
-    void willReceiveResourceData(unsigned long identifier, Frame*);
+    void willReceiveResourceData(unsigned long identifier, Frame*, int length);
     void didReceiveResourceData();
 
     void didRequestAnimationFrame(int callbackId, Frame*);
index 152be3a..6f3b4aa 100644 (file)
@@ -161,10 +161,11 @@ PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceFinishData(cons
     return data.release();
 }
 
-PassRefPtr<InspectorObject> TimelineRecordFactory::createReceiveResourceData(const String& requestId)
+PassRefPtr<InspectorObject> TimelineRecordFactory::createReceiveResourceData(const String& requestId, int length)
 {
     RefPtr<InspectorObject> data = InspectorObject::create();
     data->setString("requestId", requestId);
+    data->setNumber("encodedDataLength", length);
     return data.release();
 }
     
index 5d3e5ae..555f232 100644 (file)
@@ -71,7 +71,7 @@ namespace WebCore {
 
         static PassRefPtr<InspectorObject> createResourceReceiveResponseData(const String& requestId, const ResourceResponse&);
 
-        static PassRefPtr<InspectorObject> createReceiveResourceData(const String& requestId);
+        static PassRefPtr<InspectorObject> createReceiveResourceData(const String& requestId, int length);
 
         static PassRefPtr<InspectorObject> createResourceFinishData(const String& requestId, bool didFail, double finishTime);
 
index 66a77ac..cc37675 100644 (file)
@@ -515,6 +515,8 @@ WebInspector.TimelinePresentationModel.Record.prototype = {
                     contentHelper._appendTextRow(WebInspector.UIString("Status Code"), this.data["statusCode"]);
                 if (this.data["mimeType"])
                     contentHelper._appendTextRow(WebInspector.UIString("MIME Type"), this.data["mimeType"]);
+                if (this.data["encodedDataLength"])
+                    contentHelper._appendTextRow(WebInspector.UIString("Encoded Data Length"), WebInspector.UIString("%d Bytes", this.data["encodedDataLength"]));
                 break;
             case recordTypes.EvaluateScript:
                 if (this.data && this.url)
index ade00b5..5a064d0 100644 (file)
@@ -425,7 +425,7 @@ void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse&
 
 void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
 {
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_frame.get(), identifier());
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_frame.get(), identifier(), encodedDataLength);
     didReceiveData(data, length, encodedDataLength, false);
     InspectorInstrumentation::didReceiveResourceData(cookie);
 }