| 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/base/network_quality_estimator.h" | 5 #include "net/base/network_quality_estimator.h" |
| 6 | 6 |
| 7 #include <float.h> | 7 #include <float.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 // updates estimates are available, OnUpdatedEstimateAvailable() will be | 938 // updates estimates are available, OnUpdatedEstimateAvailable() will be |
| 939 // called. | 939 // called. |
| 940 external_estimate_provider_->Update(); | 940 external_estimate_provider_->Update(); |
| 941 return; | 941 return; |
| 942 } | 942 } |
| 943 | 943 |
| 944 RecordExternalEstimateProviderMetrics( | 944 RecordExternalEstimateProviderMetrics( |
| 945 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL); | 945 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL); |
| 946 base::TimeDelta rtt; | 946 base::TimeDelta rtt; |
| 947 if (external_estimate_provider_->GetRTT(&rtt)) { | 947 if (external_estimate_provider_->GetRTT(&rtt)) { |
| 948 RecordExternalEstimateProviderMetrics( |
| 949 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE); |
| 948 rtt_observations_.AddObservation( | 950 rtt_observations_.AddObservation( |
| 949 RttObservation(rtt, base::TimeTicks::Now(), EXTERNAL_ESTIMATE)); | 951 RttObservation(rtt, base::TimeTicks::Now(), EXTERNAL_ESTIMATE)); |
| 950 } | 952 } |
| 951 | 953 |
| 952 int32_t downstream_throughput_kbps; | 954 int32_t downstream_throughput_kbps; |
| 953 if (external_estimate_provider_->GetDownstreamThroughputKbps( | 955 if (external_estimate_provider_->GetDownstreamThroughputKbps( |
| 954 &downstream_throughput_kbps)) { | 956 &downstream_throughput_kbps)) { |
| 957 RecordExternalEstimateProviderMetrics( |
| 958 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE); |
| 955 downstream_throughput_kbps_observations_.AddObservation( | 959 downstream_throughput_kbps_observations_.AddObservation( |
| 956 ThroughputObservation(downstream_throughput_kbps, | 960 ThroughputObservation(downstream_throughput_kbps, |
| 957 base::TimeTicks::Now(), EXTERNAL_ESTIMATE)); | 961 base::TimeTicks::Now(), EXTERNAL_ESTIMATE)); |
| 958 } | 962 } |
| 959 } | 963 } |
| 960 | 964 |
| 961 void NetworkQualityEstimator::CacheNetworkQualityEstimate() { | 965 void NetworkQualityEstimator::CacheNetworkQualityEstimate() { |
| 962 DCHECK(thread_checker_.CalledOnValidThread()); | 966 DCHECK(thread_checker_.CalledOnValidThread()); |
| 963 DCHECK_LE(cached_network_qualities_.size(), | 967 DCHECK_LE(cached_network_qualities_.size(), |
| 964 static_cast<size_t>(kMaximumNetworkQualityCacheSize)); | 968 static_cast<size_t>(kMaximumNetworkQualityCacheSize)); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 | 1074 |
| 1071 NetworkQualityEstimator::NetworkQuality& | 1075 NetworkQualityEstimator::NetworkQuality& |
| 1072 NetworkQualityEstimator::NetworkQuality:: | 1076 NetworkQualityEstimator::NetworkQuality:: |
| 1073 operator=(const NetworkQuality& other) { | 1077 operator=(const NetworkQuality& other) { |
| 1074 rtt_ = other.rtt_; | 1078 rtt_ = other.rtt_; |
| 1075 downstream_throughput_kbps_ = other.downstream_throughput_kbps_; | 1079 downstream_throughput_kbps_ = other.downstream_throughput_kbps_; |
| 1076 return *this; | 1080 return *this; |
| 1077 } | 1081 } |
| 1078 | 1082 |
| 1079 } // namespace net | 1083 } // namespace net |
| OLD | NEW |