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

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: Use response_time instead of now() 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..94119e611083829861c2d9d7d1e3435e1c6b1e3d 100644
--- a/net/base/network_quality_estimator.cc
+++ b/net/base/network_quality_estimator.cc
@@ -51,23 +51,37 @@ void NetworkQualityEstimator::NotifyDataReceived(const URLRequest& request,
return;
}
- base::TimeTicks now = base::TimeTicks::Now();
- base::TimeDelta request_duration = now - request.creation_time();
- DCHECK_GE(request_duration, base::TimeDelta());
+ base::Time now = base::Time::Now();
+
+ // Time when the resource was requested.
bengr 2015/06/09 00:18:49 Please add a comment to explain this logic.
tbansal1 2015/06/10 18:20:11 Done.
+ base::Time request_start_time = !request.request_time().is_null()
+ ? request.request_time()
+ : request.creation_time();
+
+ // Difference of when the response headers were received and when the resource
bengr 2015/06/09 00:18:49 // Duration between when the resource was requeste
tbansal1 2015/06/10 18:20:11 Done.
+ // was requested.
+ base::TimeDelta estimated_rtt =
bengr 2015/06/09 00:18:49 Maybe rename this as observed_rtt? It would be goo
tbansal1 2015/06/10 18:20:11 Done.
+ request.response_info().response_time - request_start_time;
bengr 2015/06/09 00:18:49 Can response_time be null?
tbansal1 2015/06/10 18:20:11 No, there is a check above in the "if" condition:
+ DCHECK_GE(estimated_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_ = estimated_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 (estimated_rtt < fastest_RTT_since_last_connection_change_)
+ fastest_RTT_since_last_connection_change_ = estimated_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