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

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

Issue 2020353002: Record NQE accuracy at main frame requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at 184 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at
185 // the HTTP layer. Virtualized for testing. |rtt| should not be null. The RTT 185 // the HTTP layer. Virtualized for testing. |rtt| should not be null. The RTT
186 // at the HTTP layer measures the time from when the request was sent (this 186 // at the HTTP layer measures the time from when the request was sent (this
187 // happens after the connection is established) to the time when the response 187 // happens after the connection is established) to the time when the response
188 // headers were received. 188 // headers were received.
189 virtual bool GetHttpRTTEstimate(base::TimeDelta* rtt) const 189 virtual bool GetHttpRTTEstimate(base::TimeDelta* rtt) const
190 WARN_UNUSED_RESULT; 190 WARN_UNUSED_RESULT;
191 191
192 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at 192 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at
193 // the transport layer. |rtt| should not be null. 193 // the transport layer. |rtt| should not be null.
194 bool GetTransportRTTEstimate(base::TimeDelta* rtt) const WARN_UNUSED_RESULT; 194 virtual bool GetTransportRTTEstimate(base::TimeDelta* rtt) const
bengr 2016/06/01 16:55:29 Add to the comment that this is virtualized for te
tbansal1 2016/06/01 21:49:02 Done.
195 WARN_UNUSED_RESULT;
195 196
196 // Returns true if downlink throughput is available and sets |kbps| to 197 // Returns true if downlink throughput is available and sets |kbps| to
197 // estimated downlink throughput (in kilobits per second). 198 // estimated downlink throughput (in kilobits per second).
198 // Virtualized for testing. |kbps| should not be null. 199 // Virtualized for testing. |kbps| should not be null.
199 virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const; 200 virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const;
200 201
201 // Notifies NetworkQualityEstimator that the response header of |request| has 202 // Notifies NetworkQualityEstimator that the response header of |request| has
202 // been received. 203 // been received.
203 void NotifyHeadersReceived(const URLRequest& request); 204 void NotifyHeadersReceived(const URLRequest& request);
204 205
(...skipping 14 matching lines...) Expand all
219 // layer measures the time from when the request was sent (this happens after 220 // layer measures the time from when the request was sent (this happens after
220 // the connection is established) to the time when the response headers were 221 // the connection is established) to the time when the response headers were
221 // received. 222 // received.
222 virtual bool GetRecentHttpRTTMedian(const base::TimeTicks& start_time, 223 virtual bool GetRecentHttpRTTMedian(const base::TimeTicks& start_time,
223 base::TimeDelta* rtt) const 224 base::TimeDelta* rtt) const
224 WARN_UNUSED_RESULT; 225 WARN_UNUSED_RESULT;
225 226
226 // Returns true if the median RTT at the transport layer is available and sets 227 // Returns true if the median RTT at the transport layer is available and sets
227 // |rtt| to the median of transport layer RTT observations since 228 // |rtt| to the median of transport layer RTT observations since
228 // |start_time|. |rtt| should not be null. 229 // |start_time|. |rtt| should not be null.
229 bool GetRecentTransportRTTMedian(const base::TimeTicks& start_time, 230 virtual bool GetRecentTransportRTTMedian(const base::TimeTicks& start_time,
bengr 2016/06/01 16:55:29 Add to the comment that this is virtualized for te
tbansal1 2016/06/01 21:49:02 Done.
230 base::TimeDelta* rtt) const 231 base::TimeDelta* rtt) const
231 WARN_UNUSED_RESULT; 232 WARN_UNUSED_RESULT;
232 233
233 // Returns true if median downstream throughput is available and sets |kbps| 234 // Returns true if median downstream throughput is available and sets |kbps|
234 // to the median of downstream throughput (in kilobits per second) 235 // to the median of downstream throughput (in kilobits per second)
235 // observations since |start_time|. Virtualized for testing. |kbps| 236 // observations since |start_time|. Virtualized for testing. |kbps|
236 // should not be null. 237 // should not be null.
237 virtual bool GetRecentMedianDownlinkThroughputKbps( 238 virtual bool GetRecentMedianDownlinkThroughputKbps(
238 const base::TimeTicks& start_time, 239 const base::TimeTicks& start_time,
239 int32_t* kbps) const WARN_UNUSED_RESULT; 240 int32_t* kbps) const WARN_UNUSED_RESULT;
240 241
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 304
304 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. 305 // ExternalEstimateProvider::UpdatedEstimateObserver implementation.
305 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt, 306 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt,
306 int32_t downstream_throughput_kbps, 307 int32_t downstream_throughput_kbps,
307 int32_t upstream_throughput_kbps) override; 308 int32_t upstream_throughput_kbps) override;
308 309
309 // Return a string equivalent to |type|. 310 // Return a string equivalent to |type|.
310 const char* GetNameForEffectiveConnectionType( 311 const char* GetNameForEffectiveConnectionType(
311 EffectiveConnectionType type) const; 312 EffectiveConnectionType type) const;
312 313
314 // Virtualized for testing. Returns the list of intervals at which accuracy of
bengr 2016/06/01 16:55:30 nits: which -> which the Move the first sentence t
tbansal1 2016/06/01 21:49:02 Done.
315 // network quality prediction should be recorded.
316 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals()
317 const;
318
313 // Overrides the tick clock used by |this| for testing. 319 // Overrides the tick clock used by |this| for testing.
314 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); 320 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
315 321
316 private: 322 private:
317 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); 323 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations);
318 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); 324 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation);
319 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); 325 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams);
320 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); 326 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam);
321 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); 327 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles);
322 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); 328 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // Returns true only if the |request| can be used for RTT estimation. 438 // Returns true only if the |request| can be used for RTT estimation.
433 bool RequestProvidesRTTObservation(const URLRequest& request) const; 439 bool RequestProvidesRTTObservation(const URLRequest& request) const;
434 440
435 // Recomputes effective connection type, if it was computed more than the 441 // Recomputes effective connection type, if it was computed more than the
436 // specified duration ago, or if there has been a connection change recently. 442 // specified duration ago, or if there has been a connection change recently.
437 void MaybeRecomputeEffectiveConnectionType(); 443 void MaybeRecomputeEffectiveConnectionType();
438 444
439 // Notify observers of a change in effective connection type. 445 // Notify observers of a change in effective connection type.
440 void NotifyObserversOfEffectiveConnectionTypeChanged(); 446 void NotifyObserversOfEffectiveConnectionTypeChanged();
441 447
448 // Records NQE accuracy metrics. |measuring_duration| should belong to the
449 // vector returned by AccuracyRecordingIntervals().
450 // RecordAccuracyAfterMainFrame should be called |measuring_duration| after a
451 // main frame request is observed.
452 void RecordAccuracyAfterMainFrame(
453 const base::TimeDelta& measuring_duration) const;
454
442 // Values of external estimate provider status. This enum must remain 455 // Values of external estimate provider status. This enum must remain
443 // synchronized with the enum of the same name in 456 // synchronized with the enum of the same name in
444 // metrics/histograms/histograms.xml. 457 // metrics/histograms/histograms.xml.
445 enum NQEExternalEstimateProviderStatus { 458 enum NQEExternalEstimateProviderStatus {
446 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE, 459 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE,
447 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE, 460 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE,
448 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED, 461 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED,
449 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL, 462 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL,
450 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, 463 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK,
451 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE, 464 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE,
(...skipping 20 matching lines...) Expand all
472 // Tick clock used by the network quality estimator. 485 // Tick clock used by the network quality estimator.
473 std::unique_ptr<base::TickClock> tick_clock_; 486 std::unique_ptr<base::TickClock> tick_clock_;
474 487
475 // Minimum duration between two consecutive computations of effective 488 // Minimum duration between two consecutive computations of effective
476 // connection type. Set to non-zero value as a performance optimization. 489 // connection type. Set to non-zero value as a performance optimization.
477 const base::TimeDelta effective_connection_type_recomputation_interval_; 490 const base::TimeDelta effective_connection_type_recomputation_interval_;
478 491
479 // Time when the effective connection type was last computed. 492 // Time when the effective connection type was last computed.
480 base::TimeTicks last_effective_connection_type_computation_; 493 base::TimeTicks last_effective_connection_type_computation_;
481 494
495 // Intervals after the main frame request arrives at which accuracy of network
496 // quality prediction is recorded.
497 std::vector<base::TimeDelta> accuracy_recording_intervals_;
498
482 // Time when last connection change was observed. 499 // Time when last connection change was observed.
483 base::TimeTicks last_connection_change_; 500 base::TimeTicks last_connection_change_;
484 501
485 // ID of the current network. 502 // ID of the current network.
486 NetworkID current_network_id_; 503 NetworkID current_network_id_;
487 504
488 // Peak network quality (fastest round-trip-time (RTT) and highest 505 // Peak network quality (fastest round-trip-time (RTT) and highest
489 // downstream throughput) measured since last connectivity change. RTT is 506 // downstream throughput) measured since last connectivity change. RTT is
490 // measured from time the request is sent until the first byte received. 507 // measured from time the request is sent until the first byte received.
491 // The accuracy is decreased by ignoring these factors: 508 // The accuracy is decreased by ignoring these factors:
(...skipping 17 matching lines...) Expand all
509 nqe::internal::NetworkQuality 526 nqe::internal::NetworkQuality
510 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1]; 527 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1];
511 528
512 // Thresholds for different effective connection types obtained from field 529 // Thresholds for different effective connection types obtained from field
513 // trial variation params. These thresholds encode how different connection 530 // trial variation params. These thresholds encode how different connection
514 // types behave in general. In future, complex encodings (e.g., curve 531 // types behave in general. In future, complex encodings (e.g., curve
515 // fitting) may be used. 532 // fitting) may be used.
516 nqe::internal::NetworkQuality 533 nqe::internal::NetworkQuality
517 connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_LAST]; 534 connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_LAST];
518 535
536 // Latest time when the headers for a main frame request were received.
537 base::TimeTicks last_main_frame_request_;
538
519 // Estimated network quality. Updated on mainframe requests. 539 // Estimated network quality. Updated on mainframe requests.
520 nqe::internal::NetworkQuality estimated_median_network_quality_; 540 nqe::internal::NetworkQuality estimated_quality_main_frame_;
bengr 2016/06/01 16:55:29 estimated_quality_at_last_main_frame_request_? or
tbansal1 2016/06/01 21:49:02 Done.
521 541
522 // ExternalEstimateProvider that provides network quality using operating 542 // ExternalEstimateProvider that provides network quality using operating
523 // system APIs. May be NULL. 543 // system APIs. May be NULL.
524 const std::unique_ptr<ExternalEstimateProvider> external_estimate_provider_; 544 const std::unique_ptr<ExternalEstimateProvider> external_estimate_provider_;
525 545
526 // Observer list for changes in effective connection type. 546 // Observer list for changes in effective connection type.
527 base::ObserverList<EffectiveConnectionTypeObserver> 547 base::ObserverList<EffectiveConnectionTypeObserver>
528 effective_connection_type_observer_list_; 548 effective_connection_type_observer_list_;
529 549
530 // Observer lists for round trip times and throughput measurements. 550 // Observer lists for round trip times and throughput measurements.
(...skipping 17 matching lines...) Expand all
548 base::ThreadChecker thread_checker_; 568 base::ThreadChecker thread_checker_;
549 569
550 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; 570 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
551 571
552 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); 572 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
553 }; 573 };
554 574
555 } // namespace net 575 } // namespace net
556 576
557 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 577 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
OLDNEW
« no previous file with comments | « no previous file | net/nqe/network_quality_estimator.cc » ('j') | net/nqe/network_quality_estimator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698