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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 RecordMetricsOnConnectionTypeChanged(); | 733 RecordMetricsOnConnectionTypeChanged(); |
| 734 | 734 |
| 735 // Write the estimates of the previous network to the cache. | 735 // Write the estimates of the previous network to the cache. |
| 736 CacheNetworkQualityEstimate(); | 736 CacheNetworkQualityEstimate(); |
| 737 | 737 |
| 738 // Clear the local state. | 738 // Clear the local state. |
| 739 last_connection_change_ = tick_clock_->NowTicks(); | 739 last_connection_change_ = tick_clock_->NowTicks(); |
| 740 peak_network_quality_ = nqe::internal::NetworkQuality(); | 740 peak_network_quality_ = nqe::internal::NetworkQuality(); |
| 741 downstream_throughput_kbps_observations_.Clear(); | 741 downstream_throughput_kbps_observations_.Clear(); |
| 742 rtt_observations_.Clear(); | 742 rtt_observations_.Clear(); |
| 743 | |
| 744 // Update the local state for the new connection. | |
|
bengr
2016/07/08 17:00:07
I don't understand this comment.
tbansal1
2016/07/08 18:39:08
Reworded.
First, the local state is cleared ("// C
| |
| 743 current_network_id_ = GetCurrentNetworkID(); | 745 current_network_id_ = GetCurrentNetworkID(); |
| 746 RecordNetworkIDAvailability(); | |
| 744 | 747 |
| 745 // Query the external estimate provider on certain connection types. Once the | 748 // Query the external estimate provider on certain connection types. Once the |
| 746 // updated estimates are available, OnUpdatedEstimateAvailable will be called | 749 // updated estimates are available, OnUpdatedEstimateAvailable will be called |
| 747 // by |external_estimate_provider_| with updated estimates. | 750 // by |external_estimate_provider_| with updated estimates. |
| 748 if (external_estimate_provider_ && | 751 if (external_estimate_provider_ && |
| 749 current_network_id_.type != NetworkChangeNotifier::CONNECTION_NONE && | 752 current_network_id_.type != NetworkChangeNotifier::CONNECTION_NONE && |
| 750 current_network_id_.type != NetworkChangeNotifier::CONNECTION_UNKNOWN && | 753 current_network_id_.type != NetworkChangeNotifier::CONNECTION_UNKNOWN && |
| 751 current_network_id_.type != NetworkChangeNotifier::CONNECTION_ETHERNET && | 754 current_network_id_.type != NetworkChangeNotifier::CONNECTION_ETHERNET && |
| 752 current_network_id_.type != NetworkChangeNotifier::CONNECTION_BLUETOOTH) { | 755 current_network_id_.type != NetworkChangeNotifier::CONNECTION_BLUETOOTH) { |
| 753 RecordExternalEstimateProviderMetrics( | 756 RecordExternalEstimateProviderMetrics( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 base::TimeTicks(), kPercentiles[i]); | 831 base::TimeTicks(), kPercentiles[i]); |
| 829 | 832 |
| 830 transport_rtt_percentile = GetHistogram( | 833 transport_rtt_percentile = GetHistogram( |
| 831 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", | 834 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", |
| 832 current_network_id_.type, 10 * 1000); // 10 seconds | 835 current_network_id_.type, 10 * 1000); // 10 seconds |
| 833 transport_rtt_percentile->Add(rtt.InMilliseconds()); | 836 transport_rtt_percentile->Add(rtt.InMilliseconds()); |
| 834 } | 837 } |
| 835 } | 838 } |
| 836 } | 839 } |
| 837 | 840 |
| 841 void NetworkQualityEstimator::RecordNetworkIDAvailability() const { | |
| 842 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 843 if (current_network_id_.type == | |
| 844 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI || | |
| 845 NetworkChangeNotifier::IsConnectionCellular(current_network_id_.type)) { | |
| 846 UMA_HISTOGRAM_BOOLEAN("NQE.NetworkIdAvailable", | |
| 847 !current_network_id_.id.empty()); | |
| 848 } | |
| 849 } | |
| 850 | |
| 838 void NetworkQualityEstimator::RecordMetricsOnMainFrameRequest() const { | 851 void NetworkQualityEstimator::RecordMetricsOnMainFrameRequest() const { |
| 839 DCHECK(thread_checker_.CalledOnValidThread()); | 852 DCHECK(thread_checker_.CalledOnValidThread()); |
| 840 | 853 |
| 841 base::TimeDelta http_rtt; | 854 base::TimeDelta http_rtt; |
| 842 if (GetHttpRTTEstimate(&http_rtt)) { | 855 if (GetHttpRTTEstimate(&http_rtt)) { |
| 843 // Add the 50th percentile value. | 856 // Add the 50th percentile value. |
| 844 base::HistogramBase* rtt_percentile = GetHistogram( | 857 base::HistogramBase* rtt_percentile = GetHistogram( |
| 845 "MainFrame.RTT.Percentile50.", current_network_id_.type, 10 * 1000); | 858 "MainFrame.RTT.Percentile50.", current_network_id_.type, 10 * 1000); |
| 846 rtt_percentile->Add(http_rtt.InMilliseconds()); | 859 rtt_percentile->Add(http_rtt.InMilliseconds()); |
| 847 } | 860 } |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1360 NotifyObserversOfEffectiveConnectionTypeChanged() { | 1373 NotifyObserversOfEffectiveConnectionTypeChanged() { |
| 1361 DCHECK(thread_checker_.CalledOnValidThread()); | 1374 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1362 | 1375 |
| 1363 // TODO(tbansal): Add hysteresis in the notification. | 1376 // TODO(tbansal): Add hysteresis in the notification. |
| 1364 FOR_EACH_OBSERVER( | 1377 FOR_EACH_OBSERVER( |
| 1365 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, | 1378 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, |
| 1366 OnEffectiveConnectionTypeChanged(effective_connection_type_)); | 1379 OnEffectiveConnectionTypeChanged(effective_connection_type_)); |
| 1367 } | 1380 } |
| 1368 | 1381 |
| 1369 } // namespace net | 1382 } // namespace net |
| OLD | NEW |