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

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

Issue 2214163002: Revert of Expose effective connection type to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « net/nqe/effective_connection_type.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1636
1637 void NetworkQualityEstimator::MaybeRecomputeEffectiveConnectionType() { 1637 void NetworkQualityEstimator::MaybeRecomputeEffectiveConnectionType() {
1638 DCHECK(thread_checker_.CalledOnValidThread()); 1638 DCHECK(thread_checker_.CalledOnValidThread());
1639 1639
1640 const base::TimeTicks now = tick_clock_->NowTicks(); 1640 const base::TimeTicks now = tick_clock_->NowTicks();
1641 // Recompute effective connection type only if 1641 // Recompute effective connection type only if
1642 // |effective_connection_type_recomputation_interval_| has passed since it was 1642 // |effective_connection_type_recomputation_interval_| has passed since it was
1643 // last computed or a connection change event was observed since the last 1643 // last computed or a connection change event was observed since the last
1644 // computation. Strict inequalities are used to ensure that effective 1644 // computation. Strict inequalities are used to ensure that effective
1645 // connection type is recomputed on connection change events even if the clock 1645 // connection type is recomputed on connection change events even if the clock
1646 // has not updated. Recompute the effective connection type if the effective 1646 // has not updated.
1647 // connection type was previously unavailable. This is because the RTT
1648 // observations are voluminous, so it may now be possible to compute the
1649 // effective connection type.
1650 if (now - last_effective_connection_type_computation_ < 1647 if (now - last_effective_connection_type_computation_ <
1651 effective_connection_type_recomputation_interval_ && 1648 effective_connection_type_recomputation_interval_ &&
1652 last_connection_change_ < last_effective_connection_type_computation_ && 1649 last_connection_change_ < last_effective_connection_type_computation_) {
1653 effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
1654 return; 1650 return;
1655 } 1651 }
1656 1652
1657 const EffectiveConnectionType past_type = effective_connection_type_; 1653 const EffectiveConnectionType past_type = effective_connection_type_;
1658 last_effective_connection_type_computation_ = now; 1654 last_effective_connection_type_computation_ = now;
1659 effective_connection_type_ = GetEffectiveConnectionType(); 1655 effective_connection_type_ = GetEffectiveConnectionType();
1660 1656
1661 if (past_type != effective_connection_type_) 1657 if (past_type != effective_connection_type_)
1662 NotifyObserversOfEffectiveConnectionTypeChanged(); 1658 NotifyObserversOfEffectiveConnectionTypeChanged();
1663 } 1659 }
1664 1660
1665 void NetworkQualityEstimator:: 1661 void NetworkQualityEstimator::
1666 NotifyObserversOfEffectiveConnectionTypeChanged() { 1662 NotifyObserversOfEffectiveConnectionTypeChanged() {
1667 DCHECK(thread_checker_.CalledOnValidThread()); 1663 DCHECK(thread_checker_.CalledOnValidThread());
1668 DCHECK_NE(EFFECTIVE_CONNECTION_TYPE_LAST, effective_connection_type_);
1669 1664
1670 // TODO(tbansal): Add hysteresis in the notification. 1665 // TODO(tbansal): Add hysteresis in the notification.
1671 FOR_EACH_OBSERVER( 1666 FOR_EACH_OBSERVER(
1672 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, 1667 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_,
1673 OnEffectiveConnectionTypeChanged(effective_connection_type_)); 1668 OnEffectiveConnectionTypeChanged(effective_connection_type_));
1674 } 1669 }
1675 1670
1676 } // namespace net 1671 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/effective_connection_type.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698