Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: net/nqe/network_quality_estimator.h

Issue 1942893002: Split NQE to multiple files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 5 #ifndef NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <deque>
12 #include <map> 11 #include <map>
13 #include <memory> 12 #include <memory>
14 #include <string> 13 #include <string>
15 #include <tuple> 14 #include <tuple>
16 15
17 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
18 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
19 #include "base/macros.h" 18 #include "base/macros.h"
20 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
21 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
22 #include "base/observer_list.h" 21 #include "base/observer_list.h"
23 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
24 #include "base/time/time.h" 23 #include "base/time/time.h"
25 #include "net/base/net_export.h" 24 #include "net/base/net_export.h"
26 #include "net/base/network_change_notifier.h" 25 #include "net/base/network_change_notifier.h"
27 #include "net/nqe/external_estimate_provider.h" 26 #include "net/nqe/external_estimate_provider.h"
27 #include "net/nqe/network_quality.h"
28 #include "net/nqe/network_quality_observation.h"
29 #include "net/nqe/network_quality_observation_source.h"
28 #include "net/socket/socket_performance_watcher_factory.h" 30 #include "net/socket/socket_performance_watcher_factory.h"
29 31
30 namespace base { 32 namespace base {
31 class SingleThreadTaskRunner; 33 class SingleThreadTaskRunner;
32 } // namespace base 34 } // namespace base
33 35
34 namespace net { 36 namespace net {
35 37
36 class URLRequest; 38 class URLRequest;
37 39
(...skipping 22 matching lines...) Expand all
60 EFFECTIVE_CONNECTION_TYPE_UNKNOWN = 0, 62 EFFECTIVE_CONNECTION_TYPE_UNKNOWN = 0,
61 EFFECTIVE_CONNECTION_TYPE_OFFLINE, 63 EFFECTIVE_CONNECTION_TYPE_OFFLINE,
62 EFFECTIVE_CONNECTION_TYPE_SLOW_2G, 64 EFFECTIVE_CONNECTION_TYPE_SLOW_2G,
63 EFFECTIVE_CONNECTION_TYPE_2G, 65 EFFECTIVE_CONNECTION_TYPE_2G,
64 EFFECTIVE_CONNECTION_TYPE_3G, 66 EFFECTIVE_CONNECTION_TYPE_3G,
65 EFFECTIVE_CONNECTION_TYPE_4G, 67 EFFECTIVE_CONNECTION_TYPE_4G,
66 EFFECTIVE_CONNECTION_TYPE_BROADBAND, 68 EFFECTIVE_CONNECTION_TYPE_BROADBAND,
67 EFFECTIVE_CONNECTION_TYPE_LAST, 69 EFFECTIVE_CONNECTION_TYPE_LAST,
68 }; 70 };
69 71
70 // On Android, a Java counterpart will be generated for this enum.
71 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
72 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: NetworkQualityObservationSource
73 // GENERATED_JAVA_PREFIX_TO_STRIP:
74 enum ObservationSource {
75 // The observation was taken at the request layer, e.g., a round trip time
76 // is recorded as the time between the request being sent and the first byte
77 // being received.
78 URL_REQUEST,
79 // The observation is taken from TCP statistics maintained by the kernel.
80 TCP,
81 // The observation is taken at the QUIC layer.
82 QUIC,
83 // The observation is a previously cached estimate of the metric.
84 CACHED_ESTIMATE,
85 // The observation is derived from network connection information provided
86 // by the platform. For example, typical RTT and throughput values are used
87 // for a given type of network connection.
88 DEFAULT_FROM_PLATFORM,
89 // The observation came from a Chromium-external source.
90 EXTERNAL_ESTIMATE
91 };
92
93 // Observes measurements of round trip time. 72 // Observes measurements of round trip time.
94 class NET_EXPORT_PRIVATE RTTObserver { 73 class NET_EXPORT_PRIVATE RTTObserver {
95 public: 74 public:
96 // Will be called when a new RTT observation is available. The round trip 75 // Will be called when a new RTT observation is available. The round trip
97 // time is specified in milliseconds. The time when the observation was 76 // time is specified in milliseconds. The time when the observation was
98 // taken and the source of the observation are provided. 77 // taken and the source of the observation are provided.
99 virtual void OnRTTObservation(int32_t rtt_ms, 78 virtual void OnRTTObservation(int32_t rtt_ms,
100 const base::TimeTicks& timestamp, 79 const base::TimeTicks& timestamp,
101 ObservationSource source) = 0; 80 NetworkQualityObservationSource source) = 0;
102 81
103 protected: 82 protected:
104 RTTObserver() {} 83 RTTObserver() {}
105 virtual ~RTTObserver() {} 84 virtual ~RTTObserver() {}
106 85
107 private: 86 private:
108 DISALLOW_COPY_AND_ASSIGN(RTTObserver); 87 DISALLOW_COPY_AND_ASSIGN(RTTObserver);
109 }; 88 };
110 89
111 // Observes measurements of throughput. 90 // Observes measurements of throughput.
112 class NET_EXPORT_PRIVATE ThroughputObserver { 91 class NET_EXPORT_PRIVATE ThroughputObserver {
113 public: 92 public:
114 // Will be called when a new throughput observation is available. 93 // Will be called when a new throughput observation is available.
115 // Throughput is specified in kilobits per second. 94 // Throughput is specified in kilobits per second.
116 virtual void OnThroughputObservation(int32_t throughput_kbps, 95 virtual void OnThroughputObservation(
117 const base::TimeTicks& timestamp, 96 int32_t throughput_kbps,
118 ObservationSource source) = 0; 97 const base::TimeTicks& timestamp,
98 NetworkQualityObservationSource source) = 0;
119 99
120 protected: 100 protected:
121 ThroughputObserver() {} 101 ThroughputObserver() {}
122 virtual ~ThroughputObserver() {} 102 virtual ~ThroughputObserver() {}
123 103
124 private: 104 private:
125 DISALLOW_COPY_AND_ASSIGN(ThroughputObserver); 105 DISALLOW_COPY_AND_ASSIGN(ThroughputObserver);
126 }; 106 };
127 107
128 // Creates a new NetworkQualityEstimator. 108 // Creates a new NetworkQualityEstimator.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 244
265 // Return a string equivalent to |type|. 245 // Return a string equivalent to |type|.
266 const char* GetNameForEffectiveConnectionType( 246 const char* GetNameForEffectiveConnectionType(
267 EffectiveConnectionType type) const; 247 EffectiveConnectionType type) const;
268 248
269 private: 249 private:
270 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); 250 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations);
271 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); 251 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation);
272 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); 252 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams);
273 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); 253 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam);
274 FRIEND_TEST_ALL_PREFIXES(URLRequestTestHTTP, NetworkQualityEstimator);
275 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
276 PercentileSameTimestamps);
277 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
278 PercentileDifferentTimestamps);
279 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); 254 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles);
280 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); 255 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching);
281 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, 256 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
282 TestLRUCacheMaximumSize); 257 TestLRUCacheMaximumSize);
283 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMedianRTTSince); 258 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMedianRTTSince);
284 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, 259 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
285 TestExternalEstimateProviderMergeEstimates); 260 TestExternalEstimateProviderMergeEstimates);
286 261
287 class SocketWatcher; 262 class SocketWatcher;
288 class SocketWatcherFactory; 263 class SocketWatcherFactory;
289 264
290 // NetworkQuality is used to cache the quality of a network connection.
291 class NET_EXPORT_PRIVATE NetworkQuality {
292 public:
293 NetworkQuality();
294 // |rtt| is the estimate of the round trip time.
295 // |downstream_throughput_kbps| is the estimate of the downstream
296 // throughput in kilobits per second.
297 NetworkQuality(const base::TimeDelta& rtt,
298 int32_t downstream_throughput_kbps);
299 NetworkQuality(const NetworkQuality& other);
300 ~NetworkQuality();
301
302 NetworkQuality& operator=(const NetworkQuality& other);
303
304 // Returns the estimate of the round trip time.
305 const base::TimeDelta& rtt() const { return rtt_; }
306
307 // Returns the estimate of the downstream throughput in Kbps (Kilobits per
308 // second).
309 int32_t downstream_throughput_kbps() const {
310 return downstream_throughput_kbps_;
311 }
312
313 private:
314 // Estimated round trip time.
315 base::TimeDelta rtt_;
316
317 // Estimated downstream throughput in kilobits per second.
318 int32_t downstream_throughput_kbps_;
319 };
320
321 // CachedNetworkQuality stores the quality of a previously seen network.
322 class NET_EXPORT_PRIVATE CachedNetworkQuality {
323 public:
324 explicit CachedNetworkQuality(const NetworkQuality& network_quality);
325 CachedNetworkQuality(const CachedNetworkQuality& other);
326 ~CachedNetworkQuality();
327
328 // Returns the network quality associated with this cached entry.
329 const NetworkQuality& network_quality() const { return network_quality_; }
330
331 // Returns true if this cache entry was updated before
332 // |cached_network_quality|.
333 bool OlderThan(const CachedNetworkQuality& cached_network_quality) const;
334
335 // Time when this cache entry was last updated.
336 const base::TimeTicks last_update_time_;
337
338 // Quality of this cached network.
339 const NetworkQuality network_quality_;
340
341 private:
342 DISALLOW_ASSIGN(CachedNetworkQuality);
343 };
344
345 // Records observations of network quality metrics (such as round trip time
346 // or throughput), along with the time the observation was made. Observations
347 // can be made at several places in the network stack, thus the observation
348 // source is provided as well. ValueType must be numerical so that statistics
349 // such as median, average can be computed.
350 template <typename ValueType>
351 struct NET_EXPORT_PRIVATE Observation {
352 Observation(const ValueType& value,
353 base::TimeTicks timestamp,
354 ObservationSource source)
355 : value(value), timestamp(timestamp), source(source) {
356 DCHECK(!timestamp.is_null());
357 }
358 ~Observation() {}
359
360 // Value of the observation.
361 const ValueType value;
362
363 // Time when the observation was taken.
364 const base::TimeTicks timestamp;
365
366 // The source of the observation.
367 const ObservationSource source;
368 };
369
370 // Holds an observation and its weight.
371 template <typename ValueType>
372 struct NET_EXPORT_PRIVATE WeightedObservation {
373 WeightedObservation(ValueType value, double weight)
374 : value(value), weight(weight) {}
375 WeightedObservation(const WeightedObservation& other)
376 : WeightedObservation(other.value, other.weight) {}
377
378 WeightedObservation& operator=(const WeightedObservation& other) {
379 value = other.value;
380 weight = other.weight;
381 return *this;
382 }
383
384 // Required for sorting the samples in the ascending order of values.
385 bool operator<(const WeightedObservation& other) const {
386 return (value < other.value);
387 }
388
389 // Value of the sample.
390 ValueType value;
391
392 // Weight of the sample. This is computed based on how much time has passed
393 // since the sample was taken.
394 double weight;
395 };
396
397 // Stores observations sorted by time.
398 template <typename ValueType>
399 class NET_EXPORT_PRIVATE ObservationBuffer {
400 public:
401 explicit ObservationBuffer(double weight_multiplier_per_second);
402 ~ObservationBuffer();
403
404 // Adds |observation| to the buffer. The oldest observation in the buffer
405 // will be evicted to make room if the buffer is already full.
406 void AddObservation(const Observation<ValueType>& observation) {
407 DCHECK_LE(observations_.size(),
408 static_cast<size_t>(kMaximumObservationsBufferSize));
409 // Evict the oldest element if the buffer is already full.
410 if (observations_.size() == kMaximumObservationsBufferSize)
411 observations_.pop_front();
412
413 observations_.push_back(observation);
414 DCHECK_LE(observations_.size(),
415 static_cast<size_t>(kMaximumObservationsBufferSize));
416 }
417
418 // Clears the observations stored in this buffer.
419 void Clear() { observations_.clear(); }
420
421 // Returns true iff the |percentile| value of the observations in this
422 // buffer is available. Sets |result| to the computed |percentile|
423 // value among all observations since |begin_timestamp|. If the value is
424 // unavailable, false is returned and |result| is not modified. Percentile
425 // value is unavailable if all the values in observation buffer are older
426 // than |begin_timestamp|. |result| must not be null.
427 // |disallowed_observation_sources| is the list of observation sources that
428 // should be excluded when computing the percentile.
429 bool GetPercentile(
430 const base::TimeTicks& begin_timestamp,
431 ValueType* result,
432 int percentile,
433 const std::vector<ObservationSource>& disallowed_observation_sources)
434 const WARN_UNUSED_RESULT;
435
436 private:
437 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam);
438
439 // Computes the weighted observations and stores them in
440 // |weighted_observations| sorted by ascending |WeightedObservation.value|.
441 // Only the observations with timestamp later than |begin_timestamp| are
442 // considered. Also, sets |total_weight| to the total weight of all
443 // observations. Should be called only when there is at least one
444 // observation in the buffer. |disallowed_observation_sources| is the list
445 // of observation sources that should be excluded when computing the
446 // weighted observations.
447 void ComputeWeightedObservations(
448 const base::TimeTicks& begin_timestamp,
449 std::vector<WeightedObservation<ValueType>>& weighted_observations,
450 double* total_weight,
451 const std::vector<ObservationSource>& disallowed_observation_sources)
452 const;
453
454 // Holds observations sorted by time, with the oldest observation at the
455 // front of the queue.
456 std::deque<Observation<ValueType>> observations_;
457
458 // The factor by which the weight of an observation reduces every second.
459 // For example, if an observation is 6 seconds old, its weight would be:
460 // weight_multiplier_per_second_ ^ 6
461 // Calculated from |kHalfLifeSeconds| by solving the following equation:
462 // weight_multiplier_per_second_ ^ kHalfLifeSeconds = 0.5
463 const double weight_multiplier_per_second_;
464
465 DISALLOW_COPY_AND_ASSIGN(ObservationBuffer);
466 };
467
468 // Value of round trip time observations is in base::TimeDelta. 265 // Value of round trip time observations is in base::TimeDelta.
469 typedef net::NetworkQualityEstimator::Observation<base::TimeDelta> 266 typedef nqe::internal::Observation<base::TimeDelta> RttObservation;
470 RttObservation; 267 typedef nqe::internal::ObservationBuffer<base::TimeDelta>
471 typedef net::NetworkQualityEstimator::ObservationBuffer<base::TimeDelta>
472 RttObservationBuffer; 268 RttObservationBuffer;
473 269
474 // Value of throughput observations is in kilobits per second. 270 // Value of throughput observations is in kilobits per second.
475 typedef net::NetworkQualityEstimator::Observation<int32_t> 271 typedef nqe::internal::Observation<int32_t> ThroughputObservation;
476 ThroughputObservation; 272 typedef nqe::internal::ObservationBuffer<int32_t> ThroughputObservationBuffer;
477 typedef net::NetworkQualityEstimator::ObservationBuffer<int32_t>
478 ThroughputObservationBuffer;
479 273
480 // This does not use a unordered_map or hash_map for code simplicity (key just 274 // This does not use a unordered_map or hash_map for code simplicity (key just
481 // implements operator<, rather than hash and equality) and because the map is 275 // implements operator<, rather than hash and equality) and because the map is
482 // tiny. 276 // tiny.
483 typedef std::map<NetworkID, CachedNetworkQuality> CachedNetworkQualities; 277 typedef std::map<NetworkID, nqe::internal::CachedNetworkQuality>
484 278 CachedNetworkQualities;
485 // Throughput is set to |kInvalidThroughput| if a valid value is
486 // unavailable. Readers should discard throughput value if it is set to
487 // |kInvalidThroughput|.
488 static const int32_t kInvalidThroughput;
489 279
490 // Tiny transfer sizes may give inaccurate throughput results. 280 // Tiny transfer sizes may give inaccurate throughput results.
491 // Minimum size of the transfer over which the throughput is computed. 281 // Minimum size of the transfer over which the throughput is computed.
492 static const int kMinTransferSizeInBytes = 10000; 282 static const int kMinTransferSizeInBytes = 10000;
493 283
494 // Minimum duration (in microseconds) of the transfer over which the 284 // Minimum duration (in microseconds) of the transfer over which the
495 // throughput is computed. 285 // throughput is computed.
496 static const int kMinRequestDurationMicroseconds = 1000; 286 static const int kMinRequestDurationMicroseconds = 1000;
497 287
498 // Minimum valid value of the variation parameter that holds RTT (in 288 // Minimum valid value of the variation parameter that holds RTT (in
499 // milliseconds) values. 289 // milliseconds) values.
500 static const int kMinimumRTTVariationParameterMsec = 1; 290 static const int kMinimumRTTVariationParameterMsec = 1;
501 291
502 // Minimum valid value of the variation parameter that holds throughput (in 292 // Minimum valid value of the variation parameter that holds throughput (in
503 // kilobits per second) values. 293 // kilobits per second) values.
504 static const int kMinimumThroughputVariationParameterKbps = 1; 294 static const int kMinimumThroughputVariationParameterKbps = 1;
505 295
506 // Maximum size of the cache that holds network quality estimates. 296 // Maximum size of the cache that holds network quality estimates.
507 // Smaller size may reduce the cache hit rate due to frequent evictions. 297 // Smaller size may reduce the cache hit rate due to frequent evictions.
508 // Larger size may affect performance. 298 // Larger size may affect performance.
509 static const size_t kMaximumNetworkQualityCacheSize = 10; 299 static const size_t kMaximumNetworkQualityCacheSize = 10;
510 300
511 // Maximum number of observations that can be held in the ObservationBuffer.
512 static const size_t kMaximumObservationsBufferSize = 300;
513
514 // Time duration (in milliseconds) after which the estimate provided by 301 // Time duration (in milliseconds) after which the estimate provided by
515 // external estimate provider is considered stale. 302 // external estimate provider is considered stale.
516 static const int kExternalEstimateProviderFreshnessDurationMsec = 303 static const int kExternalEstimateProviderFreshnessDurationMsec =
517 5 * 60 * 1000; 304 5 * 60 * 1000;
518 305
519 // Returns the RTT value to be used when the valid RTT is unavailable. Readers 306 // Returns the RTT value to be used when the valid RTT is unavailable. Readers
520 // should discard RTT if it is set to the value returned by |InvalidRTT()|. 307 // should discard RTT if it is set to the value returned by |InvalidRTT()|.
521 static const base::TimeDelta InvalidRTT(); 308 static const base::TimeDelta InvalidRTT();
522 309
523 // Notifies |this| of a new transport layer RTT. 310 // Notifies |this| of a new transport layer RTT.
(...skipping 22 matching lines...) Expand all
546 // Returns an estimate of network quality at the specified |percentile|. 333 // Returns an estimate of network quality at the specified |percentile|.
547 // |disallowed_observation_sources| is the list of observation sources that 334 // |disallowed_observation_sources| is the list of observation sources that
548 // should be excluded when computing the percentile. 335 // should be excluded when computing the percentile.
549 // Only the observations later than |begin_timestamp| are taken into account. 336 // Only the observations later than |begin_timestamp| are taken into account.
550 // |percentile| must be between 0 and 100 (both inclusive) with higher 337 // |percentile| must be between 0 and 100 (both inclusive) with higher
551 // percentiles indicating less performant networks. For example, if 338 // percentiles indicating less performant networks. For example, if
552 // |percentile| is 90, then the network is expected to be faster than the 339 // |percentile| is 90, then the network is expected to be faster than the
553 // returned estimate with 0.9 probability. Similarly, network is expected to 340 // returned estimate with 0.9 probability. Similarly, network is expected to
554 // be slower than the returned estimate with 0.1 probability. 341 // be slower than the returned estimate with 0.1 probability.
555 base::TimeDelta GetRTTEstimateInternal( 342 base::TimeDelta GetRTTEstimateInternal(
556 const std::vector<ObservationSource>& disallowed_observation_sources, 343 const std::vector<NetworkQualityObservationSource>&
344 disallowed_observation_sources,
557 const base::TimeTicks& begin_timestamp, 345 const base::TimeTicks& begin_timestamp,
558 int percentile) const; 346 int percentile) const;
559 int32_t GetDownlinkThroughputKbpsEstimateInternal( 347 int32_t GetDownlinkThroughputKbpsEstimateInternal(
560 const base::TimeTicks& begin_timestamp, 348 const base::TimeTicks& begin_timestamp,
561 int percentile) const; 349 int percentile) const;
562 350
563 // Returns the current network ID checking by calling the platform APIs. 351 // Returns the current network ID checking by calling the platform APIs.
564 // Virtualized for testing. 352 // Virtualized for testing.
565 virtual NetworkID GetCurrentNetworkID() const; 353 virtual NetworkID GetCurrentNetworkID() const;
566 354
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 403
616 // ID of the current network. 404 // ID of the current network.
617 NetworkID current_network_id_; 405 NetworkID current_network_id_;
618 406
619 // Peak network quality (fastest round-trip-time (RTT) and highest 407 // Peak network quality (fastest round-trip-time (RTT) and highest
620 // downstream throughput) measured since last connectivity change. RTT is 408 // downstream throughput) measured since last connectivity change. RTT is
621 // measured from time the request is sent until the first byte received. 409 // measured from time the request is sent until the first byte received.
622 // The accuracy is decreased by ignoring these factors: 410 // The accuracy is decreased by ignoring these factors:
623 // 1) Multiple URLRequests can occur concurrently. 411 // 1) Multiple URLRequests can occur concurrently.
624 // 2) Includes server processing time. 412 // 2) Includes server processing time.
625 NetworkQuality peak_network_quality_; 413 nqe::internal::NetworkQuality peak_network_quality_;
626 414
627 // Cache that stores quality of previously seen networks. 415 // Cache that stores quality of previously seen networks.
628 CachedNetworkQualities cached_network_qualities_; 416 CachedNetworkQualities cached_network_qualities_;
629 417
630 // Buffer that holds throughput observations (in kilobits per second) sorted 418 // Buffer that holds throughput observations (in kilobits per second) sorted
631 // by timestamp. 419 // by timestamp.
632 ThroughputObservationBuffer downstream_throughput_kbps_observations_; 420 ThroughputObservationBuffer downstream_throughput_kbps_observations_;
633 421
634 // Buffer that holds RTT observations sorted by timestamp. 422 // Buffer that holds RTT observations sorted by timestamp.
635 RttObservationBuffer rtt_observations_; 423 RttObservationBuffer rtt_observations_;
636 424
637 // Default network quality observations obtained from the network quality 425 // Default network quality observations obtained from the network quality
638 // estimator field trial parameters. The observations are indexed by 426 // estimator field trial parameters. The observations are indexed by
639 // ConnectionType. 427 // ConnectionType.
640 NetworkQuality 428 nqe::internal::NetworkQuality
641 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1]; 429 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1];
642 430
643 // Thresholds for different effective connection types obtained from field 431 // Thresholds for different effective connection types obtained from field
644 // trial variation params. These thresholds encode how different connection 432 // trial variation params. These thresholds encode how different connection
645 // types behave in general. In future, complex encodings (e.g., curve 433 // types behave in general. In future, complex encodings (e.g., curve
646 // fitting) may be used. 434 // fitting) may be used.
647 NetworkQuality connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_LAST]; 435 nqe::internal::NetworkQuality
436 connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_LAST];
648 437
649 // Estimated network quality. Updated on mainframe requests. 438 // Estimated network quality. Updated on mainframe requests.
650 NetworkQuality estimated_median_network_quality_; 439 nqe::internal::NetworkQuality estimated_median_network_quality_;
651 440
652 // ExternalEstimateProvider that provides network quality using operating 441 // ExternalEstimateProvider that provides network quality using operating
653 // system APIs. May be NULL. 442 // system APIs. May be NULL.
654 const std::unique_ptr<ExternalEstimateProvider> external_estimate_provider_; 443 const std::unique_ptr<ExternalEstimateProvider> external_estimate_provider_;
655 444
656 // Observer lists for round trip times and throughput measurements. 445 // Observer lists for round trip times and throughput measurements.
657 base::ObserverList<RTTObserver> rtt_observer_list_; 446 base::ObserverList<RTTObserver> rtt_observer_list_;
658 base::ObserverList<ThroughputObserver> throughput_observer_list_; 447 base::ObserverList<ThroughputObserver> throughput_observer_list_;
659 448
660 std::unique_ptr<SocketPerformanceWatcherFactory> watcher_factory_; 449 std::unique_ptr<SocketPerformanceWatcherFactory> watcher_factory_;
661 450
662 base::ThreadChecker thread_checker_; 451 base::ThreadChecker thread_checker_;
663 452
664 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; 453 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
665 454
666 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); 455 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
667 }; 456 };
668 457
669 } // namespace net 458 } // namespace net
670 459
671 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 460 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698