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

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

Issue 2081493002: Obtain WiFi SSID on Android using Android APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 4 years, 6 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
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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 RecordMetricsOnConnectionTypeChanged(); 647 RecordMetricsOnConnectionTypeChanged();
648 648
649 // Write the estimates of the previous network to the cache. 649 // Write the estimates of the previous network to the cache.
650 CacheNetworkQualityEstimate(); 650 CacheNetworkQualityEstimate();
651 651
652 // Clear the local state. 652 // Clear the local state.
653 last_connection_change_ = tick_clock_->NowTicks(); 653 last_connection_change_ = tick_clock_->NowTicks();
654 peak_network_quality_ = nqe::internal::NetworkQuality(); 654 peak_network_quality_ = nqe::internal::NetworkQuality();
655 downstream_throughput_kbps_observations_.Clear(); 655 downstream_throughput_kbps_observations_.Clear();
656 rtt_observations_.Clear(); 656 rtt_observations_.Clear();
657
658 // Update the local state for the new connection.
657 current_network_id_ = GetCurrentNetworkID(); 659 current_network_id_ = GetCurrentNetworkID();
660 RecordNetworkIDAvailability();
658 661
659 // Query the external estimate provider on certain connection types. Once the 662 // Query the external estimate provider on certain connection types. Once the
660 // updated estimates are available, OnUpdatedEstimateAvailable will be called 663 // updated estimates are available, OnUpdatedEstimateAvailable will be called
661 // by |external_estimate_provider_| with updated estimates. 664 // by |external_estimate_provider_| with updated estimates.
662 if (external_estimate_provider_ && 665 if (external_estimate_provider_ &&
663 current_network_id_.type != NetworkChangeNotifier::CONNECTION_NONE && 666 current_network_id_.type != NetworkChangeNotifier::CONNECTION_NONE &&
664 current_network_id_.type != NetworkChangeNotifier::CONNECTION_UNKNOWN && 667 current_network_id_.type != NetworkChangeNotifier::CONNECTION_UNKNOWN &&
665 current_network_id_.type != NetworkChangeNotifier::CONNECTION_ETHERNET && 668 current_network_id_.type != NetworkChangeNotifier::CONNECTION_ETHERNET &&
666 current_network_id_.type != NetworkChangeNotifier::CONNECTION_BLUETOOTH) { 669 current_network_id_.type != NetworkChangeNotifier::CONNECTION_BLUETOOTH) {
667 RecordExternalEstimateProviderMetrics( 670 RecordExternalEstimateProviderMetrics(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 base::TimeTicks(), kPercentiles[i]); 745 base::TimeTicks(), kPercentiles[i]);
743 746
744 transport_rtt_percentile = GetHistogram( 747 transport_rtt_percentile = GetHistogram(
745 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", 748 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".",
746 current_network_id_.type, 10 * 1000); // 10 seconds 749 current_network_id_.type, 10 * 1000); // 10 seconds
747 transport_rtt_percentile->Add(rtt.InMilliseconds()); 750 transport_rtt_percentile->Add(rtt.InMilliseconds());
748 } 751 }
749 } 752 }
750 } 753 }
751 754
755 void NetworkQualityEstimator::RecordNetworkIDAvailability() const {
756 DCHECK(thread_checker_.CalledOnValidThread());
757 if (current_network_id_.type ==
758 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI ||
759 NetworkChangeNotifier::IsConnectionCellular(current_network_id_.type)) {
760 UMA_HISTOGRAM_BOOLEAN("NQE.NetworkIdAvailable",
761 !current_network_id_.id.empty());
762 }
763 }
764
752 void NetworkQualityEstimator::RecordMetricsOnMainFrameRequest() const { 765 void NetworkQualityEstimator::RecordMetricsOnMainFrameRequest() const {
753 DCHECK(thread_checker_.CalledOnValidThread()); 766 DCHECK(thread_checker_.CalledOnValidThread());
754 767
755 base::TimeDelta http_rtt; 768 base::TimeDelta http_rtt;
756 if (GetHttpRTTEstimate(&http_rtt)) { 769 if (GetHttpRTTEstimate(&http_rtt)) {
757 // Add the 50th percentile value. 770 // Add the 50th percentile value.
758 base::HistogramBase* rtt_percentile = GetHistogram( 771 base::HistogramBase* rtt_percentile = GetHistogram(
759 "MainFrame.RTT.Percentile50.", current_network_id_.type, 10 * 1000); 772 "MainFrame.RTT.Percentile50.", current_network_id_.type, 10 * 1000);
760 rtt_percentile->Add(http_rtt.InMilliseconds()); 773 rtt_percentile->Add(http_rtt.InMilliseconds());
761 } 774 }
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 NotifyObserversOfEffectiveConnectionTypeChanged() { 1252 NotifyObserversOfEffectiveConnectionTypeChanged() {
1240 DCHECK(thread_checker_.CalledOnValidThread()); 1253 DCHECK(thread_checker_.CalledOnValidThread());
1241 1254
1242 // TODO(tbansal): Add hysteresis in the notification. 1255 // TODO(tbansal): Add hysteresis in the notification.
1243 FOR_EACH_OBSERVER( 1256 FOR_EACH_OBSERVER(
1244 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, 1257 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_,
1245 OnEffectiveConnectionTypeChanged(effective_connection_type_)); 1258 OnEffectiveConnectionTypeChanged(effective_connection_type_));
1246 } 1259 }
1247 1260
1248 } // namespace net 1261 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698