Chromium Code Reviews| Index: net/base/network_quality_estimator.cc |
| diff --git a/net/base/network_quality_estimator.cc b/net/base/network_quality_estimator.cc |
| index e864c7e1f4619501fb8ce7073545f6f4c3ab7752..63b4afd86625d010ac5bea1c98522a5e24e19b3f 100644 |
| --- a/net/base/network_quality_estimator.cc |
| +++ b/net/base/network_quality_estimator.cc |
| @@ -9,6 +9,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" |
| @@ -63,25 +64,50 @@ void NetworkQualityEstimator::NotifyDataReceived( |
| } |
| 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 a secure |
| + // connection is established. |
| + base::TimeTicks request_start_time = !load_timing_info.send_start.is_null() |
|
mmenke
2015/06/15 17:21:00
Hrm...If load_timing_info.send_start or load_timin
tbansal1
2015/06/15 18:57:11
QUIC still has these 2 values populated. I checked
|
| + ? 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 |
| + // 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()); |
|
mmenke
2015/06/15 17:21:00
This is only used in the body of the next if state
tbansal1
2015/06/15 18:57:11
Done.
|
| + |
| + // Time since the resource was requested. |
| + base::TimeDelta since_request_start = now - request_start_time; |
| + DCHECK_GE(since_request_start, base::TimeDelta()); |
| // Only add RTT observation if this is the first read for this response. |
| if (cumulative_prefilter_bytes_read == prefiltered_bytes_read) { |
| - 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; |
| rtt_msec_observations_.AddObservation( |
| - Observation(request_duration.InMilliseconds(), now)); |
| + Observation(observed_rtt.InMilliseconds(), now)); |
| } |
| // Ignore tiny transfers which will not produce accurate rates. |
| // Ignore short duration transfers. |
| if (cumulative_prefilter_bytes_read >= kMinTransferSizeInBytes && |
| - request_duration >= |
| + since_request_start >= |
| base::TimeDelta::FromMicroseconds(kMinRequestDurationMicroseconds)) { |
| double kbps_f = cumulative_prefilter_bytes_read * 8.0 / 1000.0 / |
| - request_duration.InSecondsF(); |
| + since_request_start.InSecondsF(); |
| DCHECK_GE(kbps_f, 0.0); |
| // Check overflow errors. This may happen if the kbpsF is more than |