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

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

Issue 2650573002: NetworkQualityEstimator: Update signal strength estimate periodically (Closed)
Patch Set: Created 3 years, 11 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 | 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // possible to measure the accuracy by comparing the estimate with the 435 // possible to measure the accuracy by comparing the estimate with the
436 // observations received over intervals of varying durations. 436 // observations received over intervals of varying durations.
437 for (const base::TimeDelta& measuring_delay : 437 for (const base::TimeDelta& measuring_delay :
438 GetAccuracyRecordingIntervals()) { 438 GetAccuracyRecordingIntervals()) {
439 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 439 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
440 FROM_HERE, 440 FROM_HERE,
441 base::Bind(&NetworkQualityEstimator::RecordAccuracyAfterMainFrame, 441 base::Bind(&NetworkQualityEstimator::RecordAccuracyAfterMainFrame,
442 weak_ptr_factory_.GetWeakPtr(), measuring_delay), 442 weak_ptr_factory_.GetWeakPtr(), measuring_delay),
443 measuring_delay); 443 measuring_delay);
444 } 444 }
445 UpdateSignalStrength();
446 } 445 }
447 446
448 LoadTimingInfo load_timing_info; 447 LoadTimingInfo load_timing_info;
449 request.GetLoadTimingInfo(&load_timing_info); 448 request.GetLoadTimingInfo(&load_timing_info);
450 449
451 // If the load timing info is unavailable, it probably means that the request 450 // If the load timing info is unavailable, it probably means that the request
452 // did not go over the network. 451 // did not go over the network.
453 if (load_timing_info.send_start.is_null() || 452 if (load_timing_info.send_start.is_null() ||
454 load_timing_info.receive_headers_end.is_null()) { 453 load_timing_info.receive_headers_end.is_null()) {
455 return; 454 return;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 830
832 MaybeQueryExternalEstimateProvider(); 831 MaybeQueryExternalEstimateProvider();
833 832
834 // Read any cached estimates for the new network. If cached estimates are 833 // Read any cached estimates for the new network. If cached estimates are
835 // unavailable, add the default estimates. 834 // unavailable, add the default estimates.
836 if (!ReadCachedNetworkQualityEstimate()) 835 if (!ReadCachedNetworkQualityEstimate())
837 AddDefaultEstimates(); 836 AddDefaultEstimates();
838 estimated_quality_at_last_main_frame_ = nqe::internal::NetworkQuality(); 837 estimated_quality_at_last_main_frame_ = nqe::internal::NetworkQuality();
839 throughput_analyzer_->OnConnectionTypeChanged(); 838 throughput_analyzer_->OnConnectionTypeChanged();
840 MaybeComputeEffectiveConnectionType(); 839 MaybeComputeEffectiveConnectionType();
841 UpdateSignalStrength();
842 } 840 }
843 841
844 void NetworkQualityEstimator::MaybeQueryExternalEstimateProvider() const { 842 void NetworkQualityEstimator::MaybeQueryExternalEstimateProvider() const {
845 // Query the external estimate provider on certain connection types. Once the 843 // Query the external estimate provider on certain connection types. Once the
846 // updated estimates are available, OnUpdatedEstimateAvailable will be called 844 // updated estimates are available, OnUpdatedEstimateAvailable will be called
847 // by |external_estimate_provider_| with updated estimates. 845 // by |external_estimate_provider_| with updated estimates.
848 if (external_estimate_provider_ && 846 if (external_estimate_provider_ &&
849 current_network_id_.type != NetworkChangeNotifier::CONNECTION_NONE && 847 current_network_id_.type != NetworkChangeNotifier::CONNECTION_NONE &&
850 current_network_id_.type != NetworkChangeNotifier::CONNECTION_UNKNOWN && 848 current_network_id_.type != NetworkChangeNotifier::CONNECTION_UNKNOWN &&
851 current_network_id_.type != NetworkChangeNotifier::CONNECTION_ETHERNET && 849 current_network_id_.type != NetworkChangeNotifier::CONNECTION_ETHERNET &&
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 EFFECTIVE_CONNECTION_TYPE_LAST /* Number of buckets */, 1011 EFFECTIVE_CONNECTION_TYPE_LAST /* Number of buckets */,
1014 base::HistogramBase::kUmaTargetedHistogramFlag); 1012 base::HistogramBase::kUmaTargetedHistogramFlag);
1015 1013
1016 effective_connection_type_histogram->Add( 1014 effective_connection_type_histogram->Add(
1017 effective_connection_type_at_last_main_frame_); 1015 effective_connection_type_at_last_main_frame_);
1018 } 1016 }
1019 1017
1020 void NetworkQualityEstimator::ComputeEffectiveConnectionType() { 1018 void NetworkQualityEstimator::ComputeEffectiveConnectionType() {
1021 DCHECK(thread_checker_.CalledOnValidThread()); 1019 DCHECK(thread_checker_.CalledOnValidThread());
1022 1020
1021 UpdateSignalStrength();
1022
1023 const base::TimeTicks now = tick_clock_->NowTicks(); 1023 const base::TimeTicks now = tick_clock_->NowTicks();
1024 1024
1025 const EffectiveConnectionType past_type = effective_connection_type_; 1025 const EffectiveConnectionType past_type = effective_connection_type_;
1026 last_effective_connection_type_computation_ = now; 1026 last_effective_connection_type_computation_ = now;
1027 1027
1028 base::TimeDelta http_rtt = nqe::internal::InvalidRTT(); 1028 base::TimeDelta http_rtt = nqe::internal::InvalidRTT();
1029 base::TimeDelta transport_rtt = nqe::internal::InvalidRTT(); 1029 base::TimeDelta transport_rtt = nqe::internal::InvalidRTT();
1030 int32_t downstream_throughput_kbps = nqe::internal::kInvalidThroughput; 1030 int32_t downstream_throughput_kbps = nqe::internal::kInvalidThroughput;
1031 1031
1032 effective_connection_type_ = 1032 effective_connection_type_ =
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1720 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1721 downstream_throughput_kbps_observations_.AddObservation( 1721 downstream_throughput_kbps_observations_.AddObservation(
1722 throughput_observation); 1722 throughput_observation);
1723 NotifyObserversOfThroughput(throughput_observation); 1723 NotifyObserversOfThroughput(throughput_observation);
1724 } 1724 }
1725 1725
1726 ComputeEffectiveConnectionType(); 1726 ComputeEffectiveConnectionType();
1727 } 1727 }
1728 1728
1729 } // namespace net 1729 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698