Chromium Code Reviews| 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..aa3126948c42f388a63eb2e08253616f798111c3 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,41 @@ 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) |
| + { |
| + for (var i = 0; i < events.length; ++i) { |
| + if (timing[events[i]] >= 0) |
| + return timing[events[i]]; |
| + } |
| + return -1; |
| + } |
| + |
| + var blocked = nextEventTime(["dnsStart", "connectStart", "sendStart"]); |
| + |
| + var dns = -1; |
| + if (timing.dnsStart > -1) |
|
caseq
2013/09/17 16:56:22
nit: >= 0
eustas
2013/09/18 05:32:10
Done.
|
| + dns = nextEventTime(["connectStart", "sendStart"]) - timing.dnsStart; |
|
caseq
2013/09/17 16:56:22
So, is it possible for us to have dns time while n
eustas
2013/09/18 05:32:10
Not sure. I've tried to avoid any assumptions here
|
| + |
| var connect = -1; |
| + if (timing.connectStart > -1) |
|
caseq
2013/09/17 16:56:22
as discussed, >= 0
eustas
2013/09/18 05:32:10
Done.
|
| + connect = timing.sendStart - timing.connectStart; |
| - if (this._request.connectionReused) |
| - blocked = waitForConnection; |
| - else |
| - connect = waitForConnection; |
| + var send = timing.sendEnd - timing.sendStart; |
| + var wait = timing.receiveHeadersEnd - timing.sendEnd; |
| + var receive = WebInspector.HAREntry._toMilliseconds(this._request.duration) - 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) |
|
caseq
2013/09/17 16:56:22
as discussed, >= 0
eustas
2013/09/18 05:32:10
Done.
|
| + ssl = timing.sslEnd - timing.sslStart; |
| + |
| + return {blocked: blocked, dns: dns, connect: connect, send: send, wait: wait, receive: receive, ssl: ssl}; |
| }, |
| /** |
| @@ -204,20 +222,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() |
| @@ -252,7 +256,7 @@ WebInspector.HAREntry.prototype = { |
| */ |
| WebInspector.HAREntry._toMilliseconds = function(time) |
| { |
| - return time === -1 ? -1 : Math.round(time * 1000); |
| + return time === -1 ? -1 : time * 1000; |
| } |
| /** |