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

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: Rebased 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
« no previous file with comments | « net/nqe/network_quality.h ('k') | net/nqe/network_quality_estimator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Obtains the current cellular signal strength value and updates 503 // Obtains the current cellular signal strength value and updates
481 // |min_signal_strength_since_connection_change_| and 504 // |min_signal_strength_since_connection_change_| and
482 // |max_signal_strength_since_connection_change_|. 505 // |max_signal_strength_since_connection_change_|.
483 void UpdateSignalStrength(); 506 void UpdateSignalStrength();
484 507
485 // Returns the effective type of the current connection based on only the 508 // Returns the effective type of the current connection based on only the
486 // samples observed after |start_time|. Uses HTTP RTT and downstream 509 // samples observed after |start_time|. May use HTTP RTT, transport RTT and
487 // throughput to compute the effective connection type, and requires both of 510 // downstream throughput to compute the effective connection type based on
488 // them to have a valid value. 511 // |http_rtt_metric|, |transport_rtt_metric| and
489 EffectiveConnectionType 512 // |downstream_throughput_kbps_metric|, respectively.
490 GetRecentEffectiveConnectionTypeHttpRTTAndDownstreamThroughput( 513 EffectiveConnectionType GetRecentEffectiveConnectionTypeUsingMetrics(
491 const base::TimeTicks& start_time) const; 514 const base::TimeTicks& start_time,
515 MetricUsage http_rtt_metric,
516 MetricUsage transport_rtt_metric,
517 MetricUsage downstream_throughput_kbps_metric) const;
492 518
493 // Values of external estimate provider status. This enum must remain 519 // Values of external estimate provider status. This enum must remain
494 // synchronized with the enum of the same name in 520 // synchronized with the enum of the same name in
495 // metrics/histograms/histograms.xml. 521 // metrics/histograms/histograms.xml.
496 enum NQEExternalEstimateProviderStatus { 522 enum NQEExternalEstimateProviderStatus {
497 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE, 523 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE,
498 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE, 524 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE,
499 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED, 525 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED,
500 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL, 526 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL,
501 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, 527 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 base::ThreadChecker thread_checker_; 645 base::ThreadChecker thread_checker_;
620 646
621 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; 647 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
622 648
623 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); 649 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
624 }; 650 };
625 651
626 } // namespace net 652 } // namespace net
627 653
628 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 654 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
OLDNEW
« no previous file with comments | « net/nqe/network_quality.h ('k') | net/nqe/network_quality_estimator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698