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

Side by Side Diff: net/base/network_change_notifier.cc

Issue 2814473002: Move HttpStreamFactoryImpl::JobController UMA to a schedule upload (Closed)
Patch Set: add test Created 3 years, 8 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/base/network_change_notifier.h ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/network_change_notifier.h" 5 #include "net/base/network_change_notifier.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <unordered_set> 8 #include <unordered_set>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 void NetworkChangeNotifier::ShutdownHistogramWatcher() { 735 void NetworkChangeNotifier::ShutdownHistogramWatcher() {
736 if (!g_network_change_notifier) 736 if (!g_network_change_notifier)
737 return; 737 return;
738 g_network_change_notifier->histogram_watcher_.reset(); 738 g_network_change_notifier->histogram_watcher_.reset();
739 } 739 }
740 740
741 // static 741 // static
742 void NetworkChangeNotifier::FinalizingMetricsLogRecord() { 742 void NetworkChangeNotifier::FinalizingMetricsLogRecord() {
743 if (!g_network_change_notifier) 743 if (!g_network_change_notifier)
744 return; 744 return;
745 g_network_change_notifier->OnFinalizingMetricsLogRecord(); 745 g_network_change_notifier->NotifyObserversOfMetricsOnFinalize();
746 } 746 }
747 747
748 // static 748 // static
749 void NetworkChangeNotifier::LogOperatorCodeHistogram(ConnectionType type) { 749 void NetworkChangeNotifier::LogOperatorCodeHistogram(ConnectionType type) {
750 #if defined(OS_ANDROID) 750 #if defined(OS_ANDROID)
751 // On a connection type change to cellular, log the network operator MCC/MNC. 751 // On a connection type change to cellular, log the network operator MCC/MNC.
752 // Log zero in other cases. 752 // Log zero in other cases.
753 unsigned mcc_mnc = 0; 753 unsigned mcc_mnc = 0;
754 if (NetworkChangeNotifier::IsConnectionCellular(type)) { 754 if (NetworkChangeNotifier::IsConnectionCellular(type)) {
755 // Log zero if not perfectly converted. 755 // Log zero if not perfectly converted.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 } 909 }
910 } 910 }
911 911
912 void NetworkChangeNotifier::RemoveNetworkObserver(NetworkObserver* observer) { 912 void NetworkChangeNotifier::RemoveNetworkObserver(NetworkObserver* observer) {
913 DCHECK(AreNetworkHandlesSupported()); 913 DCHECK(AreNetworkHandlesSupported());
914 if (g_network_change_notifier) { 914 if (g_network_change_notifier) {
915 g_network_change_notifier->network_observer_list_->RemoveObserver(observer); 915 g_network_change_notifier->network_observer_list_->RemoveObserver(observer);
916 } 916 }
917 } 917 }
918 918
919 void NetworkChangeNotifier::AddMetricsObserver(MetricsObserver* observer) {
920 if (g_network_change_notifier) {
921 g_network_change_notifier->metrics_observer_list_->AddObserver(observer);
922 }
923 }
924
919 // static 925 // static
920 void NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests() { 926 void NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests() {
921 if (g_network_change_notifier) 927 if (g_network_change_notifier)
922 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl(); 928 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl();
923 } 929 }
924 930
925 // static 931 // static
926 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests( 932 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests(
927 ConnectionType type) { 933 ConnectionType type) {
928 if (g_network_change_notifier) 934 if (g_network_change_notifier)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 new base::ObserverListThreadSafe<DNSObserver>( 984 new base::ObserverListThreadSafe<DNSObserver>(
979 base::ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)), 985 base::ObserverListBase<DNSObserver>::NOTIFY_EXISTING_ONLY)),
980 network_change_observer_list_(new base::ObserverListThreadSafe< 986 network_change_observer_list_(new base::ObserverListThreadSafe<
981 NetworkChangeObserver>( 987 NetworkChangeObserver>(
982 base::ObserverListBase<NetworkChangeObserver>::NOTIFY_EXISTING_ONLY)), 988 base::ObserverListBase<NetworkChangeObserver>::NOTIFY_EXISTING_ONLY)),
983 max_bandwidth_observer_list_(new base::ObserverListThreadSafe< 989 max_bandwidth_observer_list_(new base::ObserverListThreadSafe<
984 MaxBandwidthObserver>( 990 MaxBandwidthObserver>(
985 base::ObserverListBase<MaxBandwidthObserver>::NOTIFY_EXISTING_ONLY)), 991 base::ObserverListBase<MaxBandwidthObserver>::NOTIFY_EXISTING_ONLY)),
986 network_observer_list_(new base::ObserverListThreadSafe<NetworkObserver>( 992 network_observer_list_(new base::ObserverListThreadSafe<NetworkObserver>(
987 base::ObserverListBase<NetworkObserver>::NOTIFY_EXISTING_ONLY)), 993 base::ObserverListBase<NetworkObserver>::NOTIFY_EXISTING_ONLY)),
994 metrics_observer_list_(new base::ObserverListThreadSafe<MetricsObserver>(
995 base::ObserverListBase<MetricsObserver>::NOTIFY_EXISTING_ONLY)),
988 network_state_(new NetworkState()), 996 network_state_(new NetworkState()),
989 network_change_calculator_(new NetworkChangeCalculator(params)) { 997 network_change_calculator_(new NetworkChangeCalculator(params)) {
990 DCHECK(!g_network_change_notifier); 998 DCHECK(!g_network_change_notifier);
991 g_network_change_notifier = this; 999 g_network_change_notifier = this;
992 network_change_calculator_->Init(); 1000 network_change_calculator_->Init();
993 } 1001 }
994 1002
995 #if defined(OS_LINUX) 1003 #if defined(OS_LINUX)
996 const internal::AddressTrackerLinux* 1004 const internal::AddressTrackerLinux*
997 NetworkChangeNotifier::GetAddressTrackerInternal() const { 1005 NetworkChangeNotifier::GetAddressTrackerInternal() const {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 NetworkChangeNotifier::GetCurrentNetworkConnectionType( 1038 NetworkChangeNotifier::GetCurrentNetworkConnectionType(
1031 NetworkHandle network) const { 1039 NetworkHandle network) const {
1032 return CONNECTION_UNKNOWN; 1040 return CONNECTION_UNKNOWN;
1033 } 1041 }
1034 1042
1035 NetworkChangeNotifier::NetworkHandle 1043 NetworkChangeNotifier::NetworkHandle
1036 NetworkChangeNotifier::GetCurrentDefaultNetwork() const { 1044 NetworkChangeNotifier::GetCurrentDefaultNetwork() const {
1037 return kInvalidNetworkHandle; 1045 return kInvalidNetworkHandle;
1038 } 1046 }
1039 1047
1048 void NetworkChangeNotifier::OnFinalizingMetricsLogRecord() {
1049 if (g_network_change_notifier &&
1050 !NetworkChangeNotifier::test_notifications_only_) {
1051 g_network_change_notifier->NotifyObserversOfMetricsOnFinalize();
1052 }
1053 }
1054
1040 // static 1055 // static
1041 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() { 1056 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() {
1042 if (g_network_change_notifier && 1057 if (g_network_change_notifier &&
1043 !NetworkChangeNotifier::test_notifications_only_) { 1058 !NetworkChangeNotifier::test_notifications_only_) {
1044 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl(); 1059 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl();
1045 } 1060 }
1046 } 1061 }
1047 1062
1048 // static 1063 // static
1049 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() { 1064 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 } 1165 }
1151 1166
1152 void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeImpl( 1167 void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeImpl(
1153 double max_bandwidth_mbps, 1168 double max_bandwidth_mbps,
1154 ConnectionType type) { 1169 ConnectionType type) {
1155 max_bandwidth_observer_list_->Notify( 1170 max_bandwidth_observer_list_->Notify(
1156 FROM_HERE, &MaxBandwidthObserver::OnMaxBandwidthChanged, 1171 FROM_HERE, &MaxBandwidthObserver::OnMaxBandwidthChanged,
1157 max_bandwidth_mbps, type); 1172 max_bandwidth_mbps, type);
1158 } 1173 }
1159 1174
1175 void NetworkChangeNotifier::NotifyObserversOfMetricsOnFinalize() {
1176 metrics_observer_list_->Notify(FROM_HERE,
1177 &MetricsObserver::OnMetricsFinalize);
1178 }
1179
1160 void NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChangeImpl( 1180 void NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChangeImpl(
1161 NetworkChangeType type, 1181 NetworkChangeType type,
1162 NetworkHandle network) { 1182 NetworkHandle network) {
1163 switch (type) { 1183 switch (type) {
1164 case CONNECTED: 1184 case CONNECTED:
1165 network_observer_list_->Notify( 1185 network_observer_list_->Notify(
1166 FROM_HERE, &NetworkObserver::OnNetworkConnected, network); 1186 FROM_HERE, &NetworkObserver::OnNetworkConnected, network);
1167 break; 1187 break;
1168 case DISCONNECTED: 1188 case DISCONNECTED:
1169 network_observer_list_->Notify( 1189 network_observer_list_->Notify(
(...skipping 18 matching lines...) Expand all
1188 1208
1189 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 1209 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
1190 DCHECK(!g_network_change_notifier); 1210 DCHECK(!g_network_change_notifier);
1191 g_network_change_notifier = network_change_notifier_; 1211 g_network_change_notifier = network_change_notifier_;
1192 } 1212 }
1193 1213
1194 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() { 1214 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() {
1195 } 1215 }
1196 1216
1197 } // namespace net 1217 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_change_notifier.h ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698