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

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

Issue 246553003: Record Mobile Operator ID in UMA report. This is Android only for now. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@operator_id
Patch Set: addressed comments. Created 6 years, 7 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('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 "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"
11 #include "net/base/net_util.h" 11 #include "net/base/net_util.h"
12 #include "net/base/network_change_notifier_factory.h" 12 #include "net/base/network_change_notifier_factory.h"
13 #include "net/dns/dns_config_service.h" 13 #include "net/dns/dns_config_service.h"
14 #include "net/url_request/url_request.h" 14 #include "net/url_request/url_request.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 #if defined(OS_ANDROID)
18 #include "base/metrics/sparse_histogram.h"
19 #include "base/strings/string_number_conversions.h"
20 #include "net/android/network_library.h"
21 #endif
22
17 #if defined(OS_WIN) 23 #if defined(OS_WIN)
18 #include "net/base/network_change_notifier_win.h" 24 #include "net/base/network_change_notifier_win.h"
19 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) 25 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
20 #include "net/base/network_change_notifier_linux.h" 26 #include "net/base/network_change_notifier_linux.h"
21 #elif defined(OS_MACOSX) 27 #elif defined(OS_MACOSX)
22 #include "net/base/network_change_notifier_mac.h" 28 #include "net/base/network_change_notifier_mac.h"
23 #endif 29 #endif
24 30
25 namespace net { 31 namespace net {
26 32
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 "NCN.OfflineDataRecvAny5sBeforeOnline", 227 "NCN.OfflineDataRecvAny5sBeforeOnline",
222 offline_packets_received_); 228 offline_packets_received_);
223 } 229 }
224 230
225 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecvUntilOnline", 231 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecvUntilOnline",
226 now - last_offline_packet_received_); 232 now - last_offline_packet_received_);
227 } 233 }
228 } else { 234 } else {
229 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineChange", state_duration); 235 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineChange", state_duration);
230 } 236 }
237
238 #if defined(OS_ANDROID)
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
231 UMA_HISTOGRAM_MEDIUM_TIMES( 255 UMA_HISTOGRAM_MEDIUM_TIMES(
232 "NCN.IPAddressChangeToConnectionTypeChange", 256 "NCN.IPAddressChangeToConnectionTypeChange",
233 now - last_ip_address_change_); 257 now - last_ip_address_change_);
234 258
235 offline_packets_received_ = 0; 259 offline_packets_received_ = 0;
236 bytes_read_since_last_connection_change_ = 0; 260 bytes_read_since_last_connection_change_ = 0;
237 peak_kbps_since_last_connection_change_ = 0; 261 peak_kbps_since_last_connection_change_ = 0;
238 last_connection_type_ = type; 262 last_connection_type_ = type;
239 polling_interval_ = base::TimeDelta::FromSeconds(1); 263 polling_interval_ = base::TimeDelta::FromSeconds(1);
240 } 264 }
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 DCHECK(g_network_change_notifier); 766 DCHECK(g_network_change_notifier);
743 g_network_change_notifier = NULL; 767 g_network_change_notifier = NULL;
744 } 768 }
745 769
746 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 770 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
747 DCHECK(!g_network_change_notifier); 771 DCHECK(!g_network_change_notifier);
748 g_network_change_notifier = network_change_notifier_; 772 g_network_change_notifier = network_change_notifier_;
749 } 773 }
750 774
751 } // namespace net 775 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698