Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1782)

Unified Diff: Source/devtools/front_end/HAREntry.js

Issue 23308009: [DevTools] Save as HAR: classify time before network activity as "blocked". (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/NetworkRequest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/HAREntry.js
diff --git a/Source/devtools/front_end/HAREntry.js b/Source/devtools/front_end/HAREntry.js
index 51f996e5f2a90c0a70f8291a627b0eb82e7601a8..60aae6180741d2eef9b0a68e36168d18dcb497f0 100644
--- a/Source/devtools/front_end/HAREntry.js
+++ b/Source/devtools/front_end/HAREntry.js
@@ -49,14 +49,15 @@ WebInspector.HAREntry.prototype = {
*/
build: function()
{
- var entry = {
+ var entry = {
startedDateTime: new Date(this._request.startTime * 1000),
- time: WebInspector.HAREntry._toMilliseconds(this._request.duration),
+ time: this._request.timing ? WebInspector.HAREntry._toMilliseconds(this._request.duration) : 0,
request: this._buildRequest(),
response: this._buildResponse(),
cache: { }, // Not supported yet.
timings: this._buildTimings()
};
+
if (this._request.connectionId)
entry.connection = String(this._request.connectionId);
var page = WebInspector.networkLog.pageLoadForRequest(this._request);
@@ -125,24 +126,40 @@ WebInspector.HAREntry.prototype = {
*/
_buildTimings: function()
{
- var waitForConnection = this._interval("connectStart", "connectEnd");
- var blocked = 0;
+ // Order of events: request_start = 0, [proxy], [dns], [connect [ssl]], [send], receive_headers_end
+ // HAR 'blocked' time is time before first network activity.
+
+ var timing = this._request.timing;
+ if (!timing)
+ return {blocked: -1, dns: -1, connect: -1, send: 0, wait: 0, receive: 0, ssl: -1};
+
+ function nextEventTime(events) {
caseq 2013/09/13 15:24:07 style: { => next line
eustas 2013/09/16 10:06:22 Done.
+ for (var i = 0; i < events.length; ++i) {
+ if (timing[events[i]] > -1)
caseq 2013/09/13 15:24:07 nit: -1 is a "null" value, so I think it would be
eustas 2013/09/16 10:06:22 Done.
+ return Math.round(timing[events[i]]);
+ }
+ return -1;
+ }
+
+ var blocked = nextEventTime(["dnsStart", "connectStart", "sendStart"]);
+
+ var dns = -1;
+ if (timing["dnsStart"] > -1)
caseq 2013/09/13 15:24:07 Here ad below, why not timing.dnsStart? We should
eustas 2013/09/16 10:06:22 Done.
+ dns = nextEventTime(["connectStart", "sendStart"]) - Math.round(timing["dnsStart"]);
+
var connect = -1;
+ if (timing["connectStart"] > -1)
+ connect = Math.round(timing["sendStart"]) - Math.round(timing["connectStart"]);
caseq 2013/09/13 15:24:07 On a closer look to the spec, do we really have to
eustas 2013/09/16 10:06:22 Done.
- if (this._request.connectionReused)
- blocked = waitForConnection;
- else
- connect = waitForConnection;
+ var send = Math.round(timing["sendEnd"]) - Math.round(timing["sendStart"]);
caseq 2013/09/13 15:24:07 Are we intentionally counting send time from sendS
eustas 2013/09/16 10:06:22 Yes. Last event (block, dns or connect) lasts til
+ var wait = Math.round(timing["receiveHeadersEnd"]) - Math.round(timing["sendEnd"]);
+ var receive = WebInspector.HAREntry._toMilliseconds(this._request.duration) - Math.round(timing["receiveHeadersEnd"]);
- return {
- blocked: blocked,
- dns: this._interval("dnsStart", "dnsEnd"),
- connect: connect,
- send: this._interval("sendStart", "sendEnd"),
- wait: this._interval("sendEnd", "receiveHeadersEnd"),
- receive: WebInspector.HAREntry._toMilliseconds(this._request.receiveDuration),
- ssl: this._interval("sslStart", "sslEnd")
- };
+ var ssl = -1;
+ if (timing["sslStart"] > -1 && timing["sslEnd"] > -1)
+ ssl = Math.round(timing["sslEnd"]) - Math.round(timing["sslStart"]);
+
+ return {blocked: blocked, dns: dns, connect: connect, send: send, wait: wait, receive: receive, ssl: ssl};
},
/**
@@ -204,20 +221,6 @@ WebInspector.HAREntry.prototype = {
},
/**
- * @param {string} start
- * @param {string} end
- * @return {number}
- */
- _interval: function(start, end)
- {
- var timing = this._request.timing;
- if (!timing)
- return -1;
- var startTime = timing[start];
- return typeof startTime !== "number" || startTime === -1 ? -1 : Math.round(timing[end] - startTime);
- },
-
- /**
* @return {number}
*/
get requestBodySize()
« no previous file with comments | « no previous file | Source/devtools/front_end/NetworkRequest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698