Chromium Code Reviews| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 ObservationSource source) = 0; | 94 ObservationSource source) = 0; |
| 95 | 95 |
| 96 protected: | 96 protected: |
| 97 ThroughputObserver() {} | 97 ThroughputObserver() {} |
| 98 virtual ~ThroughputObserver() {} | 98 virtual ~ThroughputObserver() {} |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 DISALLOW_COPY_AND_ASSIGN(ThroughputObserver); | 101 DISALLOW_COPY_AND_ASSIGN(ThroughputObserver); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 // Observes measurements of packet loss. | |
| 105 class NET_EXPORT_PRIVATE PacketLossObserver { | |
| 106 public: | |
| 107 // Will be called when a new packet loss observation is available. | |
|
bengr
2016/02/16 17:02:02
Use complete sentences. "This method will.."
tbansal1
2016/02/17 18:35:10
Done.
| |
| 108 // |num_packets_lost| is the number of packets lost. | |
| 109 // |num_packets_received_in_order| is the number of packets received in | |
| 110 // order. |num_packets_received_not_in_order| is the number of packets | |
| 111 // received out of order. See | |
| 112 // SocketPerformanceWatcherFactory::OnUpdatedPacketCountAvailable for more | |
| 113 // details on how these values are populated. | |
| 114 // | |
| 115 // Providing counts of lost, in-order and out-of-order packets provides | |
| 116 // consumers with more information. From the perspective of network quality, | |
|
bengr
2016/02/16 17:02:01
More information than what?
How does network quali
tbansal1
2016/02/17 18:35:10
Done.
| |
| 117 // loss of a packet indicates worse network quality than receival of an | |
|
bengr
2016/02/16 17:02:02
receival -> reception
tbansal1
2016/02/17 18:35:10
Removed that comment, it was confusing. Also, how
| |
| 118 // out-of-order packet. The latter in turns indicates worse network | |
|
bengr
2016/02/16 17:02:02
turns -> turn
tbansal1
2016/02/17 18:35:11
Done.
| |
| 119 // quality than receival of an in-order packet. | |
|
bengr
2016/02/16 17:02:02
receival -> reception
tbansal1
2016/02/17 18:35:10
Done.
| |
| 120 virtual void OnPacketLossObservation( | |
| 121 uint64_t num_packets_lost, | |
| 122 uint64_t num_packets_received_in_order, | |
| 123 uint64_t num_packets_received_not_in_order, | |
| 124 const base::TimeTicks& timestamp, | |
| 125 ObservationSource source) = 0; | |
| 126 | |
| 127 protected: | |
| 128 PacketLossObserver() {} | |
| 129 virtual ~PacketLossObserver() {} | |
| 130 | |
| 131 private: | |
| 132 DISALLOW_COPY_AND_ASSIGN(PacketLossObserver); | |
| 133 }; | |
| 134 | |
| 104 // Creates a new NetworkQualityEstimator. | 135 // Creates a new NetworkQualityEstimator. |
| 105 // |variation_params| is the map containing all field trial parameters | 136 // |variation_params| is the map containing all field trial parameters |
| 106 // related to NetworkQualityEstimator field trial. | 137 // related to NetworkQualityEstimator field trial. |
| 107 // |external_estimates_provider| may be NULL. | 138 // |external_estimates_provider| may be NULL. |
| 108 NetworkQualityEstimator( | 139 NetworkQualityEstimator( |
| 109 scoped_ptr<ExternalEstimateProvider> external_estimates_provider, | 140 scoped_ptr<ExternalEstimateProvider> external_estimates_provider, |
| 110 const std::map<std::string, std::string>& variation_params); | 141 const std::map<std::string, std::string>& variation_params); |
| 111 | 142 |
| 112 // Construct a NetworkQualityEstimator instance allowing for test | 143 // Construct a NetworkQualityEstimator instance allowing for test |
| 113 // configuration. Registers for network type change notifications so estimates | 144 // configuration. Registers for network type change notifications so estimates |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 132 | 163 |
| 133 // Returns true if RTT is available and sets |rtt| to estimated RTT. | 164 // Returns true if RTT is available and sets |rtt| to estimated RTT. |
| 134 // Virtualized for testing. |rtt| should not be null. | 165 // Virtualized for testing. |rtt| should not be null. |
| 135 virtual bool GetRTTEstimate(base::TimeDelta* rtt) const; | 166 virtual bool GetRTTEstimate(base::TimeDelta* rtt) const; |
| 136 | 167 |
| 137 // Returns true if downlink throughput is available and sets |kbps| to | 168 // Returns true if downlink throughput is available and sets |kbps| to |
| 138 // estimated downlink throughput (in kilobits per second). | 169 // estimated downlink throughput (in kilobits per second). |
| 139 // Virtualized for testing. |kbps| should not be null. | 170 // Virtualized for testing. |kbps| should not be null. |
| 140 virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const; | 171 virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const; |
| 141 | 172 |
| 173 // Returns true if the estimated packet loss rate is available and sets | |
| 174 // |packet_loss| to the estimated packet loss rate. Virtualized for testing. | |
| 175 // |packet_loss| should not be NULL. |packet_loss| is always between 0.0 | |
| 176 // and 1.0 with a higher value indicating higher packet loss rate. | |
|
bengr
2016/02/16 17:02:02
inclusive?
tbansal1
2016/02/17 18:35:10
Done.
| |
| 177 virtual bool GetPacketLossRateEstimate(float* packet_loss) const; | |
| 178 | |
| 142 // Notifies NetworkQualityEstimator that the response header of |request| has | 179 // Notifies NetworkQualityEstimator that the response header of |request| has |
| 143 // been received. | 180 // been received. |
| 144 void NotifyHeadersReceived(const URLRequest& request); | 181 void NotifyHeadersReceived(const URLRequest& request); |
| 145 | 182 |
| 146 // Notifies NetworkQualityEstimator that the response body of |request| has | 183 // Notifies NetworkQualityEstimator that the response body of |request| has |
| 147 // been received. | 184 // been received. |
| 148 void NotifyRequestCompleted(const URLRequest& request); | 185 void NotifyRequestCompleted(const URLRequest& request); |
| 149 | 186 |
| 150 // Returns true if median RTT is available and sets |rtt| to the median of | 187 // Returns true if median RTT is available and sets |rtt| to the median of |
| 151 // RTT observations since |begin_timestamp|. | 188 // RTT observations since |begin_timestamp|. |
| 152 // Virtualized for testing. |rtt| should not be null. | 189 // Virtualized for testing. |rtt| should not be null. |
| 153 virtual bool GetRecentMedianRTT(const base::TimeTicks& begin_timestamp, | 190 virtual bool GetRecentMedianRTT(const base::TimeTicks& begin_timestamp, |
| 154 base::TimeDelta* rtt) const; | 191 base::TimeDelta* rtt) const; |
| 155 | 192 |
| 156 // Returns true if median downstream throughput is available and sets |kbps| | 193 // Returns true if median downstream throughput is available and sets |kbps| |
| 157 // to the median of downstream throughput (in kilobits per second) | 194 // to the median of downstream throughput (in kilobits per second) |
| 158 // observations since |begin_timestamp|. Virtualized for testing. |kbps| | 195 // observations since |begin_timestamp|. Virtualized for testing. |kbps| |
| 159 // should not be null. | 196 // should not be null. |
| 160 virtual bool GetRecentMedianDownlinkThroughputKbps( | 197 virtual bool GetRecentMedianDownlinkThroughputKbps( |
| 161 const base::TimeTicks& begin_timestamp, | 198 const base::TimeTicks& begin_timestamp, |
| 162 int32_t* kbps) const; | 199 int32_t* kbps) const; |
| 163 | 200 |
| 164 // SocketPerformanceWatcherFactory implementation: | 201 // SocketPerformanceWatcherFactory implementation: |
| 165 scoped_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher( | 202 scoped_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher( |
| 166 const Protocol protocol) override; | 203 const Protocol protocol) override; |
| 167 void OnUpdatedRTTAvailable(const Protocol protocol, | 204 void OnUpdatedRTTAvailable(const Protocol protocol, |
| 168 const base::TimeDelta& rtt) override; | 205 const base::TimeDelta& rtt) override; |
| 206 void OnUpdatedPacketCountAvailable( | |
| 207 const Protocol protocol, | |
| 208 uint64_t num_packets_lost, | |
| 209 uint64_t num_packets_received_in_order, | |
| 210 uint64_t num_packets_received_not_in_order) override; | |
| 169 | 211 |
| 170 // Adds |rtt_observer| to the list of round trip time observers. Must be | 212 // Adds |rtt_observer| to the list of round trip time observers. Must be |
| 171 // called on the IO thread. | 213 // called on the IO thread. |
| 172 void AddRTTObserver(RTTObserver* rtt_observer); | 214 void AddRTTObserver(RTTObserver* rtt_observer); |
| 173 | 215 |
| 174 // Removes |rtt_observer| from the list of round trip time observers if it | 216 // Removes |rtt_observer| from the list of round trip time observers if it |
| 175 // is on the list of observers. Must be called on the IO thread. | 217 // is on the list of observers. Must be called on the IO thread. |
| 176 void RemoveRTTObserver(RTTObserver* rtt_observer); | 218 void RemoveRTTObserver(RTTObserver* rtt_observer); |
| 177 | 219 |
| 178 // Adds |throughput_observer| to the list of throughput observers. Must be | 220 // Adds |throughput_observer| to the list of throughput observers. Must be |
| 179 // called on the IO thread. | 221 // called on the IO thread. |
| 180 void AddThroughputObserver(ThroughputObserver* throughput_observer); | 222 void AddThroughputObserver(ThroughputObserver* throughput_observer); |
| 181 | 223 |
| 182 // Removes |throughput_observer| from the list of throughput observers if it | 224 // Removes |throughput_observer| from the list of throughput observers if it |
| 183 // is on the list of observers. Must be called on the IO thread. | 225 // is on the list of observers. Must be called on the IO thread. |
| 184 void RemoveThroughputObserver(ThroughputObserver* throughput_observer); | 226 void RemoveThroughputObserver(ThroughputObserver* throughput_observer); |
| 185 | 227 |
| 228 // Adds |packet_loss_observer| to the list of packet loss observers. Must be | |
| 229 // called on the IO thread. | |
| 230 void AddPacketLossObserver(PacketLossObserver* packet_loss_observer); | |
| 231 | |
| 232 // Removes |packet_loss_observer| from the list of packet loss observers if it | |
| 233 // is on the list of observers. Must be called on the IO thread. | |
| 234 void RemovePacketLossObserver(PacketLossObserver* packet_loss_observer); | |
| 235 | |
| 186 protected: | 236 protected: |
| 187 // NetworkID is used to uniquely identify a network. | 237 // NetworkID is used to uniquely identify a network. |
| 188 // For the purpose of network quality estimation and caching, a network is | 238 // For the purpose of network quality estimation and caching, a network is |
| 189 // uniquely identified by a combination of |type| and | 239 // uniquely identified by a combination of |type| and |
| 190 // |id|. This approach is unable to distinguish networks with | 240 // |id|. This approach is unable to distinguish networks with |
| 191 // same name (e.g., different Wi-Fi networks with same SSID). | 241 // same name (e.g., different Wi-Fi networks with same SSID). |
| 192 // This is a protected member to expose it to tests. | 242 // This is a protected member to expose it to tests. |
| 193 struct NET_EXPORT_PRIVATE NetworkID { | 243 struct NET_EXPORT_PRIVATE NetworkID { |
| 194 NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id) | 244 NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id) |
| 195 : type(type), id(id) {} | 245 : type(type), id(id) {} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 // NetworkChangeNotifier::ConnectionTypeObserver implementation: | 277 // NetworkChangeNotifier::ConnectionTypeObserver implementation: |
| 228 void OnConnectionTypeChanged( | 278 void OnConnectionTypeChanged( |
| 229 NetworkChangeNotifier::ConnectionType type) override; | 279 NetworkChangeNotifier::ConnectionType type) override; |
| 230 | 280 |
| 231 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. | 281 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. |
| 232 void OnUpdatedEstimateAvailable() override; | 282 void OnUpdatedEstimateAvailable() override; |
| 233 | 283 |
| 234 private: | 284 private: |
| 235 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); | 285 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| 236 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestKbpsRTTUpdates); | 286 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestKbpsRTTUpdates); |
| 287 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | |
| 288 TestPacketLossRateUpdates); | |
| 237 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); | 289 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); |
| 238 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); | 290 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); |
| 239 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); | 291 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); |
| 240 FRIEND_TEST_ALL_PREFIXES(URLRequestTestHTTP, NetworkQualityEstimator); | 292 FRIEND_TEST_ALL_PREFIXES(URLRequestTestHTTP, NetworkQualityEstimator); |
| 241 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 293 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 242 PercentileSameTimestamps); | 294 PercentileSameTimestamps); |
| 243 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 295 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 244 PercentileDifferentTimestamps); | 296 PercentileDifferentTimestamps); |
| 245 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); | 297 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); |
| 246 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); | 298 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 // buffer is available. Sets |result| to the computed |percentile| | 443 // buffer is available. Sets |result| to the computed |percentile| |
| 392 // value among all observations since |begin_timestamp|. If the value is | 444 // value among all observations since |begin_timestamp|. If the value is |
| 393 // unavailable, false is returned and |result| is not modified. Percentile | 445 // unavailable, false is returned and |result| is not modified. Percentile |
| 394 // value is unavailable if all the values in observation buffer are older | 446 // value is unavailable if all the values in observation buffer are older |
| 395 // than |begin_timestamp|. | 447 // than |begin_timestamp|. |
| 396 // |result| must not be null. | 448 // |result| must not be null. |
| 397 bool GetPercentile(const base::TimeTicks& begin_timestamp, | 449 bool GetPercentile(const base::TimeTicks& begin_timestamp, |
| 398 ValueType* result, | 450 ValueType* result, |
| 399 int percentile) const; | 451 int percentile) const; |
| 400 | 452 |
| 453 // Returns true iff the weighted average value of the observations in this | |
| 454 // buffer is available. Sets |result| to the computed average | |
| 455 // value among all observations since |begin_timestamp|. If the value is | |
| 456 // unavailable, false is returned and |result| is not modified. Average | |
|
bengr
2016/02/16 17:02:02
Average -> The average
tbansal1
2016/02/17 18:35:11
Done.
| |
| 457 // value is unavailable if all the values in observation buffer are older | |
|
bengr
2016/02/16 17:02:02
all the -> all of the
in observation -> in the obs
tbansal1
2016/02/17 18:35:11
Done.
| |
| 458 // than |begin_timestamp|. |result| must not be NULL. | |
| 459 bool GetWeightedAverage(const base::TimeTicks& begin_timestamp, | |
| 460 ValueType* result) const; | |
| 461 | |
| 401 private: | 462 private: |
| 402 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); | 463 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| 403 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 464 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 404 ObtainOperatingParams); | 465 ObtainOperatingParams); |
| 405 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); | 466 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); |
| 406 | 467 |
| 407 // Computes the weighted observations and stores them in | 468 // Computes the weighted observations and stores them in |
| 408 // |weighted_observations| sorted by ascending |WeightedObservation.value|. | 469 // |weighted_observations| sorted by ascending |WeightedObservation.value|. |
| 409 // Only the observations with timestamp later than |begin_timestamp| are | 470 // Only the observations with timestamp later than |begin_timestamp| are |
| 410 // considered. Also, sets |total_weight| to the total weight of all | 471 // considered. Also, sets |total_weight| to the total weight of all |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 434 RttObservation; | 495 RttObservation; |
| 435 typedef net::NetworkQualityEstimator::ObservationBuffer<base::TimeDelta> | 496 typedef net::NetworkQualityEstimator::ObservationBuffer<base::TimeDelta> |
| 436 RttObservationBuffer; | 497 RttObservationBuffer; |
| 437 | 498 |
| 438 // Value of throughput observations is in kilobits per second. | 499 // Value of throughput observations is in kilobits per second. |
| 439 typedef net::NetworkQualityEstimator::Observation<int32_t> | 500 typedef net::NetworkQualityEstimator::Observation<int32_t> |
| 440 ThroughputObservation; | 501 ThroughputObservation; |
| 441 typedef net::NetworkQualityEstimator::ObservationBuffer<int32_t> | 502 typedef net::NetworkQualityEstimator::ObservationBuffer<int32_t> |
| 442 ThroughputObservationBuffer; | 503 ThroughputObservationBuffer; |
| 443 | 504 |
| 505 // Value of a packet loss observation. A value of 0.0 indicates one packet | |
| 506 // was received successfully in-order, while a value of 1.0 indicates one | |
| 507 // packet was lost. | |
|
bengr
2016/02/16 17:02:02
What does a value of 0.5 mean? Why can't this be a
tbansal1
2016/02/17 18:35:11
This is packet loss rate observation from the rece
| |
| 508 typedef net::NetworkQualityEstimator::Observation<float> | |
| 509 PacketLossObservation; | |
| 510 | |
| 444 // This does not use a unordered_map or hash_map for code simplicity (key just | 511 // This does not use a unordered_map or hash_map for code simplicity (key just |
| 445 // implements operator<, rather than hash and equality) and because the map is | 512 // implements operator<, rather than hash and equality) and because the map is |
| 446 // tiny. | 513 // tiny. |
| 447 typedef std::map<NetworkID, CachedNetworkQuality> CachedNetworkQualities; | 514 typedef std::map<NetworkID, CachedNetworkQuality> CachedNetworkQualities; |
| 448 | 515 |
| 449 // Throughput is set to |kInvalidThroughput| if a valid value is | 516 // Throughput is set to |kInvalidThroughput| if a valid value is |
| 450 // unavailable. Readers should discard throughput value if it is set to | 517 // unavailable. Readers should discard throughput value if it is set to |
| 451 // |kInvalidThroughput|. | 518 // |kInvalidThroughput|. |
| 452 static const int32_t kInvalidThroughput; | 519 static const int32_t kInvalidThroughput; |
| 453 | 520 |
| 521 // Packet loss rate is set to |kInvalidPacketLossRate| if a valid value is | |
| 522 // unavailable. Readers should discard the packet loss rate value if it is | |
| 523 // set to |kInvalidPacketLossRate|. | |
| 524 static const float kInvalidPacketLossRate; | |
|
bengr
2016/02/16 17:02:02
It might be better to provide an is_valid() method
tbansal1
2016/02/17 18:35:11
Changed to use a min valid value.
| |
| 525 | |
| 454 // Tiny transfer sizes may give inaccurate throughput results. | 526 // Tiny transfer sizes may give inaccurate throughput results. |
| 455 // Minimum size of the transfer over which the throughput is computed. | 527 // Minimum size of the transfer over which the throughput is computed. |
| 456 static const int kMinTransferSizeInBytes = 10000; | 528 static const int kMinTransferSizeInBytes = 10000; |
| 457 | 529 |
| 458 // Minimum duration (in microseconds) of the transfer over which the | 530 // Minimum duration (in microseconds) of the transfer over which the |
| 459 // throughput is computed. | 531 // throughput is computed. |
| 460 static const int kMinRequestDurationMicroseconds = 1000; | 532 static const int kMinRequestDurationMicroseconds = 1000; |
| 461 | 533 |
| 462 // Minimum valid value of the variation parameter that holds RTT (in | 534 // Minimum valid value of the variation parameter that holds RTT (in |
| 463 // milliseconds) values. | 535 // milliseconds) values. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 // percentiles indicating less performant networks. For example, if | 574 // percentiles indicating less performant networks. For example, if |
| 503 // |percentile| is 90, then the network is expected to be faster than the | 575 // |percentile| is 90, then the network is expected to be faster than the |
| 504 // returned estimate with 0.9 probability. Similarly, network is expected to | 576 // returned estimate with 0.9 probability. Similarly, network is expected to |
| 505 // be slower than the returned estimate with 0.1 probability. | 577 // be slower than the returned estimate with 0.1 probability. |
| 506 base::TimeDelta GetRTTEstimateInternal(const base::TimeTicks& begin_timestamp, | 578 base::TimeDelta GetRTTEstimateInternal(const base::TimeTicks& begin_timestamp, |
| 507 int percentile) const; | 579 int percentile) const; |
| 508 int32_t GetDownlinkThroughputKbpsEstimateInternal( | 580 int32_t GetDownlinkThroughputKbpsEstimateInternal( |
| 509 const base::TimeTicks& begin_timestamp, | 581 const base::TimeTicks& begin_timestamp, |
| 510 int percentile) const; | 582 int percentile) const; |
| 511 | 583 |
| 584 // Returns an estimate of the packet loss rate. Only the observations later | |
| 585 // than |begin_timestamp| are taken into account. | |
| 586 float GetPacketLossRateEstimateInternal( | |
| 587 const base::TimeTicks& begin_timestamp) const; | |
| 588 | |
| 512 // Returns the current network ID checking by calling the platform APIs. | 589 // Returns the current network ID checking by calling the platform APIs. |
| 513 // Virtualized for testing. | 590 // Virtualized for testing. |
| 514 virtual NetworkID GetCurrentNetworkID() const; | 591 virtual NetworkID GetCurrentNetworkID() const; |
| 515 | 592 |
| 516 // Writes the estimated quality of the current network to the cache. | 593 // Writes the estimated quality of the current network to the cache. |
| 517 void CacheNetworkQualityEstimate(); | 594 void CacheNetworkQualityEstimate(); |
| 518 | 595 |
| 519 void NotifyObserversOfRTT(const RttObservation& observation); | 596 void NotifyObserversOfRTT(const RttObservation& observation); |
| 520 | 597 |
| 521 void NotifyObserversOfThroughput(const ThroughputObservation& observation); | 598 void NotifyObserversOfThroughput(const ThroughputObservation& observation); |
| 522 | 599 |
| 600 void NotifyObserversOfPacketLoss(uint64_t num_packets_lost, | |
| 601 uint64_t num_packets_received_in_order, | |
| 602 uint64_t num_packets_received_not_in_order, | |
| 603 const base::TimeTicks& timestamp, | |
| 604 ObservationSource source); | |
| 605 | |
| 523 // Records the UMA related to RTT. | 606 // Records the UMA related to RTT. |
| 524 void RecordRTTUMA(int32_t estimated_value_msec, | 607 void RecordRTTUMA(int32_t estimated_value_msec, |
| 525 int32_t actual_value_msec) const; | 608 int32_t actual_value_msec) const; |
| 526 | 609 |
| 527 // Returns true only if |request| can be used for network quality estimation. | 610 // Returns true only if |request| can be used for network quality estimation. |
| 528 // Only the requests that go over network are considered to provide useful | 611 // Only the requests that go over network are considered to provide useful |
| 529 // observations. | 612 // observations. |
| 530 bool RequestProvidesUsefulObservations(const URLRequest& request) const; | 613 bool RequestProvidesUsefulObservations(const URLRequest& request) const; |
| 531 | 614 |
| 532 // Values of external estimate provider status. This enum must remain | 615 // Values of external estimate provider status. This enum must remain |
| 533 // synchronized with the enum of the same name in | 616 // synchronized with the enum of the same name in |
| 534 // metrics/histograms/histograms.xml. | 617 // metrics/histograms/histograms.xml. |
| 535 enum NQEExternalEstimateProviderStatus { | 618 enum NQEExternalEstimateProviderStatus { |
| 536 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE, | 619 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE, |
| 537 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE, | 620 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE, |
| 538 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED, | 621 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED, |
| 539 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL, | 622 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL, |
| 540 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, | 623 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, |
| 541 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY | 624 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY |
| 542 }; | 625 }; |
| 543 | 626 |
| 544 // Records the metrics related to external estimate provider. | 627 // Records the metrics related to external estimate provider. |
| 545 void RecordExternalEstimateProviderMetrics( | 628 void RecordExternalEstimateProviderMetrics( |
| 546 NQEExternalEstimateProviderStatus status) const; | 629 NQEExternalEstimateProviderStatus status) const; |
| 547 | 630 |
| 631 // Sets |observation_source| that corresponds to the given |protocol|, and | |
|
bengr
2016/02/16 17:02:02
Do you mean "Gets the?" The entire comment is awkw
tbansal1
2016/02/17 18:35:11
Done.
| |
| 632 // returns true. If the corresponding ObservationSource is unknown, false is | |
| 633 // returned and |observation_source| is not modified. | |
| 634 bool GetObservationSourceForProtocol( | |
| 635 const Protocol protocol, | |
| 636 ObservationSource* observation_source) const; | |
| 637 | |
| 548 // Determines if the requests to local host can be used in estimating the | 638 // Determines if the requests to local host can be used in estimating the |
| 549 // network quality. Set to true only for tests. | 639 // network quality. Set to true only for tests. |
| 550 const bool allow_localhost_requests_; | 640 const bool allow_localhost_requests_; |
| 551 | 641 |
| 552 // Determines if the responses smaller than |kMinTransferSizeInBytes| | 642 // Determines if the responses smaller than |kMinTransferSizeInBytes| |
| 553 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the | 643 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the |
| 554 // network quality. Set to true only for tests. | 644 // network quality. Set to true only for tests. |
| 555 const bool allow_small_responses_; | 645 const bool allow_small_responses_; |
| 556 | 646 |
| 557 // Time when last connection change was observed. | 647 // Time when last connection change was observed. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 571 // Cache that stores quality of previously seen networks. | 661 // Cache that stores quality of previously seen networks. |
| 572 CachedNetworkQualities cached_network_qualities_; | 662 CachedNetworkQualities cached_network_qualities_; |
| 573 | 663 |
| 574 // Buffer that holds throughput observations (in kilobits per second) sorted | 664 // Buffer that holds throughput observations (in kilobits per second) sorted |
| 575 // by timestamp. | 665 // by timestamp. |
| 576 ThroughputObservationBuffer downstream_throughput_kbps_observations_; | 666 ThroughputObservationBuffer downstream_throughput_kbps_observations_; |
| 577 | 667 |
| 578 // Buffer that holds RTT observations sorted by timestamp. | 668 // Buffer that holds RTT observations sorted by timestamp. |
| 579 RttObservationBuffer rtt_msec_observations_; | 669 RttObservationBuffer rtt_msec_observations_; |
| 580 | 670 |
| 671 // Buffer that holds packet loss observations sorted by timestamp. | |
| 672 ObservationBuffer<float> packet_loss_rate_observations_; | |
| 673 | |
| 581 // Default network quality observations obtained from the network quality | 674 // Default network quality observations obtained from the network quality |
| 582 // estimator field trial parameters. The observations are indexed by | 675 // estimator field trial parameters. The observations are indexed by |
| 583 // ConnectionType. | 676 // ConnectionType. |
| 584 NetworkQuality | 677 NetworkQuality |
| 585 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1]; | 678 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1]; |
| 586 | 679 |
| 587 // Estimated network quality. Updated on mainframe requests. | 680 // Estimated network quality. Updated on mainframe requests. |
| 588 NetworkQuality estimated_median_network_quality_; | 681 NetworkQuality estimated_median_network_quality_; |
| 589 | 682 |
| 590 // ExternalEstimateProvider that provides network quality using operating | 683 // ExternalEstimateProvider that provides network quality using operating |
| 591 // system APIs. May be NULL. | 684 // system APIs. May be NULL. |
| 592 const scoped_ptr<ExternalEstimateProvider> external_estimate_provider_; | 685 const scoped_ptr<ExternalEstimateProvider> external_estimate_provider_; |
| 593 | 686 |
| 594 // Observer lists for round trip times and throughput measurements. | 687 // Observer lists for round trip times, throughput and packet loss |
| 688 // measurements. | |
| 595 base::ObserverList<RTTObserver> rtt_observer_list_; | 689 base::ObserverList<RTTObserver> rtt_observer_list_; |
| 596 base::ObserverList<ThroughputObserver> throughput_observer_list_; | 690 base::ObserverList<ThroughputObserver> throughput_observer_list_; |
| 691 base::ObserverList<PacketLossObserver> packet_loss_observer_list_; | |
| 597 | 692 |
| 598 base::ThreadChecker thread_checker_; | 693 base::ThreadChecker thread_checker_; |
| 599 | 694 |
| 600 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 695 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| 601 }; | 696 }; |
| 602 | 697 |
| 603 } // namespace net | 698 } // namespace net |
| 604 | 699 |
| 605 #endif // NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ | 700 #endif // NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ |
| OLD | NEW |