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

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

Issue 1316863006: Populate EEP estimate in NQE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use EXPECT_TRUE instead of DCHECK Created 5 years, 3 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/base/external_estimate_provider.h ('k') | net/base/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_BASE_NETWORK_QUALITY_ESTIMATOR_H_ 5 #ifndef NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_
6 #define NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ 6 #define NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 bool allow_local_host_requests_for_tests, 142 bool allow_local_host_requests_for_tests,
143 bool allow_smaller_responses_for_tests); 143 bool allow_smaller_responses_for_tests);
144 144
145 // Returns true if the cached network quality estimate was successfully read. 145 // Returns true if the cached network quality estimate was successfully read.
146 bool ReadCachedNetworkQualityEstimate(); 146 bool ReadCachedNetworkQualityEstimate();
147 147
148 // NetworkChangeNotifier::ConnectionTypeObserver implementation: 148 // NetworkChangeNotifier::ConnectionTypeObserver implementation:
149 void OnConnectionTypeChanged( 149 void OnConnectionTypeChanged(
150 NetworkChangeNotifier::ConnectionType type) override; 150 NetworkChangeNotifier::ConnectionType type) override;
151 151
152 // ExternalEstimateProvider::UpdatedEstimateObserver implementation.
153 void OnUpdatedEstimateAvailable() override;
154
152 private: 155 private:
153 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); 156 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations);
154 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestKbpsRTTUpdates); 157 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestKbpsRTTUpdates);
155 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); 158 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation);
156 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); 159 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams);
157 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); 160 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam);
158 FRIEND_TEST_ALL_PREFIXES(URLRequestTestHTTP, NetworkQualityEstimator); 161 FRIEND_TEST_ALL_PREFIXES(URLRequestTestHTTP, NetworkQualityEstimator);
159 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, 162 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
160 PercentileSameTimestamps); 163 PercentileSameTimestamps);
161 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, 164 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
162 PercentileDifferentTimestamps); 165 PercentileDifferentTimestamps);
163 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); 166 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles);
164 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); 167 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching);
165 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, 168 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
166 TestLRUCacheMaximumSize); 169 TestLRUCacheMaximumSize);
167 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMedianRTTSince); 170 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMedianRTTSince);
171 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
172 TestExternalEstimateProvider);
173 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
174 TestExternalEstimateProviderMergeEstimates);
168 175
169 // NetworkQuality is used to cache the quality of a network connection. 176 // NetworkQuality is used to cache the quality of a network connection.
170 class NET_EXPORT_PRIVATE NetworkQuality { 177 class NET_EXPORT_PRIVATE NetworkQuality {
171 public: 178 public:
172 NetworkQuality(); 179 NetworkQuality();
173 // |rtt| is the estimate of the round trip time. 180 // |rtt| is the estimate of the round trip time.
174 // |downstream_throughput_kbps| is the estimate of the downstream 181 // |downstream_throughput_kbps| is the estimate of the downstream
175 // throughput. 182 // throughput.
176 NetworkQuality(const base::TimeDelta& rtt, 183 NetworkQuality(const base::TimeDelta& rtt,
177 int32_t downstream_throughput_kbps); 184 int32_t downstream_throughput_kbps);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 static const int kMinimumThroughputVariationParameterKbps = 1; 352 static const int kMinimumThroughputVariationParameterKbps = 1;
346 353
347 // Maximum size of the cache that holds network quality estimates. 354 // Maximum size of the cache that holds network quality estimates.
348 // Smaller size may reduce the cache hit rate due to frequent evictions. 355 // Smaller size may reduce the cache hit rate due to frequent evictions.
349 // Larger size may affect performance. 356 // Larger size may affect performance.
350 static const size_t kMaximumNetworkQualityCacheSize = 10; 357 static const size_t kMaximumNetworkQualityCacheSize = 10;
351 358
352 // Maximum number of observations that can be held in the ObservationBuffer. 359 // Maximum number of observations that can be held in the ObservationBuffer.
353 static const size_t kMaximumObservationsBufferSize = 300; 360 static const size_t kMaximumObservationsBufferSize = 300;
354 361
362 // Time duration (in milliseconds) after which the estimate provided by
363 // external estimate provider is considered stale.
364 static const int kExternalEstimateProviderFreshnessDurationMsec =
365 5 * 60 * 1000;
366
355 // Returns the RTT value to be used when the valid RTT is unavailable. Readers 367 // Returns the RTT value to be used when the valid RTT is unavailable. Readers
356 // should discard RTT if it is set to the value returned by |InvalidRTT()|. 368 // should discard RTT if it is set to the value returned by |InvalidRTT()|.
357 static const base::TimeDelta InvalidRTT(); 369 static const base::TimeDelta InvalidRTT();
358 370
359 // ExternalEstimateProvider::UpdatedEstimateObserver implementation: 371 // Queries the external estimate provider for the latest network quality
360 void OnUpdatedEstimateAvailable() override; 372 // estimates, and adds those estimates to the current observation buffer.
373 void QueryExternalEstimateProvider();
361 374
362 // Obtains operating parameters from the field trial parameters. 375 // Obtains operating parameters from the field trial parameters.
363 void ObtainOperatingParams( 376 void ObtainOperatingParams(
364 const std::map<std::string, std::string>& variation_params); 377 const std::map<std::string, std::string>& variation_params);
365 378
366 // Adds the default median RTT and downstream throughput estimate for the 379 // Adds the default median RTT and downstream throughput estimate for the
367 // current connection type to the observation buffer. 380 // current connection type to the observation buffer.
368 void AddDefaultEstimates(); 381 void AddDefaultEstimates();
369 382
370 // Returns an estimate of network quality at the specified |percentile|. 383 // Returns an estimate of network quality at the specified |percentile|.
(...skipping 18 matching lines...) Expand all
389 402
390 // Records the UMA related to RTT. 403 // Records the UMA related to RTT.
391 void RecordRTTUMA(int32_t estimated_value_msec, 404 void RecordRTTUMA(int32_t estimated_value_msec,
392 int32_t actual_value_msec) const; 405 int32_t actual_value_msec) const;
393 406
394 // Returns true only if |request| can be used for network quality estimation. 407 // Returns true only if |request| can be used for network quality estimation.
395 // Only the requests that go over network are considered to provide useful 408 // Only the requests that go over network are considered to provide useful
396 // observations. 409 // observations.
397 bool RequestProvidesUsefulObservations(const URLRequest& request) const; 410 bool RequestProvidesUsefulObservations(const URLRequest& request) const;
398 411
412 // Values of external estimate provider status. This enum must remain
413 // synchronized with the enum of the same name in
414 // metrics/histograms/histograms.xml.
415 enum NQEExternalEstimateProviderStatus {
416 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE,
417 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE,
418 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED,
419 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL,
420 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK,
421 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY
422 };
423
424 // Records the metrics related to external estimate provider.
425 void RecordExternalEstimateProviderMetrics(
426 NQEExternalEstimateProviderStatus status) const;
427
399 // Determines if the requests to local host can be used in estimating the 428 // Determines if the requests to local host can be used in estimating the
400 // network quality. Set to true only for tests. 429 // network quality. Set to true only for tests.
401 const bool allow_localhost_requests_; 430 const bool allow_localhost_requests_;
402 431
403 // Determines if the responses smaller than |kMinTransferSizeInBytes| 432 // Determines if the responses smaller than |kMinTransferSizeInBytes|
404 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the 433 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the
405 // network quality. Set to true only for tests. 434 // network quality. Set to true only for tests.
406 const bool allow_small_responses_; 435 const bool allow_small_responses_;
407 436
408 // Time when last connection change was observed. 437 // Time when last connection change was observed.
(...skipping 23 matching lines...) Expand all
432 // estimator field trial parameters. The observations are indexed by 461 // estimator field trial parameters. The observations are indexed by
433 // ConnectionType. 462 // ConnectionType.
434 NetworkQuality 463 NetworkQuality
435 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1]; 464 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1];
436 465
437 // Estimated network quality. Updated on mainframe requests. 466 // Estimated network quality. Updated on mainframe requests.
438 NetworkQuality estimated_median_network_quality_; 467 NetworkQuality estimated_median_network_quality_;
439 468
440 // ExternalEstimateProvider that provides network quality using operating 469 // ExternalEstimateProvider that provides network quality using operating
441 // system APIs. May be NULL. 470 // system APIs. May be NULL.
442 const scoped_ptr<ExternalEstimateProvider> external_estimates_provider_; 471 const scoped_ptr<ExternalEstimateProvider> external_estimate_provider_;
443 472
444 base::ThreadChecker thread_checker_; 473 base::ThreadChecker thread_checker_;
445 474
446 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); 475 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
447 }; 476 };
448 477
449 } // namespace net 478 } // namespace net
450 479
451 #endif // NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_ 480 #endif // NET_BASE_NETWORK_QUALITY_ESTIMATOR_H_
OLDNEW
« no previous file with comments | « net/base/external_estimate_provider.h ('k') | net/base/network_quality_estimator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698