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

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

Issue 2707633002: NQE: Cleanup the calls to the observation buffer (Closed)
Patch Set: ps Created 3 years, 10 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_estimator.h ('k') | no next file » | 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 #include "net/nqe/network_quality_estimator.h" 5 #include "net/nqe/network_quality_estimator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 correlation_uma_logging_probability_( 285 correlation_uma_logging_probability_(
286 nqe::internal::correlation_uma_logging_probability(variation_params)), 286 nqe::internal::correlation_uma_logging_probability(variation_params)),
287 forced_effective_connection_type_set_( 287 forced_effective_connection_type_set_(
288 nqe::internal::forced_effective_connection_type_set( 288 nqe::internal::forced_effective_connection_type_set(
289 variation_params)), 289 variation_params)),
290 forced_effective_connection_type_( 290 forced_effective_connection_type_(
291 nqe::internal::forced_effective_connection_type(variation_params)), 291 nqe::internal::forced_effective_connection_type(variation_params)),
292 persistent_cache_reading_enabled_( 292 persistent_cache_reading_enabled_(
293 nqe::internal::persistent_cache_reading_enabled(variation_params)), 293 nqe::internal::persistent_cache_reading_enabled(variation_params)),
294 event_creator_(net_log), 294 event_creator_(net_log),
295 disallowed_observation_sources_for_http_(
296 {NETWORK_QUALITY_OBSERVATION_SOURCE_TCP,
297 NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC,
298 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE,
299 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_TRANSPORT_FROM_PLATFORM}),
300 disallowed_observation_sources_for_transport_(
301 {NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP,
302 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_EXTERNAL_ESTIMATE,
303 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE,
304 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_HTTP_FROM_PLATFORM}),
295 weak_ptr_factory_(this) { 305 weak_ptr_factory_(this) {
296 // None of the algorithms can have an empty name. 306 // None of the algorithms can have an empty name.
297 DCHECK(algorithm_name_to_enum_.end() == 307 DCHECK(algorithm_name_to_enum_.end() ==
298 algorithm_name_to_enum_.find(std::string())); 308 algorithm_name_to_enum_.find(std::string()));
299 309
300 DCHECK_EQ(algorithm_name_to_enum_.size(), 310 DCHECK_EQ(algorithm_name_to_enum_.size(),
301 static_cast<size_t>(EffectiveConnectionTypeAlgorithm:: 311 static_cast<size_t>(EffectiveConnectionTypeAlgorithm::
302 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST)); 312 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST));
303 DCHECK_NE(EffectiveConnectionTypeAlgorithm:: 313 DCHECK_NE(EffectiveConnectionTypeAlgorithm::
304 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST, 314 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST,
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 899
890 base::TimeDelta rtt; 900 base::TimeDelta rtt;
891 if (GetRecentHttpRTT(base::TimeTicks(), &rtt)) { 901 if (GetRecentHttpRTT(base::TimeTicks(), &rtt)) {
892 // Add the 50th percentile value. 902 // Add the 50th percentile value.
893 base::HistogramBase* rtt_percentile = 903 base::HistogramBase* rtt_percentile =
894 GetHistogram("RTT.Percentile50.", current_network_id_.type, 10 * 1000); 904 GetHistogram("RTT.Percentile50.", current_network_id_.type, 10 * 1000);
895 rtt_percentile->Add(rtt.InMilliseconds()); 905 rtt_percentile->Add(rtt.InMilliseconds());
896 906
897 // Add the remaining percentile values. 907 // Add the remaining percentile values.
898 static const int kPercentiles[] = {0, 10, 90, 100}; 908 static const int kPercentiles[] = {0, 10, 90, 100};
899 std::vector<NetworkQualityObservationSource> disallowed_observation_sources;
900 disallowed_observation_sources.push_back(
901 NETWORK_QUALITY_OBSERVATION_SOURCE_TCP);
902 disallowed_observation_sources.push_back(
903 NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC);
904 disallowed_observation_sources.push_back(
905 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE);
906 disallowed_observation_sources.push_back(
907 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_TRANSPORT_FROM_PLATFORM);
908 for (size_t i = 0; i < arraysize(kPercentiles); ++i) { 909 for (size_t i = 0; i < arraysize(kPercentiles); ++i) {
909 rtt = GetRTTEstimateInternal(disallowed_observation_sources, 910 rtt = GetRTTEstimateInternal(disallowed_observation_sources_for_http_,
910 base::TimeTicks(), kPercentiles[i]); 911 base::TimeTicks(), kPercentiles[i]);
911 912
912 rtt_percentile = GetHistogram( 913 rtt_percentile = GetHistogram(
913 "RTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", 914 "RTT.Percentile" + base::IntToString(kPercentiles[i]) + ".",
914 current_network_id_.type, 10 * 1000); // 10 seconds 915 current_network_id_.type, 10 * 1000); // 10 seconds
915 rtt_percentile->Add(rtt.InMilliseconds()); 916 rtt_percentile->Add(rtt.InMilliseconds());
916 } 917 }
917 } 918 }
918 919
919 if (GetRecentTransportRTT(base::TimeTicks(), &rtt)) { 920 if (GetRecentTransportRTT(base::TimeTicks(), &rtt)) {
920 // Add the 50th percentile value. 921 // Add the 50th percentile value.
921 base::HistogramBase* transport_rtt_percentile = GetHistogram( 922 base::HistogramBase* transport_rtt_percentile = GetHistogram(
922 "TransportRTT.Percentile50.", current_network_id_.type, 10 * 1000); 923 "TransportRTT.Percentile50.", current_network_id_.type, 10 * 1000);
923 transport_rtt_percentile->Add(rtt.InMilliseconds()); 924 transport_rtt_percentile->Add(rtt.InMilliseconds());
924 925
925 // Add the remaining percentile values. 926 // Add the remaining percentile values.
926 static const int kPercentiles[] = {0, 10, 90, 100}; 927 static const int kPercentiles[] = {0, 10, 90, 100};
927 std::vector<NetworkQualityObservationSource> disallowed_observation_sources;
928 disallowed_observation_sources.push_back(
929 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP);
930 // Disallow external estimate provider since it provides RTT at HTTP layer.
931 disallowed_observation_sources.push_back(
932 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_EXTERNAL_ESTIMATE);
933 disallowed_observation_sources.push_back(
934 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
935 disallowed_observation_sources.push_back(
936 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_HTTP_FROM_PLATFORM);
937 for (size_t i = 0; i < arraysize(kPercentiles); ++i) { 928 for (size_t i = 0; i < arraysize(kPercentiles); ++i) {
938 rtt = GetRTTEstimateInternal(disallowed_observation_sources, 929 rtt =
939 base::TimeTicks(), kPercentiles[i]); 930 GetRTTEstimateInternal(disallowed_observation_sources_for_transport_,
931 base::TimeTicks(), kPercentiles[i]);
940 932
941 transport_rtt_percentile = GetHistogram( 933 transport_rtt_percentile = GetHistogram(
942 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", 934 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".",
943 current_network_id_.type, 10 * 1000); // 10 seconds 935 current_network_id_.type, 10 * 1000); // 10 seconds
944 transport_rtt_percentile->Add(rtt.InMilliseconds()); 936 transport_rtt_percentile->Add(rtt.InMilliseconds());
945 } 937 }
946 } 938 }
947 } 939 }
948 940
949 void NetworkQualityEstimator::RecordNetworkIDAvailability() const { 941 void NetworkQualityEstimator::RecordNetworkIDAvailability() const {
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 void NetworkQualityEstimator::RemoveRTTAndThroughputEstimatesObserver( 1276 void NetworkQualityEstimator::RemoveRTTAndThroughputEstimatesObserver(
1285 RTTAndThroughputEstimatesObserver* observer) { 1277 RTTAndThroughputEstimatesObserver* observer) {
1286 DCHECK(thread_checker_.CalledOnValidThread()); 1278 DCHECK(thread_checker_.CalledOnValidThread());
1287 rtt_and_throughput_estimates_observer_list_.RemoveObserver(observer); 1279 rtt_and_throughput_estimates_observer_list_.RemoveObserver(observer);
1288 } 1280 }
1289 1281
1290 bool NetworkQualityEstimator::GetRecentHttpRTT( 1282 bool NetworkQualityEstimator::GetRecentHttpRTT(
1291 const base::TimeTicks& start_time, 1283 const base::TimeTicks& start_time,
1292 base::TimeDelta* rtt) const { 1284 base::TimeDelta* rtt) const {
1293 DCHECK(thread_checker_.CalledOnValidThread()); 1285 DCHECK(thread_checker_.CalledOnValidThread());
1294 std::vector<NetworkQualityObservationSource> disallowed_observation_sources; 1286 *rtt = GetRTTEstimateInternal(disallowed_observation_sources_for_http_,
1295 disallowed_observation_sources.push_back( 1287 start_time, 50);
1296 NETWORK_QUALITY_OBSERVATION_SOURCE_TCP);
1297 disallowed_observation_sources.push_back(
1298 NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC);
1299 disallowed_observation_sources.push_back(
1300 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE);
1301 disallowed_observation_sources.push_back(
1302 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_TRANSPORT_FROM_PLATFORM);
1303 *rtt = GetRTTEstimateInternal(disallowed_observation_sources, start_time, 50);
1304 return (*rtt != nqe::internal::InvalidRTT()); 1288 return (*rtt != nqe::internal::InvalidRTT());
1305 } 1289 }
1306 1290
1307 bool NetworkQualityEstimator::GetRecentTransportRTT( 1291 bool NetworkQualityEstimator::GetRecentTransportRTT(
1308 const base::TimeTicks& start_time, 1292 const base::TimeTicks& start_time,
1309 base::TimeDelta* rtt) const { 1293 base::TimeDelta* rtt) const {
1310 DCHECK(thread_checker_.CalledOnValidThread()); 1294 DCHECK(thread_checker_.CalledOnValidThread());
1311 std::vector<NetworkQualityObservationSource> disallowed_observation_sources; 1295 *rtt = GetRTTEstimateInternal(disallowed_observation_sources_for_transport_,
1312 disallowed_observation_sources.push_back( 1296 start_time, 50);
1313 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP);
1314 // Disallow external estimate provider since it provides RTT at HTTP layer.
1315 disallowed_observation_sources.push_back(
1316 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_EXTERNAL_ESTIMATE);
1317 disallowed_observation_sources.push_back(
1318 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1319 disallowed_observation_sources.push_back(
1320 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_HTTP_FROM_PLATFORM);
1321
1322 *rtt = GetRTTEstimateInternal(disallowed_observation_sources, start_time, 50);
1323 return (*rtt != nqe::internal::InvalidRTT()); 1297 return (*rtt != nqe::internal::InvalidRTT());
1324 } 1298 }
1325 1299
1326 bool NetworkQualityEstimator::GetRecentDownlinkThroughputKbps( 1300 bool NetworkQualityEstimator::GetRecentDownlinkThroughputKbps(
1327 const base::TimeTicks& start_time, 1301 const base::TimeTicks& start_time,
1328 int32_t* kbps) const { 1302 int32_t* kbps) const {
1329 DCHECK(thread_checker_.CalledOnValidThread()); 1303 DCHECK(thread_checker_.CalledOnValidThread());
1330 *kbps = GetDownlinkThroughputKbpsEstimateInternal(start_time, 50); 1304 *kbps = GetDownlinkThroughputKbpsEstimateInternal(start_time, 50);
1331 return (*kbps != nqe::internal::kInvalidThroughput); 1305 return (*kbps != nqe::internal::kInvalidThroughput);
1332 } 1306 }
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1723 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1750 downstream_throughput_kbps_observations_.AddObservation( 1724 downstream_throughput_kbps_observations_.AddObservation(
1751 throughput_observation); 1725 throughput_observation);
1752 NotifyObserversOfThroughput(throughput_observation); 1726 NotifyObserversOfThroughput(throughput_observation);
1753 } 1727 }
1754 1728
1755 ComputeEffectiveConnectionType(); 1729 ComputeEffectiveConnectionType();
1756 } 1730 }
1757 1731
1758 } // namespace net 1732 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698