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

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

Issue 2032443003: NQE: Allow algorithm to be set using variation params (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fix in DCHECK evaluation Created 4 years, 6 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 | « no previous file | 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() 315 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals()
316 const; 316 const;
317 317
318 // Overrides the tick clock used by |this| for testing. 318 // Overrides the tick clock used by |this| for testing.
319 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); 319 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
320 320
321 private: 321 private:
322 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); 322 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations);
323 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); 323 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation);
324 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); 324 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams);
325 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
326 ObtainAlgorithmToUseFromParams);
325 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); 327 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam);
326 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); 328 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles);
327 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); 329 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching);
328 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, 330 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
329 TestLRUCacheMaximumSize); 331 TestLRUCacheMaximumSize);
330 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMetricsSince); 332 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMetricsSince);
331 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, 333 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
332 TestExternalEstimateProviderMergeEstimates); 334 TestExternalEstimateProviderMergeEstimates);
333 335
334 // Value of round trip time observations is in base::TimeDelta. 336 // Value of round trip time observations is in base::TimeDelta.
335 typedef nqe::internal::Observation<base::TimeDelta> RttObservation; 337 typedef nqe::internal::Observation<base::TimeDelta> RttObservation;
336 typedef nqe::internal::ObservationBuffer<base::TimeDelta> 338 typedef nqe::internal::ObservationBuffer<base::TimeDelta>
337 RttObservationBuffer; 339 RttObservationBuffer;
338 340
339 // Value of throughput observations is in kilobits per second. 341 // Value of throughput observations is in kilobits per second.
340 typedef nqe::internal::Observation<int32_t> ThroughputObservation; 342 typedef nqe::internal::Observation<int32_t> ThroughputObservation;
341 typedef nqe::internal::ObservationBuffer<int32_t> ThroughputObservationBuffer; 343 typedef nqe::internal::ObservationBuffer<int32_t> ThroughputObservationBuffer;
342 344
343 // This does not use a unordered_map or hash_map for code simplicity (key just 345 // This does not use a unordered_map or hash_map for code simplicity (key just
344 // implements operator<, rather than hash and equality) and because the map is 346 // implements operator<, rather than hash and equality) and because the map is
345 // tiny. 347 // tiny.
346 typedef std::map<NetworkID, nqe::internal::CachedNetworkQuality> 348 typedef std::map<NetworkID, nqe::internal::CachedNetworkQuality>
347 CachedNetworkQualities; 349 CachedNetworkQualities;
348 350
351 // Algorithms supported by network quality estimator for computing effective
352 // connection type.
353 enum class EffectiveConnectionTypeAlgorithm {
354 HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT = 0,
355 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST
356 };
357
358 // Map from algorithm names to EffectiveConnectionTypeAlgorithm.
359 const std::map<std::string, EffectiveConnectionTypeAlgorithm>
360 algorithm_name_to_enum_;
361
362 // The default algorithm to be used if the algorithm value is not available
363 // through field trial parameters.
364 static const EffectiveConnectionTypeAlgorithm
365 kDefaultEffectiveConnectionTypeAlgorithm =
366 EffectiveConnectionTypeAlgorithm::HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT;
367
349 // Minimum valid value of the variation parameter that holds RTT (in 368 // Minimum valid value of the variation parameter that holds RTT (in
350 // milliseconds) values. 369 // milliseconds) values.
351 static const int kMinimumRTTVariationParameterMsec = 1; 370 static const int kMinimumRTTVariationParameterMsec = 1;
352 371
353 // Minimum valid value of the variation parameter that holds throughput (in 372 // Minimum valid value of the variation parameter that holds throughput (in
354 // kilobits per second) values. 373 // kilobits per second) values.
355 static const int kMinimumThroughputVariationParameterKbps = 1; 374 static const int kMinimumThroughputVariationParameterKbps = 1;
356 375
357 // Maximum size of the cache that holds network quality estimates. 376 // Maximum size of the cache that holds network quality estimates.
358 // Smaller size may reduce the cache hit rate due to frequent evictions. 377 // Smaller size may reduce the cache hit rate due to frequent evictions.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 455
437 // Notify observers of a change in effective connection type. 456 // Notify observers of a change in effective connection type.
438 void NotifyObserversOfEffectiveConnectionTypeChanged(); 457 void NotifyObserversOfEffectiveConnectionTypeChanged();
439 458
440 // Records NQE accuracy metrics. |measuring_duration| should belong to the 459 // Records NQE accuracy metrics. |measuring_duration| should belong to the
441 // vector returned by AccuracyRecordingIntervals(). 460 // vector returned by AccuracyRecordingIntervals().
442 // RecordAccuracyAfterMainFrame should be called |measuring_duration| after a 461 // RecordAccuracyAfterMainFrame should be called |measuring_duration| after a
443 // main frame request is observed. 462 // main frame request is observed.
444 void RecordAccuracyAfterMainFrame(base::TimeDelta measuring_duration) const; 463 void RecordAccuracyAfterMainFrame(base::TimeDelta measuring_duration) const;
445 464
465 // Returns the effective type of the current connection based on only the
466 // samples observed after |start_time|. Uses HTTP RTT and downstream
467 // throughput to compute the effective connection type, and requires both of
468 // them to have a valid value.
469 EffectiveConnectionType
470 GetRecentEffectiveConnectionTypeHttpRTTAndDownstreamThroughput(
471 const base::TimeTicks& start_time) const;
472
446 // Values of external estimate provider status. This enum must remain 473 // Values of external estimate provider status. This enum must remain
447 // synchronized with the enum of the same name in 474 // synchronized with the enum of the same name in
448 // metrics/histograms/histograms.xml. 475 // metrics/histograms/histograms.xml.
449 enum NQEExternalEstimateProviderStatus { 476 enum NQEExternalEstimateProviderStatus {
450 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE, 477 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE,
451 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE, 478 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE,
452 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED, 479 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED,
453 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL, 480 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL,
454 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, 481 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK,
455 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE, 482 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE,
(...skipping 10 matching lines...) Expand all
466 const bool use_localhost_requests_; 493 const bool use_localhost_requests_;
467 494
468 // Determines if the responses smaller than |kMinTransferSizeInBytes| 495 // Determines if the responses smaller than |kMinTransferSizeInBytes|
469 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the 496 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the
470 // network quality. Set to true only for tests. 497 // network quality. Set to true only for tests.
471 const bool use_small_responses_; 498 const bool use_small_responses_;
472 499
473 // The factor by which the weight of an observation reduces every second. 500 // The factor by which the weight of an observation reduces every second.
474 const double weight_multiplier_per_second_; 501 const double weight_multiplier_per_second_;
475 502
503 // Algorithm to use for computing effective connection type. The value is
504 // obtained from field trial parameters. If the value from field trial
505 // parameters is unavailable, it is set to
506 // kDefaultEffectiveConnectionTypeAlgorithm.
507 const EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_;
508
476 // Tick clock used by the network quality estimator. 509 // Tick clock used by the network quality estimator.
477 std::unique_ptr<base::TickClock> tick_clock_; 510 std::unique_ptr<base::TickClock> tick_clock_;
478 511
479 // Minimum duration between two consecutive computations of effective 512 // Minimum duration between two consecutive computations of effective
480 // connection type. Set to non-zero value as a performance optimization. 513 // connection type. Set to non-zero value as a performance optimization.
481 const base::TimeDelta effective_connection_type_recomputation_interval_; 514 const base::TimeDelta effective_connection_type_recomputation_interval_;
482 515
483 // Time when the effective connection type was last computed. 516 // Time when the effective connection type was last computed.
484 base::TimeTicks last_effective_connection_type_computation_; 517 base::TimeTicks last_effective_connection_type_computation_;
485 518
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 base::ThreadChecker thread_checker_; 593 base::ThreadChecker thread_checker_;
561 594
562 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; 595 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
563 596
564 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); 597 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
565 }; 598 };
566 599
567 } // namespace net 600 } // namespace net
568 601
569 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 602 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
OLDNEW
« no previous file with comments | « no previous file | net/nqe/network_quality_estimator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698