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

Unified Diff: net/base/network_quality_estimator.cc

Issue 1162293004: Use request start time for estimating network quality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/network_quality_estimator.cc
diff --git a/net/base/network_quality_estimator.cc b/net/base/network_quality_estimator.cc
index 6415ee6e6d7eb36b47ab4fd568d3537283b27729..cf3fdacf3d0bd26304a3f0c2ef4e18860adf75dc 100644
--- a/net/base/network_quality_estimator.cc
+++ b/net/base/network_quality_estimator.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
+#include "net/base/load_timing_info.h"
#include "net/base/net_util.h"
#include "net/base/network_quality.h"
#include "net/url_request/url_request.h"
@@ -52,22 +53,49 @@ void NetworkQualityEstimator::NotifyDataReceived(const URLRequest& request,
}
base::TimeTicks now = base::TimeTicks::Now();
- base::TimeDelta request_duration = now - request.creation_time();
- DCHECK_GE(request_duration, base::TimeDelta());
+
+ LoadTimingInfo load_timing_info;
+ request.GetLoadTimingInfo(&load_timing_info);
+
+ // Time when the resource was requested. Use the timings from LoadTimingInfo,
+ // if it is available since it is recorded after DNS is resolved and secure
bengr 2015/06/11 00:22:58 secure -> a secure
tbansal1 2015/06/11 03:01:36 Done.
+ // connection is established.
+ base::TimeTicks request_start_time = !load_timing_info.send_start.is_null()
+ ? load_timing_info.send_start
+ : request.creation_time();
+ DCHECK(!request_start_time.is_null());
+
+ // Time when the headers were received. Use timings from LoadTimingInfo, if
bengr 2015/06/11 00:22:58 Are they available at this point? When wouldn't th
tbansal1 2015/06/11 03:01:35 I think they are MOSTLY available, except for one
+ // available.
+ base::TimeTicks headers_received_time =
+ !load_timing_info.receive_headers_end.is_null()
+ ? load_timing_info.receive_headers_end
+ : now;
+ DCHECK(!headers_received_time.is_null());
+
+ // Duration between when the resource was requested and when response headers
+ // were received.
+ base::TimeDelta observed_rtt = headers_received_time - request_start_time;
+ DCHECK_GE(observed_rtt, base::TimeDelta());
+
+ // Time since the resource was requested.
+ base::TimeDelta since_request_start = now - request_start_time;
+ DCHECK_GE(since_request_start, base::TimeDelta());
+
if (!bytes_read_since_last_connection_change_)
- fastest_RTT_since_last_connection_change_ = request_duration;
+ fastest_RTT_since_last_connection_change_ = observed_rtt;
bytes_read_since_last_connection_change_ = true;
- if (request_duration < fastest_RTT_since_last_connection_change_)
- fastest_RTT_since_last_connection_change_ = request_duration;
+ if (observed_rtt < fastest_RTT_since_last_connection_change_)
+ fastest_RTT_since_last_connection_change_ = observed_rtt;
// Ignore tiny transfers which will not produce accurate rates.
// Ignore short duration transfers.
if (prefilter_bytes_read >= kMinTransferSizeInBytes &&
- request_duration >=
+ since_request_start >=
base::TimeDelta::FromMicroseconds(kMinRequestDurationMicroseconds)) {
uint64_t kbps = static_cast<uint64_t>(prefilter_bytes_read * 8 * 1000 /
- request_duration.InMicroseconds());
+ since_request_start.InMicroseconds());
if (kbps > peak_kbps_since_last_connection_change_)
peak_kbps_since_last_connection_change_ = kbps;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698