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

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

Issue 1991933002: Return E_C_T_OFFLINE when the device is offline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | net/nqe/network_quality_estimator_unittest.cc » ('j') | 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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 // unavailable, add the default estimates. 660 // unavailable, add the default estimates.
661 if (!ReadCachedNetworkQualityEstimate()) 661 if (!ReadCachedNetworkQualityEstimate())
662 AddDefaultEstimates(); 662 AddDefaultEstimates();
663 estimated_median_network_quality_ = nqe::internal::NetworkQuality(); 663 estimated_median_network_quality_ = nqe::internal::NetworkQuality();
664 } 664 }
665 665
666 NetworkQualityEstimator::EffectiveConnectionType 666 NetworkQualityEstimator::EffectiveConnectionType
667 NetworkQualityEstimator::GetEffectiveConnectionType() const { 667 NetworkQualityEstimator::GetEffectiveConnectionType() const {
668 DCHECK(thread_checker_.CalledOnValidThread()); 668 DCHECK(thread_checker_.CalledOnValidThread());
669 669
670 // If the device is currently offline, then return
671 // EFFECTIVE_CONNECTION_TYPE_OFFLINE.
672 if (GetCurrentNetworkID().type == NetworkChangeNotifier::CONNECTION_NONE)
673 return EFFECTIVE_CONNECTION_TYPE_OFFLINE;
674
670 base::TimeDelta url_request_rtt = nqe::internal::InvalidRTT(); 675 base::TimeDelta url_request_rtt = nqe::internal::InvalidRTT();
671 if (!GetURLRequestRTTEstimate(&url_request_rtt)) 676 if (!GetURLRequestRTTEstimate(&url_request_rtt))
672 url_request_rtt = nqe::internal::InvalidRTT(); 677 url_request_rtt = nqe::internal::InvalidRTT();
673 678
674 int32_t kbps = nqe::internal::kInvalidThroughput; 679 int32_t kbps = nqe::internal::kInvalidThroughput;
675 if (!GetDownlinkThroughputKbpsEstimate(&kbps)) 680 if (!GetDownlinkThroughputKbpsEstimate(&kbps))
676 kbps = nqe::internal::kInvalidThroughput; 681 kbps = nqe::internal::kInvalidThroughput;
677 682
678 if (url_request_rtt == nqe::internal::InvalidRTT() && 683 if (url_request_rtt == nqe::internal::InvalidRTT() &&
679 kbps == nqe::internal::kInvalidThroughput) { 684 kbps == nqe::internal::kInvalidThroughput) {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 1028
1024 void NetworkQualityEstimator::NotifyObserversOfThroughput( 1029 void NetworkQualityEstimator::NotifyObserversOfThroughput(
1025 const ThroughputObservation& observation) { 1030 const ThroughputObservation& observation) {
1026 FOR_EACH_OBSERVER( 1031 FOR_EACH_OBSERVER(
1027 ThroughputObserver, throughput_observer_list_, 1032 ThroughputObserver, throughput_observer_list_,
1028 OnThroughputObservation(observation.value, observation.timestamp, 1033 OnThroughputObservation(observation.value, observation.timestamp,
1029 observation.source)); 1034 observation.source));
1030 } 1035 }
1031 1036
1032 } // namespace net 1037 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/nqe/network_quality_estimator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698