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/nqe/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 <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/metrics/histogram_base.h" | 16 #include "base/metrics/histogram_base.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
19 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
22 #include "net/base/load_timing_info.h" | 22 #include "net/base/load_timing_info.h" |
23 #include "net/base/network_interfaces.h" | 23 #include "net/base/network_interfaces.h" |
24 #include "net/base/socket_performance_watcher.h" | |
25 #include "net/base/url_util.h" | 24 #include "net/base/url_util.h" |
| 25 #include "net/socket/socket_performance_watcher.h" |
26 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
28 | 28 |
29 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
30 #include "net/android/network_library.h" | 30 #include "net/android/network_library.h" |
31 #endif // OS_ANDROID | 31 #endif // OS_ANDROID |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // Default value of the half life (in seconds) for computing time weighted | 35 // Default value of the half life (in seconds) for computing time weighted |
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 const ThroughputObservation& observation) { | 1110 const ThroughputObservation& observation) { |
1111 FOR_EACH_OBSERVER( | 1111 FOR_EACH_OBSERVER( |
1112 ThroughputObserver, throughput_observer_list_, | 1112 ThroughputObserver, throughput_observer_list_, |
1113 OnThroughputObservation(observation.value, observation.timestamp, | 1113 OnThroughputObservation(observation.value, observation.timestamp, |
1114 observation.source)); | 1114 observation.source)); |
1115 } | 1115 } |
1116 | 1116 |
1117 NetworkQualityEstimator::CachedNetworkQuality::CachedNetworkQuality( | 1117 NetworkQualityEstimator::CachedNetworkQuality::CachedNetworkQuality( |
1118 const NetworkQuality& network_quality) | 1118 const NetworkQuality& network_quality) |
1119 : last_update_time_(base::TimeTicks::Now()), | 1119 : last_update_time_(base::TimeTicks::Now()), |
1120 network_quality_(network_quality) { | 1120 network_quality_(network_quality) {} |
1121 } | |
1122 | 1121 |
1123 NetworkQualityEstimator::CachedNetworkQuality::CachedNetworkQuality( | 1122 NetworkQualityEstimator::CachedNetworkQuality::CachedNetworkQuality( |
1124 const CachedNetworkQuality& other) | 1123 const CachedNetworkQuality& other) |
1125 : last_update_time_(other.last_update_time_), | 1124 : last_update_time_(other.last_update_time_), |
1126 network_quality_(other.network_quality_) { | 1125 network_quality_(other.network_quality_) {} |
1127 } | |
1128 | 1126 |
1129 NetworkQualityEstimator::CachedNetworkQuality::~CachedNetworkQuality() { | 1127 NetworkQualityEstimator::CachedNetworkQuality::~CachedNetworkQuality() {} |
1130 } | |
1131 | 1128 |
1132 bool NetworkQualityEstimator::CachedNetworkQuality::OlderThan( | 1129 bool NetworkQualityEstimator::CachedNetworkQuality::OlderThan( |
1133 const CachedNetworkQuality& cached_network_quality) const { | 1130 const CachedNetworkQuality& cached_network_quality) const { |
1134 return last_update_time_ < cached_network_quality.last_update_time_; | 1131 return last_update_time_ < cached_network_quality.last_update_time_; |
1135 } | 1132 } |
1136 | 1133 |
1137 NetworkQualityEstimator::NetworkQuality::NetworkQuality() | 1134 NetworkQualityEstimator::NetworkQuality::NetworkQuality() |
1138 : NetworkQuality(NetworkQualityEstimator::InvalidRTT(), | 1135 : NetworkQuality(NetworkQualityEstimator::InvalidRTT(), |
1139 NetworkQualityEstimator::kInvalidThroughput) {} | 1136 NetworkQualityEstimator::kInvalidThroughput) {} |
1140 | 1137 |
1141 NetworkQualityEstimator::NetworkQuality::NetworkQuality( | 1138 NetworkQualityEstimator::NetworkQuality::NetworkQuality( |
1142 const base::TimeDelta& rtt, | 1139 const base::TimeDelta& rtt, |
1143 int32_t downstream_throughput_kbps) | 1140 int32_t downstream_throughput_kbps) |
1144 : rtt_(rtt), downstream_throughput_kbps_(downstream_throughput_kbps) { | 1141 : rtt_(rtt), downstream_throughput_kbps_(downstream_throughput_kbps) { |
1145 DCHECK_GE(rtt_, base::TimeDelta()); | 1142 DCHECK_GE(rtt_, base::TimeDelta()); |
1146 DCHECK_GE(downstream_throughput_kbps_, 0); | 1143 DCHECK_GE(downstream_throughput_kbps_, 0); |
1147 } | 1144 } |
1148 | 1145 |
1149 NetworkQualityEstimator::NetworkQuality::NetworkQuality( | 1146 NetworkQualityEstimator::NetworkQuality::NetworkQuality( |
1150 const NetworkQuality& other) | 1147 const NetworkQuality& other) |
1151 : NetworkQuality(other.rtt_, other.downstream_throughput_kbps_) {} | 1148 : NetworkQuality(other.rtt_, other.downstream_throughput_kbps_) {} |
1152 | 1149 |
1153 NetworkQualityEstimator::NetworkQuality::~NetworkQuality() {} | 1150 NetworkQualityEstimator::NetworkQuality::~NetworkQuality() {} |
1154 | 1151 |
1155 NetworkQualityEstimator::NetworkQuality& | 1152 NetworkQualityEstimator::NetworkQuality& |
1156 NetworkQualityEstimator::NetworkQuality:: | 1153 NetworkQualityEstimator::NetworkQuality::operator=( |
1157 operator=(const NetworkQuality& other) { | 1154 const NetworkQuality& other) { |
1158 rtt_ = other.rtt_; | 1155 rtt_ = other.rtt_; |
1159 downstream_throughput_kbps_ = other.downstream_throughput_kbps_; | 1156 downstream_throughput_kbps_ = other.downstream_throughput_kbps_; |
1160 return *this; | 1157 return *this; |
1161 } | 1158 } |
1162 | 1159 |
1163 } // namespace net | 1160 } // namespace net |
OLD | NEW |