Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
|
bengr
2014/05/06 17:14:39
Remove (c)
bolian
2014/05/06 18:00:08
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chrome_browser_metrics_log_observer.h" | |
| 6 | |
| 7 #if defined(OS_ANDROID) | |
| 8 #include "base/metrics/sparse_histogram.h" | |
| 9 #include "base/strings/string_number_conversions.h" | |
| 10 #include "net/android/network_library.h" | |
| 11 #endif | |
| 12 | |
| 13 ChromeBrowserMetricsLogObserver::ChromeBrowserMetricsLogObserver() { | |
| 14 #if defined(OS_ANDROID) | |
| 15 MetricsServiceHelper::AddMetricsLogObserver(this); | |
| 16 #endif | |
| 17 } | |
| 18 | |
| 19 ChromeBrowserMetricsLogObserver::~ChromeBrowserMetricsLogObserver() { | |
| 20 #if defined(OS_ANDROID) | |
| 21 MetricsServiceHelper::RemoveMetricsLogObserver(this); | |
| 22 #endif | |
| 23 } | |
| 24 | |
| 25 void ChromeBrowserMetricsLogObserver::OnNewMetricsLog() { | |
|
bengr
2014/05/06 17:14:39
Could you avoid the #ifdefs here by subclassing a
bolian
2014/05/06 18:00:08
I think I only need ifdefs in this one method and
Lei Zhang
2014/05/08 05:40:19
Why do you think ChromeBrowserMetricsLogObserverAn
bolian
2014/05/08 06:38:24
ok. that makes sense. Will address this in the nex
| |
| 26 #if defined(OS_ANDROID) | |
| 27 net::NetworkChangeNotifier::ConnectionType type = | |
| 28 net::NetworkChangeNotifier::GetConnectionType(); | |
| 29 unsigned mcc_mnc = 0; | |
| 30 if (type == net::NetworkChangeNotifier::CONNECTION_2G || | |
|
bengr
2014/05/06 17:14:39
Are there no other mobile network types?
bolian
2014/05/06 18:00:08
Yes, the three are on the only cellular network, f
| |
| 31 type == net::NetworkChangeNotifier::CONNECTION_3G || | |
| 32 type == net::NetworkChangeNotifier::CONNECTION_4G) { | |
| 33 // Log zero if not perfectly converted. | |
| 34 if (!base::StringToUint( | |
| 35 net::android::GetTelephonyNetworkOperator(), &mcc_mnc)) { | |
| 36 mcc_mnc = 0; | |
|
bengr
2014/05/06 17:14:39
So 0 means unknown and ethernet and wifi?
bolian
2014/05/06 18:00:08
Yes. Basically, it means non-cellular network, tha
| |
| 37 } | |
| 38 } | |
| 39 UMA_HISTOGRAM_SPARSE_SLOWLY( | |
| 40 "NCN.NetworkOperatorMCCMNC_NewMetricsLog", mcc_mnc); | |
| 41 #endif | |
| 42 } | |
| OLD | NEW |