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

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

Issue 2113363002: NQE: Add Transport RTT based GetECT algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODO Created 4 years, 5 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. 285 // ExternalEstimateProvider::UpdatedEstimateObserver implementation.
286 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt, 286 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt,
287 int32_t downstream_throughput_kbps, 287 int32_t downstream_throughput_kbps,
288 int32_t upstream_throughput_kbps) override; 288 int32_t upstream_throughput_kbps) override;
289 289
290 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at 290 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at
291 // the HTTP layer. Virtualized for testing. |rtt| should not be null. The RTT 291 // the HTTP layer. Virtualized for testing. |rtt| should not be null. The RTT
292 // at the HTTP layer measures the time from when the request was sent (this 292 // at the HTTP layer measures the time from when the request was sent (this
293 // happens after the connection is established) to the time when the response 293 // happens after the connection is established) to the time when the response
294 // headers were received. 294 // headers were received.
295 // TODO(tbansal): Change it to return HTTP RTT as base::TimeDelta.
295 virtual bool GetHttpRTTEstimate(base::TimeDelta* rtt) const 296 virtual bool GetHttpRTTEstimate(base::TimeDelta* rtt) const
296 WARN_UNUSED_RESULT; 297 WARN_UNUSED_RESULT;
297 298
298 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at 299 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at
299 // the transport layer. |rtt| should not be null. Virtualized for testing. 300 // the transport layer. |rtt| should not be null. Virtualized for testing.
301 // TODO(tbansal): Change it to return transport RTT as base::TimeDelta.
300 virtual bool GetTransportRTTEstimate(base::TimeDelta* rtt) const 302 virtual bool GetTransportRTTEstimate(base::TimeDelta* rtt) const
301 WARN_UNUSED_RESULT; 303 WARN_UNUSED_RESULT;
302 304
303 // Returns true if downlink throughput is available and sets |kbps| to 305 // Returns true if downlink throughput is available and sets |kbps| to
304 // estimated downlink throughput (in kilobits per second). 306 // estimated downlink throughput (in kilobits per second).
305 // Virtualized for testing. |kbps| should not be null. 307 // Virtualized for testing. |kbps| should not be null.
308 // TODO(tbansal): Change it to return throughput as int32.
306 virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const; 309 virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const;
307 310
308 // Returns true if median RTT at the HTTP layer is available and sets |rtt| 311 // Returns true if median RTT at the HTTP layer is available and sets |rtt|
309 // to the median of RTT observations since |start_time|. 312 // to the median of RTT observations since |start_time|.
310 // Virtualized for testing. |rtt| should not be null. The RTT at the HTTP 313 // Virtualized for testing. |rtt| should not be null. The RTT at the HTTP
311 // layer measures the time from when the request was sent (this happens after 314 // layer measures the time from when the request was sent (this happens after
312 // the connection is established) to the time when the response headers were 315 // the connection is established) to the time when the response headers were
313 // received. 316 // received.
317 // TODO(tbansal): Change it to return HTTP RTT as base::TimeDelta.
314 virtual bool GetRecentHttpRTTMedian(const base::TimeTicks& start_time, 318 virtual bool GetRecentHttpRTTMedian(const base::TimeTicks& start_time,
315 base::TimeDelta* rtt) const 319 base::TimeDelta* rtt) const
316 WARN_UNUSED_RESULT; 320 WARN_UNUSED_RESULT;
317 321
318 // Returns true if the median RTT at the transport layer is available and sets 322 // Returns true if the median RTT at the transport layer is available and sets
319 // |rtt| to the median of transport layer RTT observations since 323 // |rtt| to the median of transport layer RTT observations since
320 // |start_time|. |rtt| should not be null. Virtualized for testing. 324 // |start_time|. |rtt| should not be null. Virtualized for testing.
325 // TODO(tbansal): Change it to return transport RTT as base::TimeDelta.
321 virtual bool GetRecentTransportRTTMedian(const base::TimeTicks& start_time, 326 virtual bool GetRecentTransportRTTMedian(const base::TimeTicks& start_time,
322 base::TimeDelta* rtt) const 327 base::TimeDelta* rtt) const
323 WARN_UNUSED_RESULT; 328 WARN_UNUSED_RESULT;
324 329
325 // Returns true if median downstream throughput is available and sets |kbps| 330 // Returns true if median downstream throughput is available and sets |kbps|
326 // to the median of downstream throughput (in kilobits per second) 331 // to the median of downstream throughput (in kilobits per second)
327 // observations since |start_time|. Virtualized for testing. |kbps| 332 // observations since |start_time|. Virtualized for testing. |kbps|
328 // should not be null. Virtualized for testing. 333 // should not be null. Virtualized for testing.
334 // TODO(tbansal): Change it to return throughput as int32.
329 virtual bool GetRecentMedianDownlinkThroughputKbps( 335 virtual bool GetRecentMedianDownlinkThroughputKbps(
330 const base::TimeTicks& start_time, 336 const base::TimeTicks& start_time,
331 int32_t* kbps) const WARN_UNUSED_RESULT; 337 int32_t* kbps) const WARN_UNUSED_RESULT;
332 338
333 // Returns the list of intervals at which the accuracy of network quality 339 // Returns the list of intervals at which the accuracy of network quality
334 // prediction should be recorded. Virtualized for testing. 340 // prediction should be recorded. Virtualized for testing.
335 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() 341 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals()
336 const; 342 const;
337 343
338 // Overrides the tick clock used by |this| for testing. 344 // Overrides the tick clock used by |this| for testing.
(...skipping 26 matching lines...) Expand all
365 // This does not use a unordered_map or hash_map for code simplicity (key just 371 // This does not use a unordered_map or hash_map for code simplicity (key just
366 // implements operator<, rather than hash and equality) and because the map is 372 // implements operator<, rather than hash and equality) and because the map is
367 // tiny. 373 // tiny.
368 typedef std::map<NetworkID, nqe::internal::CachedNetworkQuality> 374 typedef std::map<NetworkID, nqe::internal::CachedNetworkQuality>
369 CachedNetworkQualities; 375 CachedNetworkQualities;
370 376
371 // Algorithms supported by network quality estimator for computing effective 377 // Algorithms supported by network quality estimator for computing effective
372 // connection type. 378 // connection type.
373 enum class EffectiveConnectionTypeAlgorithm { 379 enum class EffectiveConnectionTypeAlgorithm {
374 HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT = 0, 380 HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT = 0,
381 TRANSPORT_RTT_OR_DOWNSTREAM_THROUGHOUT,
375 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST 382 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST
376 }; 383 };
377 384
385 // Defines how a metric (e.g, transport RTT) should be used when computing
386 // the effective connection type.
387 enum class MetricUsage {
388 // The metric should not be used when computing the effective connection
389 // type.
390 DO_NOT_USE = 0,
391 // If the metric is available, then it should be used when computing the
392 // effective connection type.
393 USE_IF_AVAILABLE,
394 // The metric is required when computing the effective connection type.
395 // If the value of the metric is unavailable, effective connection type
396 // should be set to |EFFECTIVE_CONNECTION_TYPE_UNKNOWN|.
397 MUST_BE_USED,
398 };
399
378 // Map from algorithm names to EffectiveConnectionTypeAlgorithm. 400 // Map from algorithm names to EffectiveConnectionTypeAlgorithm.
401 // TODO(tbansal): Consider using an autogenerated enum using macros.
379 const std::map<std::string, EffectiveConnectionTypeAlgorithm> 402 const std::map<std::string, EffectiveConnectionTypeAlgorithm>
380 algorithm_name_to_enum_; 403 algorithm_name_to_enum_;
381 404
382 // The default algorithm to be used if the algorithm value is not available 405 // The default algorithm to be used if the algorithm value is not available
383 // through field trial parameters. 406 // through field trial parameters.
384 static const EffectiveConnectionTypeAlgorithm 407 static const EffectiveConnectionTypeAlgorithm
385 kDefaultEffectiveConnectionTypeAlgorithm = 408 kDefaultEffectiveConnectionTypeAlgorithm =
386 EffectiveConnectionTypeAlgorithm::HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT; 409 EffectiveConnectionTypeAlgorithm::HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT;
387 410
388 // Minimum valid value of the variation parameter that holds RTT (in 411 // Minimum valid value of the variation parameter that holds RTT (in
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 // Notify observers of a change in effective connection type. 494 // Notify observers of a change in effective connection type.
472 void NotifyObserversOfEffectiveConnectionTypeChanged(); 495 void NotifyObserversOfEffectiveConnectionTypeChanged();
473 496
474 // Records NQE accuracy metrics. |measuring_duration| should belong to the 497 // Records NQE accuracy metrics. |measuring_duration| should belong to the
475 // vector returned by AccuracyRecordingIntervals(). 498 // vector returned by AccuracyRecordingIntervals().
476 // RecordAccuracyAfterMainFrame should be called |measuring_duration| after a 499 // RecordAccuracyAfterMainFrame should be called |measuring_duration| after a
477 // main frame request is observed. 500 // main frame request is observed.
478 void RecordAccuracyAfterMainFrame(base::TimeDelta measuring_duration) const; 501 void RecordAccuracyAfterMainFrame(base::TimeDelta measuring_duration) const;
479 502
480 // Returns the effective type of the current connection based on only the 503 // Returns the effective type of the current connection based on only the
481 // samples observed after |start_time|. Uses HTTP RTT and downstream 504 // samples observed after |start_time|. May use HTTP RTT, transport RTT and
482 // throughput to compute the effective connection type, and requires both of 505 // downstream throughput to compute the effective connection type based on
483 // them to have a valid value. 506 // |http_rtt_metric|, |transport_rtt_metric| and
484 EffectiveConnectionType 507 // |downstream_throughput_kbps_metric|, respectively.
485 GetRecentEffectiveConnectionTypeHttpRTTAndDownstreamThroughput( 508 EffectiveConnectionType GetRecentEffectiveConnectionTypeUsingMetrics(
486 const base::TimeTicks& start_time) const; 509 const base::TimeTicks& start_time,
510 MetricUsage http_rtt_metric,
511 MetricUsage transport_rtt_metric,
512 MetricUsage downstream_throughput_kbps_metric) const;
487 513
488 // Values of external estimate provider status. This enum must remain 514 // Values of external estimate provider status. This enum must remain
489 // synchronized with the enum of the same name in 515 // synchronized with the enum of the same name in
490 // metrics/histograms/histograms.xml. 516 // metrics/histograms/histograms.xml.
491 enum NQEExternalEstimateProviderStatus { 517 enum NQEExternalEstimateProviderStatus {
492 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE, 518 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE,
493 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE, 519 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE,
494 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED, 520 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED,
495 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL, 521 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL,
496 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, 522 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 base::ThreadChecker thread_checker_; 635 base::ThreadChecker thread_checker_;
610 636
611 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; 637 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
612 638
613 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); 639 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
614 }; 640 };
615 641
616 } // namespace net 642 } // namespace net
617 643
618 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 644 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698