Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 base::ThreadTaskRunnerHandle::Get(), | 338 base::ThreadTaskRunnerHandle::Get(), |
| 339 nqe::internal::GetMinSocketWatcherNotificationInterval(variation_params), | 339 nqe::internal::GetMinSocketWatcherNotificationInterval(variation_params), |
| 340 base::Bind(&NetworkQualityEstimator::OnUpdatedRTTAvailable, | 340 base::Bind(&NetworkQualityEstimator::OnUpdatedRTTAvailable, |
| 341 base::Unretained(this)), | 341 base::Unretained(this)), |
| 342 tick_clock_.get())); | 342 tick_clock_.get())); |
| 343 | 343 |
| 344 // Record accuracy after a 15 second interval. The values used here must | 344 // Record accuracy after a 15 second interval. The values used here must |
| 345 // remain in sync with the suffixes specified in | 345 // remain in sync with the suffixes specified in |
| 346 // tools/metrics/histograms/histograms.xml. | 346 // tools/metrics/histograms/histograms.xml. |
| 347 accuracy_recording_intervals_.push_back(base::TimeDelta::FromSeconds(15)); | 347 accuracy_recording_intervals_.push_back(base::TimeDelta::FromSeconds(15)); |
| 348 | |
| 349 for (int i = 0; i < STATISTIC_LAST; ++i) | |
| 350 http_rtt_at_last_main_frame_[i] = nqe::internal::InvalidRTT(); | |
| 348 } | 351 } |
| 349 | 352 |
| 350 void NetworkQualityEstimator::ObtainOperatingParams( | 353 void NetworkQualityEstimator::ObtainOperatingParams( |
| 351 const std::map<std::string, std::string>& variation_params) { | 354 const std::map<std::string, std::string>& variation_params) { |
| 352 DCHECK(thread_checker_.CalledOnValidThread()); | 355 DCHECK(thread_checker_.CalledOnValidThread()); |
| 353 nqe::internal::ObtainDefaultObservations(variation_params, | 356 nqe::internal::ObtainDefaultObservations(variation_params, |
| 354 default_observations_); | 357 default_observations_); |
| 355 nqe::internal::ObtainEffectiveConnectionTypeModelParams( | 358 nqe::internal::ObtainEffectiveConnectionTypeModelParams( |
| 356 variation_params, connection_thresholds_); | 359 variation_params, connection_thresholds_); |
| 357 nqe::internal::ObtainTypicalNetworkQuality(typical_network_quality_); | 360 nqe::internal::ObtainTypicalNetworkQuality(typical_network_quality_); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 // request. | 421 // request. |
| 419 // TODO(tbansal): Refactor this to a separate method. | 422 // TODO(tbansal): Refactor this to a separate method. |
| 420 if (request.load_flags() & LOAD_MAIN_FRAME_DEPRECATED) { | 423 if (request.load_flags() & LOAD_MAIN_FRAME_DEPRECATED) { |
| 421 base::TimeTicks now = tick_clock_->NowTicks(); | 424 base::TimeTicks now = tick_clock_->NowTicks(); |
| 422 last_main_frame_request_ = now; | 425 last_main_frame_request_ = now; |
| 423 | 426 |
| 424 MaybeComputeEffectiveConnectionType(); | 427 MaybeComputeEffectiveConnectionType(); |
| 425 effective_connection_type_at_last_main_frame_ = effective_connection_type_; | 428 effective_connection_type_at_last_main_frame_ = effective_connection_type_; |
| 426 estimated_quality_at_last_main_frame_ = network_quality_; | 429 estimated_quality_at_last_main_frame_ = network_quality_; |
| 427 | 430 |
| 431 // Record the HTTP at the last main frame for experimental statistics. | |
| 432 for (int i = 0; i < STATISTIC_LAST; ++i) { | |
| 433 Statistic statistic = static_cast<Statistic>(i); | |
| 434 switch (statistic) { | |
| 435 case STATISTIC_LAST: | |
| 436 NOTREACHED(); | |
| 437 break; | |
| 438 case STATISTIC_WEIGHTED_AVERAGE: | |
| 439 http_rtt_at_last_main_frame_[i] = | |
| 440 GetRTTEstimateInternal(disallowed_observation_sources_for_http_, | |
| 441 base::TimeTicks(), statistic, 50); | |
| 442 break; | |
| 443 } | |
| 444 } | |
| 445 | |
| 428 // Post the tasks which will run in the future and record the estimation | 446 // Post the tasks which will run in the future and record the estimation |
| 429 // accuracy based on the observations received between now and the time of | 447 // accuracy based on the observations received between now and the time of |
| 430 // task execution. Posting the task at different intervals makes it | 448 // task execution. Posting the task at different intervals makes it |
| 431 // possible to measure the accuracy by comparing the estimate with the | 449 // possible to measure the accuracy by comparing the estimate with the |
| 432 // observations received over intervals of varying durations. | 450 // observations received over intervals of varying durations. |
| 433 for (const base::TimeDelta& measuring_delay : | 451 for (const base::TimeDelta& measuring_delay : |
| 434 GetAccuracyRecordingIntervals()) { | 452 GetAccuracyRecordingIntervals()) { |
| 435 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 453 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 436 FROM_HERE, | 454 FROM_HERE, |
| 437 base::Bind(&NetworkQualityEstimator::RecordAccuracyAfterMainFrame, | 455 base::Bind(&NetworkQualityEstimator::RecordAccuracyAfterMainFrame, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 // time. Returning here ensures that we do not take inaccurate readings. | 526 // time. Returning here ensures that we do not take inaccurate readings. |
| 509 if (now - last_main_frame_request_ > 2 * measuring_duration) | 527 if (now - last_main_frame_request_ > 2 * measuring_duration) |
| 510 return; | 528 return; |
| 511 | 529 |
| 512 // Do not record accuracy if there was a connection change since the last main | 530 // Do not record accuracy if there was a connection change since the last main |
| 513 // frame request. | 531 // frame request. |
| 514 if (last_main_frame_request_ <= last_connection_change_) | 532 if (last_main_frame_request_ <= last_connection_change_) |
| 515 return; | 533 return; |
| 516 | 534 |
| 517 base::TimeDelta recent_http_rtt; | 535 base::TimeDelta recent_http_rtt; |
| 536 | |
| 537 // Record the HTTP prediction accuracy for experimental statistics. | |
| 538 for (int i = 0; i < STATISTIC_LAST; ++i) { | |
| 539 Statistic statistic = static_cast<Statistic>(i); | |
| 540 switch (statistic) { | |
|
RyanSturm
2017/02/24 19:54:18
nit: can you get rid of this switch statement if y
tbansal1
2017/02/25 03:04:01
Done.
| |
| 541 case STATISTIC_LAST: | |
| 542 NOTREACHED(); | |
| 543 break; | |
| 544 case STATISTIC_WEIGHTED_AVERAGE: | |
| 545 recent_http_rtt = | |
| 546 GetRTTEstimateInternal(disallowed_observation_sources_for_http_, | |
| 547 last_main_frame_request_, statistic, 50); | |
| 548 if (recent_http_rtt != nqe::internal::InvalidRTT() && | |
| 549 http_rtt_at_last_main_frame_[i] != nqe::internal::InvalidRTT()) { | |
| 550 int estimated_observed_diff_milliseconds = | |
| 551 http_rtt_at_last_main_frame_[i].InMilliseconds() - | |
| 552 recent_http_rtt.InMilliseconds(); | |
| 553 | |
| 554 RecordRTTAccuracy("NQE.WeightedAverage.Accuracy.HttpRTT", | |
| 555 estimated_observed_diff_milliseconds, | |
| 556 measuring_duration, recent_http_rtt); | |
| 557 } | |
| 558 break; | |
| 559 } | |
| 560 } | |
| 561 | |
| 518 if (!GetRecentHttpRTT(last_main_frame_request_, &recent_http_rtt)) | 562 if (!GetRecentHttpRTT(last_main_frame_request_, &recent_http_rtt)) |
| 519 recent_http_rtt = nqe::internal::InvalidRTT(); | 563 recent_http_rtt = nqe::internal::InvalidRTT(); |
| 520 | 564 |
| 521 if (estimated_quality_at_last_main_frame_.http_rtt() != | 565 if (estimated_quality_at_last_main_frame_.http_rtt() != |
| 522 nqe::internal::InvalidRTT() && | 566 nqe::internal::InvalidRTT() && |
| 523 recent_http_rtt != nqe::internal::InvalidRTT()) { | 567 recent_http_rtt != nqe::internal::InvalidRTT()) { |
| 524 const int estimated_observed_diff_milliseconds = | 568 const int estimated_observed_diff_milliseconds = |
| 525 estimated_quality_at_last_main_frame_.http_rtt().InMilliseconds() - | 569 estimated_quality_at_last_main_frame_.http_rtt().InMilliseconds() - |
| 526 recent_http_rtt.InMilliseconds(); | 570 recent_http_rtt.InMilliseconds(); |
| 527 | 571 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 843 current_network_id_ = GetCurrentNetworkID(); | 887 current_network_id_ = GetCurrentNetworkID(); |
| 844 RecordNetworkIDAvailability(); | 888 RecordNetworkIDAvailability(); |
| 845 | 889 |
| 846 MaybeQueryExternalEstimateProvider(); | 890 MaybeQueryExternalEstimateProvider(); |
| 847 | 891 |
| 848 // Read any cached estimates for the new network. If cached estimates are | 892 // Read any cached estimates for the new network. If cached estimates are |
| 849 // unavailable, add the default estimates. | 893 // unavailable, add the default estimates. |
| 850 if (!ReadCachedNetworkQualityEstimate()) | 894 if (!ReadCachedNetworkQualityEstimate()) |
| 851 AddDefaultEstimates(); | 895 AddDefaultEstimates(); |
| 852 estimated_quality_at_last_main_frame_ = nqe::internal::NetworkQuality(); | 896 estimated_quality_at_last_main_frame_ = nqe::internal::NetworkQuality(); |
| 897 | |
| 898 for (int i = 0; i < STATISTIC_LAST; ++i) | |
| 899 http_rtt_at_last_main_frame_[i] = nqe::internal::InvalidRTT(); | |
| 900 | |
| 853 throughput_analyzer_->OnConnectionTypeChanged(); | 901 throughput_analyzer_->OnConnectionTypeChanged(); |
| 854 MaybeComputeEffectiveConnectionType(); | 902 MaybeComputeEffectiveConnectionType(); |
| 855 } | 903 } |
| 856 | 904 |
| 857 void NetworkQualityEstimator::MaybeQueryExternalEstimateProvider() const { | 905 void NetworkQualityEstimator::MaybeQueryExternalEstimateProvider() const { |
| 858 // Query the external estimate provider on certain connection types. Once the | 906 // Query the external estimate provider on certain connection types. Once the |
| 859 // updated estimates are available, OnUpdatedEstimateAvailable will be called | 907 // updated estimates are available, OnUpdatedEstimateAvailable will be called |
| 860 // by |external_estimate_provider_| with updated estimates. | 908 // by |external_estimate_provider_| with updated estimates. |
| 861 if (external_estimate_provider_ && | 909 if (external_estimate_provider_ && |
| 862 current_network_id_.type != NetworkChangeNotifier::CONNECTION_NONE && | 910 current_network_id_.type != NetworkChangeNotifier::CONNECTION_NONE && |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 base::TimeDelta rtt; | 949 base::TimeDelta rtt; |
| 902 if (GetRecentHttpRTT(base::TimeTicks(), &rtt)) { | 950 if (GetRecentHttpRTT(base::TimeTicks(), &rtt)) { |
| 903 // Add the 50th percentile value. | 951 // Add the 50th percentile value. |
| 904 base::HistogramBase* rtt_percentile = | 952 base::HistogramBase* rtt_percentile = |
| 905 GetHistogram("RTT.Percentile50.", current_network_id_.type, 10 * 1000); | 953 GetHistogram("RTT.Percentile50.", current_network_id_.type, 10 * 1000); |
| 906 rtt_percentile->Add(rtt.InMilliseconds()); | 954 rtt_percentile->Add(rtt.InMilliseconds()); |
| 907 | 955 |
| 908 // Add the remaining percentile values. | 956 // Add the remaining percentile values. |
| 909 static const int kPercentiles[] = {0, 10, 90, 100}; | 957 static const int kPercentiles[] = {0, 10, 90, 100}; |
| 910 for (size_t i = 0; i < arraysize(kPercentiles); ++i) { | 958 for (size_t i = 0; i < arraysize(kPercentiles); ++i) { |
| 911 rtt = GetRTTEstimateInternal(disallowed_observation_sources_for_http_, | 959 rtt = GetRTTEstimateInternal( |
| 912 base::TimeTicks(), kPercentiles[i]); | 960 disallowed_observation_sources_for_http_, base::TimeTicks(), |
| 961 base::Optional<Statistic>(), kPercentiles[i]); | |
| 913 | 962 |
| 914 rtt_percentile = GetHistogram( | 963 rtt_percentile = GetHistogram( |
| 915 "RTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", | 964 "RTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", |
| 916 current_network_id_.type, 10 * 1000); // 10 seconds | 965 current_network_id_.type, 10 * 1000); // 10 seconds |
| 917 rtt_percentile->Add(rtt.InMilliseconds()); | 966 rtt_percentile->Add(rtt.InMilliseconds()); |
| 918 } | 967 } |
| 919 } | 968 } |
| 920 | 969 |
| 921 if (GetRecentTransportRTT(base::TimeTicks(), &rtt)) { | 970 if (GetRecentTransportRTT(base::TimeTicks(), &rtt)) { |
| 922 // Add the 50th percentile value. | 971 // Add the 50th percentile value. |
| 923 base::HistogramBase* transport_rtt_percentile = GetHistogram( | 972 base::HistogramBase* transport_rtt_percentile = GetHistogram( |
| 924 "TransportRTT.Percentile50.", current_network_id_.type, 10 * 1000); | 973 "TransportRTT.Percentile50.", current_network_id_.type, 10 * 1000); |
| 925 transport_rtt_percentile->Add(rtt.InMilliseconds()); | 974 transport_rtt_percentile->Add(rtt.InMilliseconds()); |
| 926 | 975 |
| 927 // Add the remaining percentile values. | 976 // Add the remaining percentile values. |
| 928 static const int kPercentiles[] = {0, 10, 90, 100}; | 977 static const int kPercentiles[] = {0, 10, 90, 100}; |
| 929 for (size_t i = 0; i < arraysize(kPercentiles); ++i) { | 978 for (size_t i = 0; i < arraysize(kPercentiles); ++i) { |
| 930 rtt = | 979 rtt = GetRTTEstimateInternal( |
| 931 GetRTTEstimateInternal(disallowed_observation_sources_for_transport_, | 980 disallowed_observation_sources_for_transport_, base::TimeTicks(), |
| 932 base::TimeTicks(), kPercentiles[i]); | 981 base::Optional<Statistic>(), kPercentiles[i]); |
| 933 | 982 |
| 934 transport_rtt_percentile = GetHistogram( | 983 transport_rtt_percentile = GetHistogram( |
| 935 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", | 984 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", |
| 936 current_network_id_.type, 10 * 1000); // 10 seconds | 985 current_network_id_.type, 10 * 1000); // 10 seconds |
| 937 transport_rtt_percentile->Add(rtt.InMilliseconds()); | 986 transport_rtt_percentile->Add(rtt.InMilliseconds()); |
| 938 } | 987 } |
| 939 } | 988 } |
| 940 } | 989 } |
| 941 | 990 |
| 942 void NetworkQualityEstimator::RecordNetworkIDAvailability() const { | 991 void NetworkQualityEstimator::RecordNetworkIDAvailability() const { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1003 base::HistogramBase* effective_connection_type_histogram = | 1052 base::HistogramBase* effective_connection_type_histogram = |
| 1004 base::Histogram::FactoryGet( | 1053 base::Histogram::FactoryGet( |
| 1005 std::string("NQE.MainFrame.EffectiveConnectionType.") + | 1054 std::string("NQE.MainFrame.EffectiveConnectionType.") + |
| 1006 nqe::internal::GetNameForConnectionType(current_network_id_.type), | 1055 nqe::internal::GetNameForConnectionType(current_network_id_.type), |
| 1007 0, EFFECTIVE_CONNECTION_TYPE_LAST, | 1056 0, EFFECTIVE_CONNECTION_TYPE_LAST, |
| 1008 EFFECTIVE_CONNECTION_TYPE_LAST /* Number of buckets */, | 1057 EFFECTIVE_CONNECTION_TYPE_LAST /* Number of buckets */, |
| 1009 base::HistogramBase::kUmaTargetedHistogramFlag); | 1058 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 1010 | 1059 |
| 1011 effective_connection_type_histogram->Add( | 1060 effective_connection_type_histogram->Add( |
| 1012 effective_connection_type_at_last_main_frame_); | 1061 effective_connection_type_at_last_main_frame_); |
| 1062 | |
| 1063 // Record the HTTP RTT at the main frames for experimental statistics. | |
| 1064 for (int i = 0; i < STATISTIC_LAST; ++i) { | |
|
RyanSturm
2017/02/24 19:54:18
nit: this for loop/switch is so awkward.
I assume
tbansal1
2017/02/25 03:04:01
Done.
| |
| 1065 Statistic statistic = static_cast<Statistic>(i); | |
| 1066 switch (statistic) { | |
| 1067 case STATISTIC_LAST: | |
| 1068 NOTREACHED(); | |
| 1069 break; | |
| 1070 case STATISTIC_WEIGHTED_AVERAGE: | |
| 1071 if (http_rtt_at_last_main_frame_[i] != nqe::internal::InvalidRTT()) { | |
| 1072 UMA_HISTOGRAM_TIMES("NQE.WeightedAverage.MainFrame.RTT", | |
| 1073 http_rtt_at_last_main_frame_[i]); | |
| 1074 } | |
| 1075 break; | |
| 1076 } | |
| 1077 } | |
| 1013 } | 1078 } |
| 1014 | 1079 |
| 1015 void NetworkQualityEstimator::ComputeEffectiveConnectionType() { | 1080 void NetworkQualityEstimator::ComputeEffectiveConnectionType() { |
| 1016 DCHECK(thread_checker_.CalledOnValidThread()); | 1081 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1017 | 1082 |
| 1018 UpdateSignalStrength(); | 1083 UpdateSignalStrength(); |
| 1019 | 1084 |
| 1020 const base::TimeTicks now = tick_clock_->NowTicks(); | 1085 const base::TimeTicks now = tick_clock_->NowTicks(); |
| 1021 | 1086 |
| 1022 const EffectiveConnectionType past_type = effective_connection_type_; | 1087 const EffectiveConnectionType past_type = effective_connection_type_; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1278 RTTAndThroughputEstimatesObserver* observer) { | 1343 RTTAndThroughputEstimatesObserver* observer) { |
| 1279 DCHECK(thread_checker_.CalledOnValidThread()); | 1344 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1280 rtt_and_throughput_estimates_observer_list_.RemoveObserver(observer); | 1345 rtt_and_throughput_estimates_observer_list_.RemoveObserver(observer); |
| 1281 } | 1346 } |
| 1282 | 1347 |
| 1283 bool NetworkQualityEstimator::GetRecentHttpRTT( | 1348 bool NetworkQualityEstimator::GetRecentHttpRTT( |
| 1284 const base::TimeTicks& start_time, | 1349 const base::TimeTicks& start_time, |
| 1285 base::TimeDelta* rtt) const { | 1350 base::TimeDelta* rtt) const { |
| 1286 DCHECK(thread_checker_.CalledOnValidThread()); | 1351 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1287 *rtt = GetRTTEstimateInternal(disallowed_observation_sources_for_http_, | 1352 *rtt = GetRTTEstimateInternal(disallowed_observation_sources_for_http_, |
| 1288 start_time, 50); | 1353 start_time, base::Optional<Statistic>(), 50); |
| 1289 return (*rtt != nqe::internal::InvalidRTT()); | 1354 return (*rtt != nqe::internal::InvalidRTT()); |
| 1290 } | 1355 } |
| 1291 | 1356 |
| 1292 bool NetworkQualityEstimator::GetRecentTransportRTT( | 1357 bool NetworkQualityEstimator::GetRecentTransportRTT( |
| 1293 const base::TimeTicks& start_time, | 1358 const base::TimeTicks& start_time, |
| 1294 base::TimeDelta* rtt) const { | 1359 base::TimeDelta* rtt) const { |
| 1295 DCHECK(thread_checker_.CalledOnValidThread()); | 1360 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1296 *rtt = GetRTTEstimateInternal(disallowed_observation_sources_for_transport_, | 1361 *rtt = GetRTTEstimateInternal(disallowed_observation_sources_for_transport_, |
| 1297 start_time, 50); | 1362 start_time, base::Optional<Statistic>(), 50); |
| 1298 return (*rtt != nqe::internal::InvalidRTT()); | 1363 return (*rtt != nqe::internal::InvalidRTT()); |
| 1299 } | 1364 } |
| 1300 | 1365 |
| 1301 bool NetworkQualityEstimator::GetRecentDownlinkThroughputKbps( | 1366 bool NetworkQualityEstimator::GetRecentDownlinkThroughputKbps( |
| 1302 const base::TimeTicks& start_time, | 1367 const base::TimeTicks& start_time, |
| 1303 int32_t* kbps) const { | 1368 int32_t* kbps) const { |
| 1304 DCHECK(thread_checker_.CalledOnValidThread()); | 1369 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1305 *kbps = GetDownlinkThroughputKbpsEstimateInternal(start_time, 50); | 1370 *kbps = GetDownlinkThroughputKbpsEstimateInternal(start_time, 50); |
| 1306 return (*kbps != nqe::internal::kInvalidThroughput); | 1371 return (*kbps != nqe::internal::kInvalidThroughput); |
| 1307 } | 1372 } |
| 1308 | 1373 |
| 1309 base::TimeDelta NetworkQualityEstimator::GetRTTEstimateInternal( | 1374 base::TimeDelta NetworkQualityEstimator::GetRTTEstimateInternal( |
| 1310 const std::vector<NetworkQualityObservationSource>& | 1375 const std::vector<NetworkQualityObservationSource>& |
| 1311 disallowed_observation_sources, | 1376 disallowed_observation_sources, |
| 1312 const base::TimeTicks& start_time, | 1377 base::TimeTicks start_time, |
| 1378 const base::Optional<Statistic>& statistic, | |
| 1313 int percentile) const { | 1379 int percentile) const { |
| 1314 DCHECK(thread_checker_.CalledOnValidThread()); | 1380 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1315 | 1381 |
| 1316 // RTT observations are sorted by duration from shortest to longest, thus | 1382 // RTT observations are sorted by duration from shortest to longest, thus |
| 1317 // a higher percentile RTT will have a longer RTT than a lower percentile. | 1383 // a higher percentile RTT will have a longer RTT than a lower percentile. |
| 1318 base::TimeDelta rtt = nqe::internal::InvalidRTT(); | 1384 base::TimeDelta rtt = nqe::internal::InvalidRTT(); |
| 1319 if (!rtt_observations_.GetPercentile(start_time, signal_strength_dbm_, &rtt, | 1385 |
| 1320 percentile, | 1386 if (!statistic) { |
| 1321 disallowed_observation_sources)) { | 1387 // Use default statistic algorithm. |
| 1322 return nqe::internal::InvalidRTT(); | 1388 if (!rtt_observations_.GetPercentile(start_time, signal_strength_dbm_, &rtt, |
| 1389 percentile, | |
| 1390 disallowed_observation_sources)) { | |
| 1391 return nqe::internal::InvalidRTT(); | |
| 1392 } | |
| 1393 return rtt; | |
| 1323 } | 1394 } |
| 1324 return rtt; | 1395 |
| 1396 switch (statistic.value()) { | |
| 1397 case STATISTIC_LAST: | |
| 1398 NOTREACHED(); | |
| 1399 return nqe::internal::InvalidRTT(); | |
| 1400 case STATISTIC_WEIGHTED_AVERAGE: | |
| 1401 if (!rtt_observations_.GetWeightedAverage( | |
| 1402 start_time, signal_strength_dbm_, disallowed_observation_sources, | |
| 1403 &rtt)) { | |
| 1404 return nqe::internal::InvalidRTT(); | |
| 1405 } | |
| 1406 return rtt; | |
| 1407 } | |
| 1408 NOTREACHED(); | |
| 1409 return nqe::internal::InvalidRTT(); | |
| 1325 } | 1410 } |
| 1326 | 1411 |
| 1327 int32_t NetworkQualityEstimator::GetDownlinkThroughputKbpsEstimateInternal( | 1412 int32_t NetworkQualityEstimator::GetDownlinkThroughputKbpsEstimateInternal( |
| 1328 const base::TimeTicks& start_time, | 1413 const base::TimeTicks& start_time, |
| 1329 int percentile) const { | 1414 int percentile) const { |
| 1330 DCHECK(thread_checker_.CalledOnValidThread()); | 1415 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1331 | 1416 |
| 1332 // Throughput observations are sorted by kbps from slowest to fastest, | 1417 // Throughput observations are sorted by kbps from slowest to fastest, |
| 1333 // thus a higher percentile throughput will be faster than a lower one. | 1418 // thus a higher percentile throughput will be faster than a lower one. |
| 1334 int32_t kbps = nqe::internal::kInvalidThroughput; | 1419 int32_t kbps = nqe::internal::kInvalidThroughput; |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1724 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); | 1809 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); |
| 1725 downstream_throughput_kbps_observations_.AddObservation( | 1810 downstream_throughput_kbps_observations_.AddObservation( |
| 1726 throughput_observation); | 1811 throughput_observation); |
| 1727 NotifyObserversOfThroughput(throughput_observation); | 1812 NotifyObserversOfThroughput(throughput_observation); |
| 1728 } | 1813 } |
| 1729 | 1814 |
| 1730 ComputeEffectiveConnectionType(); | 1815 ComputeEffectiveConnectionType(); |
| 1731 } | 1816 } |
| 1732 | 1817 |
| 1733 } // namespace net | 1818 } // namespace net |
| OLD | NEW |