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

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

Issue 2107243003: NQE: Record correlation metric in UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed bengr comments 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 | « 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 int32_t* kbps) const WARN_UNUSED_RESULT; 331 int32_t* kbps) const WARN_UNUSED_RESULT;
332 332
333 // Returns the list of intervals at which the accuracy of network quality 333 // Returns the list of intervals at which the accuracy of network quality
334 // prediction should be recorded. Virtualized for testing. 334 // prediction should be recorded. Virtualized for testing.
335 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() 335 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals()
336 const; 336 const;
337 337
338 // Overrides the tick clock used by |this| for testing. 338 // Overrides the tick clock used by |this| for testing.
339 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); 339 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
340 340
341 // Returns a random double in the range [0.0, 1.0). Virtualized for testing.
342 virtual double RandDouble() const;
343
341 private: 344 private:
342 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); 345 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations);
343 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); 346 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation);
344 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); 347 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams);
345 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, 348 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
346 ObtainAlgorithmToUseFromParams); 349 ObtainAlgorithmToUseFromParams);
347 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); 350 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam);
348 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); 351 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles);
349 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); 352 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching);
350 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, 353 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, 499 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK,
497 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE, 500 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE,
498 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE, 501 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE,
499 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY 502 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY
500 }; 503 };
501 504
502 // Records the metrics related to external estimate provider. 505 // Records the metrics related to external estimate provider.
503 void RecordExternalEstimateProviderMetrics( 506 void RecordExternalEstimateProviderMetrics(
504 NQEExternalEstimateProviderStatus status) const; 507 NQEExternalEstimateProviderStatus status) const;
505 508
509 // Records a correlation metric that can be used for computing the correlation
510 // between HTTP-layer RTT, transport-layer RTT, throughput and the time
511 // taken to complete |request|.
512 void RecordCorrelationMetric(const URLRequest& request) const;
513
506 // Determines if the requests to local host can be used in estimating the 514 // Determines if the requests to local host can be used in estimating the
507 // network quality. Set to true only for tests. 515 // network quality. Set to true only for tests.
508 bool use_localhost_requests_; 516 bool use_localhost_requests_;
509 517
510 // Determines if the responses smaller than |kMinTransferSizeInBytes| 518 // Determines if the responses smaller than |kMinTransferSizeInBytes|
511 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the 519 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the
512 // network quality. Set to true only for tests. 520 // network quality. Set to true only for tests.
513 bool use_small_responses_; 521 bool use_small_responses_;
514 522
515 // The factor by which the weight of an observation reduces every second. 523 // The factor by which the weight of an observation reduces every second.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // fitting) may be used. 579 // fitting) may be used.
572 nqe::internal::NetworkQuality 580 nqe::internal::NetworkQuality
573 connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_LAST]; 581 connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_LAST];
574 582
575 // Latest time when the headers for a main frame request were received. 583 // Latest time when the headers for a main frame request were received.
576 base::TimeTicks last_main_frame_request_; 584 base::TimeTicks last_main_frame_request_;
577 585
578 // Estimated network quality when the response headers for the last mainframe 586 // Estimated network quality when the response headers for the last mainframe
579 // request were received. 587 // request were received.
580 nqe::internal::NetworkQuality estimated_quality_at_last_main_frame_; 588 nqe::internal::NetworkQuality estimated_quality_at_last_main_frame_;
581 EffectiveConnectionType effective_connection_type_at_last_main_frame_; 589 EffectiveConnectionType effective_connection_type_at_last_main_frame_;
bengr 2016/07/19 00:32:31 This seems like a bit of a layering violation for
tbansal1 2016/07/20 00:28:02 ack'ed. I can move it to Chrome but it is not clea
582 590
583 // ExternalEstimateProvider that provides network quality using operating 591 // ExternalEstimateProvider that provides network quality using operating
584 // system APIs. May be NULL. 592 // system APIs. May be NULL.
585 const std::unique_ptr<ExternalEstimateProvider> external_estimate_provider_; 593 const std::unique_ptr<ExternalEstimateProvider> external_estimate_provider_;
586 594
587 // Observer list for changes in effective connection type. 595 // Observer list for changes in effective connection type.
588 base::ObserverList<EffectiveConnectionTypeObserver> 596 base::ObserverList<EffectiveConnectionTypeObserver>
589 effective_connection_type_observer_list_; 597 effective_connection_type_observer_list_;
590 598
591 // Observer lists for round trip times and throughput measurements. 599 // Observer lists for round trip times and throughput measurements.
592 base::ObserverList<RTTObserver> rtt_observer_list_; 600 base::ObserverList<RTTObserver> rtt_observer_list_;
593 base::ObserverList<ThroughputObserver> throughput_observer_list_; 601 base::ObserverList<ThroughputObserver> throughput_observer_list_;
594 602
595 std::unique_ptr<SocketPerformanceWatcherFactory> watcher_factory_; 603 std::unique_ptr<SocketPerformanceWatcherFactory> watcher_factory_;
596 604
597 // Takes throughput measurements, and passes them back to |this| through the 605 // Takes throughput measurements, and passes them back to |this| through the
598 // provided callback. |this| stores the throughput observations in 606 // provided callback. |this| stores the throughput observations in
599 // |downstream_throughput_kbps_observations_|, which are later used for 607 // |downstream_throughput_kbps_observations_|, which are later used for
600 // estimating the throughput. 608 // estimating the throughput.
601 std::unique_ptr<nqe::internal::ThroughputAnalyzer> throughput_analyzer_; 609 std::unique_ptr<nqe::internal::ThroughputAnalyzer> throughput_analyzer_;
602 610
603 // Current effective connection type. It is updated on connection change 611 // Current effective connection type. It is updated on connection change
604 // events. It is also updated every time there is network traffic (provided 612 // events. It is also updated every time there is network traffic (provided
605 // the last computation was more than 613 // the last computation was more than
606 // |effective_connection_type_recomputation_interval_| ago). 614 // |effective_connection_type_recomputation_interval_| ago).
607 EffectiveConnectionType effective_connection_type_; 615 EffectiveConnectionType effective_connection_type_;
608 616
617 // It is costlier to add values to a sparse histogram. So, the correlation UMA
618 // is recorded with |correlation_uma_logging_probability_| since recording it
619 // in a sparse histogram for each request is unnecessary and cost-prohibitive.
620 // e.g., if it is 0.0, then the UMA will never be recorded. On the other hand,
621 // if it is 1.0, then it will be recorded for all valid HTTP requests.
622 const double correlation_uma_logging_probability_;
623
609 base::ThreadChecker thread_checker_; 624 base::ThreadChecker thread_checker_;
610 625
611 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; 626 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
612 627
613 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); 628 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
614 }; 629 };
615 630
616 } // namespace net 631 } // namespace net
617 632
618 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 633 #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