Index: chrome/browser/chrome_browser_metrics_log_observer.cc |
diff --git a/chrome/browser/chrome_browser_metrics_log_observer.cc b/chrome/browser/chrome_browser_metrics_log_observer.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..275d8edab60438a672c630f8849dce2969c59401 |
--- /dev/null |
+++ b/chrome/browser/chrome_browser_metrics_log_observer.cc |
@@ -0,0 +1,38 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/chrome_browser_metrics_log_observer.h" |
+ |
+#if defined(OS_ANDROID) |
+#include "base/metrics/sparse_histogram.h" |
+#include "base/strings/string_number_conversions.h" |
+#include "net/android/network_library.h" |
+#endif |
+ |
+ChromeBrowserMetricsLogObserver::ChromeBrowserMetricsLogObserver() { |
+ MetricsServiceHelper::AddMetricsLogObserver(this); |
+} |
+ |
+ChromeBrowserMetricsLogObserver::~ChromeBrowserMetricsLogObserver() { |
+ MetricsServiceHelper::RemoveMetricsLogObserver(this); |
+} |
+ |
+void ChromeBrowserMetricsLogObserver::OnNewMetricsLog() { |
+#if defined(OS_ANDROID) |
+ net::NetworkChangeNotifier::ConnectionType type = |
+ net::NetworkChangeNotifier::GetConnectionType(); |
+ unsigned mcc_mnc = 0; |
+ if (type == net::NetworkChangeNotifier::CONNECTION_2G || |
+ type == net::NetworkChangeNotifier::CONNECTION_3G || |
+ type == net::NetworkChangeNotifier::CONNECTION_4G) { |
+ // Log zero if not perfectly converted. |
+ if (!base::StringToUint( |
+ net::android::GetTelephonyNetworkOperator(), &mcc_mnc)) { |
+ mcc_mnc = 0; |
+ } |
+ } |
+ UMA_HISTOGRAM_SPARSE_SLOWLY( |
+ "NCN.NetworkOperatorMCCMNC_NewMetricsLog", mcc_mnc); |
Ilya Sherman
2014/05/07 01:03:16
Hmm, I was expecting that you'd emit to a single h
bolian
2014/05/07 02:20:26
It is more about the accurate of the name, this on
Ilya Sherman
2014/05/07 23:57:40
Why does it matter which one is first? If there a
bolian
2014/05/08 00:54:51
Mainly, I want to differentiate below two cases:
Ilya Sherman
2014/05/08 01:10:11
If you emit to a single histogram, you're in case
bolian
2014/05/08 01:29:58
hmm, I can do that (and remove the metric to be _C
Ilya Sherman
2014/05/08 03:09:40
The benefit is indeed having fewer histograms to m
bolian
2014/05/08 03:47:18
fair enough. I combined them and rename it by remo
|
+#endif |
+} |