OLD | NEW |
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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 offline_packets_received_); | 228 offline_packets_received_); |
229 } | 229 } |
230 | 230 |
231 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecvUntilOnline", | 231 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecvUntilOnline", |
232 now - last_offline_packet_received_); | 232 now - last_offline_packet_received_); |
233 } | 233 } |
234 } else { | 234 } else { |
235 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineChange", state_duration); | 235 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineChange", state_duration); |
236 } | 236 } |
237 | 237 |
238 #if defined(OS_ANDROID) | 238 NetworkChangeNotifier::LogOperatorCodeHistogram(type); |
239 // On a connection type change to 2/3/4G, log the network operator MCC/MNC. | |
240 // Log zero in other cases. | |
241 unsigned mcc_mnc = 0; | |
242 if (type == NetworkChangeNotifier::CONNECTION_2G || | |
243 type == NetworkChangeNotifier::CONNECTION_3G || | |
244 type == NetworkChangeNotifier::CONNECTION_4G) { | |
245 // Log zero if not perfectly converted. | |
246 if (!base::StringToUint( | |
247 net::android::GetTelephonyNetworkOperator(), &mcc_mnc)) { | |
248 mcc_mnc = 0; | |
249 } | |
250 } | |
251 UMA_HISTOGRAM_SPARSE_SLOWLY( | |
252 "NCN.NetworkOperatorMCCMNC_ConnectionChange", mcc_mnc); | |
253 #endif | |
254 | 239 |
255 UMA_HISTOGRAM_MEDIUM_TIMES( | 240 UMA_HISTOGRAM_MEDIUM_TIMES( |
256 "NCN.IPAddressChangeToConnectionTypeChange", | 241 "NCN.IPAddressChangeToConnectionTypeChange", |
257 now - last_ip_address_change_); | 242 now - last_ip_address_change_); |
258 | 243 |
259 offline_packets_received_ = 0; | 244 offline_packets_received_ = 0; |
260 bytes_read_since_last_connection_change_ = 0; | 245 bytes_read_since_last_connection_change_ = 0; |
261 peak_kbps_since_last_connection_change_ = 0; | 246 peak_kbps_since_last_connection_change_ = 0; |
262 last_connection_type_ = type; | 247 last_connection_type_ = type; |
263 polling_interval_ = base::TimeDelta::FromSeconds(1); | 248 polling_interval_ = base::TimeDelta::FromSeconds(1); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 g_network_change_notifier->histogram_watcher_->Init(); | 572 g_network_change_notifier->histogram_watcher_->Init(); |
588 } | 573 } |
589 | 574 |
590 // static | 575 // static |
591 void NetworkChangeNotifier::ShutdownHistogramWatcher() { | 576 void NetworkChangeNotifier::ShutdownHistogramWatcher() { |
592 if (!g_network_change_notifier) | 577 if (!g_network_change_notifier) |
593 return; | 578 return; |
594 g_network_change_notifier->histogram_watcher_.reset(); | 579 g_network_change_notifier->histogram_watcher_.reset(); |
595 } | 580 } |
596 | 581 |
| 582 // static |
| 583 void NetworkChangeNotifier::LogOperatorCodeHistogram(ConnectionType type) { |
| 584 #if defined(OS_ANDROID) |
| 585 // On a connection type change to 2/3/4G, log the network operator MCC/MNC. |
| 586 // Log zero in other cases. |
| 587 unsigned mcc_mnc = 0; |
| 588 if (type == NetworkChangeNotifier::CONNECTION_2G || |
| 589 type == NetworkChangeNotifier::CONNECTION_3G || |
| 590 type == NetworkChangeNotifier::CONNECTION_4G) { |
| 591 // Log zero if not perfectly converted. |
| 592 if (!base::StringToUint( |
| 593 net::android::GetTelephonyNetworkOperator(), &mcc_mnc)) { |
| 594 mcc_mnc = 0; |
| 595 } |
| 596 } |
| 597 UMA_HISTOGRAM_SPARSE_SLOWLY("NCN.NetworkOperatorMCCMNC", mcc_mnc); |
| 598 #endif |
| 599 } |
| 600 |
597 #if defined(OS_LINUX) | 601 #if defined(OS_LINUX) |
598 // static | 602 // static |
599 const internal::AddressTrackerLinux* | 603 const internal::AddressTrackerLinux* |
600 NetworkChangeNotifier::GetAddressTracker() { | 604 NetworkChangeNotifier::GetAddressTracker() { |
601 return g_network_change_notifier ? | 605 return g_network_change_notifier ? |
602 g_network_change_notifier->GetAddressTrackerInternal() : NULL; | 606 g_network_change_notifier->GetAddressTrackerInternal() : NULL; |
603 } | 607 } |
604 #endif | 608 #endif |
605 | 609 |
606 // static | 610 // static |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 DCHECK(g_network_change_notifier); | 770 DCHECK(g_network_change_notifier); |
767 g_network_change_notifier = NULL; | 771 g_network_change_notifier = NULL; |
768 } | 772 } |
769 | 773 |
770 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 774 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
771 DCHECK(!g_network_change_notifier); | 775 DCHECK(!g_network_change_notifier); |
772 g_network_change_notifier = network_change_notifier_; | 776 g_network_change_notifier = network_change_notifier_; |
773 } | 777 } |
774 | 778 |
775 } // namespace net | 779 } // namespace net |
OLD | NEW |