| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |