Chromium Code Reviews| 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/metrics/sparse_histogram.h" | |
| 8 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 9 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 11 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
| 12 #include "net/base/network_change_notifier_factory.h" | 13 #include "net/base/network_change_notifier_factory.h" |
| 13 #include "net/dns/dns_config_service.h" | 14 #include "net/dns/dns_config_service.h" |
| 14 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 18 #if defined(OS_ANDROID) | |
| 19 #include "net/android/network_library.h" | |
| 20 #endif | |
| 21 | |
| 17 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 18 #include "net/base/network_change_notifier_win.h" | 23 #include "net/base/network_change_notifier_win.h" |
| 19 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) | 24 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 20 #include "net/base/network_change_notifier_linux.h" | 25 #include "net/base/network_change_notifier_linux.h" |
| 21 #elif defined(OS_MACOSX) | 26 #elif defined(OS_MACOSX) |
| 22 #include "net/base/network_change_notifier_mac.h" | 27 #include "net/base/network_change_notifier_mac.h" |
| 23 #endif | 28 #endif |
| 24 | 29 |
| 25 namespace net { | 30 namespace net { |
| 26 | 31 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 SinceLast(&last_dns_change_)); | 251 SinceLast(&last_dns_change_)); |
| 247 } | 252 } |
| 248 | 253 |
| 249 // NetworkChangeNotifier::NetworkChangeObserver implementation. | 254 // NetworkChangeNotifier::NetworkChangeObserver implementation. |
| 250 virtual void OnNetworkChanged( | 255 virtual void OnNetworkChanged( |
| 251 NetworkChangeNotifier::ConnectionType type) OVERRIDE { | 256 NetworkChangeNotifier::ConnectionType type) OVERRIDE { |
| 252 DCHECK(thread_checker_.CalledOnValidThread()); | 257 DCHECK(thread_checker_.CalledOnValidThread()); |
| 253 if (type != NetworkChangeNotifier::CONNECTION_NONE) { | 258 if (type != NetworkChangeNotifier::CONNECTION_NONE) { |
| 254 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.NetworkOnlineChange", | 259 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.NetworkOnlineChange", |
| 255 SinceLast(&last_network_change_)); | 260 SinceLast(&last_network_change_)); |
| 261 #if defined(OS_ANDROID) | |
| 262 std::string mcc_mnc = android::GetTelephonyNetworkOperator(); | |
| 263 // MCC and MNC codes are each 3 digits. | |
|
Ilya Sherman
2014/04/26 02:29:12
From scanning the Wikipedia article, it looked lik
bolian
2014/04/28 18:07:55
My bad. Now, I think I should only check the retur
| |
| 264 if (mcc_mnc.length() == 6) { | |
| 265 int value = atoi(mcc_mnc.c_str()); | |
| 266 if (value> 0) { | |
| 267 UMA_HISTOGRAM_SPARSE_SLOWLY("NCN.NetworkOperatorMCCMNC", value); | |
| 268 } | |
| 269 } | |
| 270 #endif | |
| 271 | |
| 256 } else { | 272 } else { |
| 257 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.NetworkOfflineChange", | 273 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.NetworkOfflineChange", |
| 258 SinceLast(&last_network_change_)); | 274 SinceLast(&last_network_change_)); |
| 259 } | 275 } |
| 260 } | 276 } |
| 261 | 277 |
| 262 // Record histogram data whenever we receive a packet. Should only be called | 278 // Record histogram data whenever we receive a packet. Should only be called |
| 263 // from the network thread. | 279 // from the network thread. |
| 264 void NotifyDataReceived(const URLRequest& request, int bytes_read) { | 280 void NotifyDataReceived(const URLRequest& request, int bytes_read) { |
| 265 DCHECK(thread_checker_.CalledOnValidThread()); | 281 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 DCHECK(g_network_change_notifier); | 758 DCHECK(g_network_change_notifier); |
| 743 g_network_change_notifier = NULL; | 759 g_network_change_notifier = NULL; |
| 744 } | 760 } |
| 745 | 761 |
| 746 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 762 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
| 747 DCHECK(!g_network_change_notifier); | 763 DCHECK(!g_network_change_notifier); |
| 748 g_network_change_notifier = network_change_notifier_; | 764 g_network_change_notifier = network_change_notifier_; |
| 749 } | 765 } |
| 750 | 766 |
| 751 } // namespace net | 767 } // namespace net |
| OLD | NEW |