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

Side by Side Diff: net/nqe/network_quality_estimator.cc

Issue 2223773003: Expose effective connection type to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes based on https://codereview.chromium.org/2210633002/ Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/nqe/network_quality_estimator.h" 5 #include "net/nqe/network_quality_estimator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 1640
1641 void NetworkQualityEstimator::MaybeRecomputeEffectiveConnectionType() { 1641 void NetworkQualityEstimator::MaybeRecomputeEffectiveConnectionType() {
1642 DCHECK(thread_checker_.CalledOnValidThread()); 1642 DCHECK(thread_checker_.CalledOnValidThread());
1643 1643
1644 const base::TimeTicks now = tick_clock_->NowTicks(); 1644 const base::TimeTicks now = tick_clock_->NowTicks();
1645 // Recompute effective connection type only if 1645 // Recompute effective connection type only if
1646 // |effective_connection_type_recomputation_interval_| has passed since it was 1646 // |effective_connection_type_recomputation_interval_| has passed since it was
1647 // last computed or a connection change event was observed since the last 1647 // last computed or a connection change event was observed since the last
1648 // computation. Strict inequalities are used to ensure that effective 1648 // computation. Strict inequalities are used to ensure that effective
1649 // connection type is recomputed on connection change events even if the clock 1649 // connection type is recomputed on connection change events even if the clock
1650 // has not updated. 1650 // has not updated. Recompute the effective connection type if the effective
1651 // connection type was previously unavailable. This is because the RTT
1652 // observations are voluminous, so it may now be possible to compute the
1653 // effective connection type.
1651 if (now - last_effective_connection_type_computation_ < 1654 if (now - last_effective_connection_type_computation_ <
1652 effective_connection_type_recomputation_interval_ && 1655 effective_connection_type_recomputation_interval_ &&
1653 last_connection_change_ < last_effective_connection_type_computation_) { 1656 last_connection_change_ < last_effective_connection_type_computation_ &&
1657 effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
1654 return; 1658 return;
1655 } 1659 }
1656 1660
1657 const EffectiveConnectionType past_type = effective_connection_type_; 1661 const EffectiveConnectionType past_type = effective_connection_type_;
1658 last_effective_connection_type_computation_ = now; 1662 last_effective_connection_type_computation_ = now;
1659 effective_connection_type_ = GetEffectiveConnectionType(); 1663 effective_connection_type_ = GetEffectiveConnectionType();
1660 1664
1661 if (past_type != effective_connection_type_) 1665 if (past_type != effective_connection_type_)
1662 NotifyObserversOfEffectiveConnectionTypeChanged(); 1666 NotifyObserversOfEffectiveConnectionTypeChanged();
1663 } 1667 }
1664 1668
1665 void NetworkQualityEstimator:: 1669 void NetworkQualityEstimator::
1666 NotifyObserversOfEffectiveConnectionTypeChanged() { 1670 NotifyObserversOfEffectiveConnectionTypeChanged() {
1667 DCHECK(thread_checker_.CalledOnValidThread()); 1671 DCHECK(thread_checker_.CalledOnValidThread());
1672 DCHECK_NE(EFFECTIVE_CONNECTION_TYPE_LAST, effective_connection_type_);
1668 1673
1669 // TODO(tbansal): Add hysteresis in the notification. 1674 // TODO(tbansal): Add hysteresis in the notification.
1670 FOR_EACH_OBSERVER( 1675 FOR_EACH_OBSERVER(
1671 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, 1676 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_,
1672 OnEffectiveConnectionTypeChanged(effective_connection_type_)); 1677 OnEffectiveConnectionTypeChanged(effective_connection_type_));
1673 } 1678 }
1674 1679
1675 } // namespace net 1680 } // namespace net
OLDNEW
« net/nqe/effective_connection_type.h ('K') | « net/nqe/effective_connection_type.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698