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> |
| 11 #include <utility> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/metrics/histogram_base.h" | 16 #include "base/metrics/histogram_base.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
19 #include "net/base/load_timing_info.h" | 20 #include "net/base/load_timing_info.h" |
20 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 115 |
115 } // namespace | 116 } // namespace |
116 | 117 |
117 namespace net { | 118 namespace net { |
118 | 119 |
119 const int32_t NetworkQualityEstimator::kInvalidThroughput = 0; | 120 const int32_t NetworkQualityEstimator::kInvalidThroughput = 0; |
120 | 121 |
121 NetworkQualityEstimator::NetworkQualityEstimator( | 122 NetworkQualityEstimator::NetworkQualityEstimator( |
122 scoped_ptr<ExternalEstimateProvider> external_estimates_provider, | 123 scoped_ptr<ExternalEstimateProvider> external_estimates_provider, |
123 const std::map<std::string, std::string>& variation_params) | 124 const std::map<std::string, std::string>& variation_params) |
124 : NetworkQualityEstimator(external_estimates_provider.Pass(), | 125 : NetworkQualityEstimator(std::move(external_estimates_provider), |
125 variation_params, | 126 variation_params, |
126 false, | 127 false, |
127 false) {} | 128 false) {} |
128 | 129 |
129 NetworkQualityEstimator::NetworkQualityEstimator( | 130 NetworkQualityEstimator::NetworkQualityEstimator( |
130 scoped_ptr<ExternalEstimateProvider> external_estimates_provider, | 131 scoped_ptr<ExternalEstimateProvider> external_estimates_provider, |
131 const std::map<std::string, std::string>& variation_params, | 132 const std::map<std::string, std::string>& variation_params, |
132 bool allow_local_host_requests_for_tests, | 133 bool allow_local_host_requests_for_tests, |
133 bool allow_smaller_responses_for_tests) | 134 bool allow_smaller_responses_for_tests) |
134 : allow_localhost_requests_(allow_local_host_requests_for_tests), | 135 : allow_localhost_requests_(allow_local_host_requests_for_tests), |
135 allow_small_responses_(allow_smaller_responses_for_tests), | 136 allow_small_responses_(allow_smaller_responses_for_tests), |
136 last_connection_change_(base::TimeTicks::Now()), | 137 last_connection_change_(base::TimeTicks::Now()), |
137 current_network_id_( | 138 current_network_id_( |
138 NetworkID(NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN, | 139 NetworkID(NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN, |
139 std::string())), | 140 std::string())), |
140 downstream_throughput_kbps_observations_( | 141 downstream_throughput_kbps_observations_( |
141 GetWeightMultiplierPerSecond(variation_params)), | 142 GetWeightMultiplierPerSecond(variation_params)), |
142 rtt_msec_observations_(GetWeightMultiplierPerSecond(variation_params)), | 143 rtt_msec_observations_(GetWeightMultiplierPerSecond(variation_params)), |
143 external_estimate_provider_(external_estimates_provider.Pass()) { | 144 external_estimate_provider_(std::move(external_estimates_provider)) { |
144 static_assert(kMinRequestDurationMicroseconds > 0, | 145 static_assert(kMinRequestDurationMicroseconds > 0, |
145 "Minimum request duration must be > 0"); | 146 "Minimum request duration must be > 0"); |
146 static_assert(kDefaultHalfLifeSeconds > 0, | 147 static_assert(kDefaultHalfLifeSeconds > 0, |
147 "Default half life duration must be > 0"); | 148 "Default half life duration must be > 0"); |
148 static_assert(kMaximumNetworkQualityCacheSize > 0, | 149 static_assert(kMaximumNetworkQualityCacheSize > 0, |
149 "Size of the network quality cache must be > 0"); | 150 "Size of the network quality cache must be > 0"); |
150 // This limit should not be increased unless the logic for removing the | 151 // This limit should not be increased unless the logic for removing the |
151 // oldest cache entry is rewritten to use a doubly-linked-list LRU queue. | 152 // oldest cache entry is rewritten to use a doubly-linked-list LRU queue. |
152 static_assert(kMaximumNetworkQualityCacheSize <= 10, | 153 static_assert(kMaximumNetworkQualityCacheSize <= 10, |
153 "Size of the network quality cache must <= 10"); | 154 "Size of the network quality cache must <= 10"); |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 | 1003 |
1003 NetworkQualityEstimator::NetworkQuality& | 1004 NetworkQualityEstimator::NetworkQuality& |
1004 NetworkQualityEstimator::NetworkQuality:: | 1005 NetworkQualityEstimator::NetworkQuality:: |
1005 operator=(const NetworkQuality& other) { | 1006 operator=(const NetworkQuality& other) { |
1006 rtt_ = other.rtt_; | 1007 rtt_ = other.rtt_; |
1007 downstream_throughput_kbps_ = other.downstream_throughput_kbps_; | 1008 downstream_throughput_kbps_ = other.downstream_throughput_kbps_; |
1008 return *this; | 1009 return *this; |
1009 } | 1010 } |
1010 | 1011 |
1011 } // namespace net | 1012 } // namespace net |
OLD | NEW |