| 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 #ifndef NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ | 5 #ifndef NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ |
| 6 #define NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ | 6 #define NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // throughput is computed. | 107 // throughput is computed. |
| 108 static const int kMinRequestDurationMicroseconds = 1000; | 108 static const int kMinRequestDurationMicroseconds = 1000; |
| 109 | 109 |
| 110 // Construct a NetworkQualityEstimator instance allowing for test | 110 // Construct a NetworkQualityEstimator instance allowing for test |
| 111 // configuration. | 111 // configuration. |
| 112 // Registers for network type change notifications so estimates can be kept | 112 // Registers for network type change notifications so estimates can be kept |
| 113 // network specific. | 113 // network specific. |
| 114 // |allow_local_host_requests_for_tests| should only be true when testing | 114 // |allow_local_host_requests_for_tests| should only be true when testing |
| 115 // against local HTTP server and allows the requests to local host to be | 115 // against local HTTP server and allows the requests to local host to be |
| 116 // used for network quality estimation. | 116 // used for network quality estimation. |
| 117 explicit NetworkQualityEstimator(bool allow_local_host_requests_for_tests); | 117 // |allow_smaller_responses_for_tests| should only be true when testing |
| 118 // against local HTTP server and allows the responses smaller than |
| 119 // |kMinTransferSizeInBytes| or shorter than |kMinRequestDurationMicroseconds| |
| 120 // to be used for network quality estimation. |
| 121 NetworkQualityEstimator(bool allow_local_host_requests_for_tests, |
| 122 bool allow_smaller_responses_for_tests); |
| 118 | 123 |
| 119 // Returns the maximum size of the observation buffer. | 124 // Returns the maximum size of the observation buffer. |
| 120 // Used for testing. | 125 // Used for testing. |
| 121 size_t GetMaximumObservationBufferSizeForTests() const; | 126 size_t GetMaximumObservationBufferSizeForTests() const; |
| 122 | 127 |
| 123 // Returns true if the size of all observation buffers is equal to the | 128 // Returns true if the size of all observation buffers is equal to the |
| 124 // |expected_size|. Used for testing. | 129 // |expected_size|. Used for testing. |
| 125 bool VerifyBufferSizeForTests(size_t expected_size) const; | 130 bool VerifyBufferSizeForTests(size_t expected_size) const; |
| 126 | 131 |
| 127 // NetworkChangeNotifier::ConnectionTypeObserver implementation. | 132 // NetworkChangeNotifier::ConnectionTypeObserver implementation. |
| 128 void OnConnectionTypeChanged( | 133 void OnConnectionTypeChanged( |
| 129 NetworkChangeNotifier::ConnectionType type) override; | 134 NetworkChangeNotifier::ConnectionType type) override; |
| 130 | 135 |
| 131 // Determines if the requests to local host can be used in estimating the | 136 // Determines if the requests to local host can be used in estimating the |
| 132 // network quality. Set to true only for tests. | 137 // network quality. Set to true only for tests. |
| 133 const bool allow_localhost_requests_; | 138 const bool allow_localhost_requests_; |
| 134 | 139 |
| 140 // Determines if the responses smaller than |kMinTransferSizeInBytes| |
| 141 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the |
| 142 // network quality. Set to true only for tests. |
| 143 const bool allow_small_responses_; |
| 144 |
| 135 // Time when last connection change was observed. | 145 // Time when last connection change was observed. |
| 136 base::TimeTicks last_connection_change_; | 146 base::TimeTicks last_connection_change_; |
| 137 | 147 |
| 138 // Last value passed to |OnConnectionTypeChanged|. This indicates the | 148 // Last value passed to |OnConnectionTypeChanged|. This indicates the |
| 139 // current connection type. | 149 // current connection type. |
| 140 NetworkChangeNotifier::ConnectionType current_connection_type_; | 150 NetworkChangeNotifier::ConnectionType current_connection_type_; |
| 141 | 151 |
| 142 // Fastest round-trip-time (RTT) since last connectivity change. RTT measured | 152 // Fastest round-trip-time (RTT) since last connectivity change. RTT measured |
| 143 // from URLRequest creation until first byte received. | 153 // from URLRequest creation until first byte received. |
| 144 base::TimeDelta fastest_rtt_since_last_connection_change_; | 154 base::TimeDelta fastest_rtt_since_last_connection_change_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 156 ObservationBuffer rtt_msec_observations_; | 166 ObservationBuffer rtt_msec_observations_; |
| 157 | 167 |
| 158 base::ThreadChecker thread_checker_; | 168 base::ThreadChecker thread_checker_; |
| 159 | 169 |
| 160 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 170 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| 161 }; | 171 }; |
| 162 | 172 |
| 163 } // namespace net | 173 } // namespace net |
| 164 | 174 |
| 165 #endif // NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ | 175 #endif // NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ |
| OLD | NEW |