Commit 1060ac80 authored by Eugene Ostroukhov's avatar Eugene Ostroukhov Committed by Commit Bot

DevTools: ensure request time is never negative.

1. Do not initialize 'receive' timestamp with -1. Quoting
   the spec: "The send, wait and receive timings are not optional
   and must have non-negative values."
2. Account for a possibility of blocked, dns, connect and ssl fields
   beeing -1.

Bug: 760547
Change-Id: I82693812a2f7aea1edfea53d85212e0f09d43360
Reviewed-on: https://chromium-review.googlesource.com/835471Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Commit-Queue: Eugene Ostroukhov <eostroukhov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526883}
parent 98676f6e
......@@ -62,8 +62,10 @@ NetworkLog.HAREntry = class {
ipAddress = ipAddress.substr(0, portPositionInString);
var timings = this._buildTimings();
var time = 0;
// "ssl" is included in the connect field, so do not double count it.
var time = timings.blocked + timings.dns + timings.connect + timings.send + timings.wait + timings.receive;
for (var t of [timings.blocked, timings.dns, timings.connect, timings.send, timings.wait, timings.receive])
time += Math.max(t, 0);
var entry = {
startedDateTime: NetworkLog.HARLog.pseudoWallTime(this._request, this._request.issueTime()),
......@@ -153,7 +155,7 @@ NetworkLog.HAREntry = class {
var issueTime = this._request.issueTime();
var startTime = this._request.startTime;
var result = {blocked: -1, dns: -1, ssl: -1, connect: -1, send: 0, wait: 0, receive: -1, _blocked_queueing: -1};
var result = {blocked: -1, dns: -1, ssl: -1, connect: -1, send: 0, wait: 0, receive: 0, _blocked_queueing: -1};
var queuedTime = (issueTime < startTime) ? startTime - issueTime : -1;
result.blocked = queuedTime;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment