Commit 74241eab authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Expand the function in NQE to determine cause of crash

Expand an existing function in network quality
estimator (NQE) to more accurately determine the cause
of crash. This CL does not make any functionality change.

Bug: 899808
Change-Id: I77c8aa07ca23ea92f99775a36393431f4ebf8cb4
Reviewed-on: https://chromium-review.googlesource.com/c/1319339Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605742}
parent 83ff91b0
...@@ -1478,7 +1478,7 @@ void NetworkQualityEstimator::OnNewThroughputObservationAvailable( ...@@ -1478,7 +1478,7 @@ void NetworkQualityEstimator::OnNewThroughputObservationAvailable(
AddAndNotifyObserversOfThroughput(throughput_observation); AddAndNotifyObserversOfThroughput(throughput_observation);
} }
void NetworkQualityEstimator::MaybeComputeEffectiveConnectionType() { bool NetworkQualityEstimator::ShouldComputeEffectiveConnectionType() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
const base::TimeTicks now = tick_clock_->NowTicks(); const base::TimeTicks now = tick_clock_->NowTicks();
...@@ -1488,27 +1488,49 @@ void NetworkQualityEstimator::MaybeComputeEffectiveConnectionType() { ...@@ -1488,27 +1488,49 @@ void NetworkQualityEstimator::MaybeComputeEffectiveConnectionType() {
// computation. Strict inequalities are used to ensure that effective // computation. Strict inequalities are used to ensure that effective
// connection type is recomputed on connection change events even if the clock // connection type is recomputed on connection change events even if the clock
// has not updated. // has not updated.
if (now - last_effective_connection_type_computation_ < if (now - last_effective_connection_type_computation_ >=
effective_connection_type_recomputation_interval_ && effective_connection_type_recomputation_interval_) {
last_connection_change_ < last_effective_connection_type_computation_ && return true;
// Recompute the effective connection type if the previously computed }
// effective connection type was unknown.
effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN && if (last_connection_change_ >= last_effective_connection_type_computation_) {
// Recompute the effective connection type if the number of samples return true;
// available now are 50% more than the number of samples that were }
// available when the effective connection type was last computed.
rtt_observations_size_at_last_ect_computation_ * 1.5 >= // Recompute the effective connection type if the previously computed
(rtt_ms_observations_[nqe::internal::OBSERVATION_CATEGORY_HTTP] // effective connection type was unknown.
.Size() + if (effective_connection_type_ == EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
rtt_ms_observations_[nqe::internal::OBSERVATION_CATEGORY_TRANSPORT] return true;
.Size()) && }
throughput_observations_size_at_last_ect_computation_ * 1.5 >=
http_downstream_throughput_kbps_observations_.Size() && // Recompute the effective connection type if the number of samples
(new_rtt_observations_since_last_ect_computation_ + // available now are 50% more than the number of samples that were
new_throughput_observations_since_last_ect_computation_) < // available when the effective connection type was last computed.
params_->count_new_observations_received_compute_ect()) { if (rtt_observations_size_at_last_ect_computation_ * 1.5 <
return; (rtt_ms_observations_[nqe::internal::OBSERVATION_CATEGORY_HTTP].Size() +
rtt_ms_observations_[nqe::internal::OBSERVATION_CATEGORY_TRANSPORT]
.Size())) {
return true;
}
if (throughput_observations_size_at_last_ect_computation_ * 1.5 <
http_downstream_throughput_kbps_observations_.Size()) {
return true;
}
if ((new_rtt_observations_since_last_ect_computation_ +
new_throughput_observations_since_last_ect_computation_) >=
params_->count_new_observations_received_compute_ect()) {
return true;
} }
return false;
}
void NetworkQualityEstimator::MaybeComputeEffectiveConnectionType() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!ShouldComputeEffectiveConnectionType())
return;
ComputeEffectiveConnectionType(); ComputeEffectiveConnectionType();
} }
......
...@@ -461,8 +461,11 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator ...@@ -461,8 +461,11 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
// Returns true only if the |request| can be used for RTT estimation. // Returns true only if the |request| can be used for RTT estimation.
bool RequestProvidesRTTObservation(const URLRequest& request) const; bool RequestProvidesRTTObservation(const URLRequest& request) const;
// Recomputes effective connection type, if it was computed more than the // Returns true if ECT should be recomputed.
// specified duration ago, or if there has been a connection change recently. bool ShouldComputeEffectiveConnectionType() const;
// Calls ShouldComputeEffectiveConnectionType() to determine if ECT needs to
// be computed. If so, it recomputes effective connection type.
void MaybeComputeEffectiveConnectionType(); void MaybeComputeEffectiveConnectionType();
// Notifies observers of a change in effective connection type. // Notifies observers of a change in effective connection type.
......
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