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

Unified Diff: chrome/browser/chrome_browser_metrics_log_observer.cc

Issue 253203002: Log operator code histogram on new metric log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@api_move
Patch Set: . 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 side-by-side diff with in-line comments
Download patch
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..261f231580edbca7e4028c087ae3b465ddced37d
--- /dev/null
+++ b/chrome/browser/chrome_browser_metrics_log_observer.cc
@@ -0,0 +1,42 @@
+// 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.
+// 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() {
+#if defined(OS_ANDROID)
+ MetricsServiceHelper::AddMetricsLogObserver(this);
+#endif
+}
+
+ChromeBrowserMetricsLogObserver::~ChromeBrowserMetricsLogObserver() {
+#if defined(OS_ANDROID)
+ MetricsServiceHelper::RemoveMetricsLogObserver(this);
+#endif
+}
+
+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
+#if defined(OS_ANDROID)
+ net::NetworkChangeNotifier::ConnectionType type =
+ net::NetworkChangeNotifier::GetConnectionType();
+ unsigned mcc_mnc = 0;
+ 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
+ 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;
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
+ }
+ }
+ UMA_HISTOGRAM_SPARSE_SLOWLY(
+ "NCN.NetworkOperatorMCCMNC_NewMetricsLog", mcc_mnc);
+#endif
+}

Powered by Google App Engine
This is Rietveld 408576698