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

Unified Diff: components/navigation_metrics/navigation_metrics.cc

Issue 35693009: Move Navigation.MainFrameScheme UMA recording to //components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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: components/navigation_metrics/navigation_metrics.cc
diff --git a/components/navigation_metrics/navigation_metrics.cc b/components/navigation_metrics/navigation_metrics.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cd398f699ec5b2a0c4c9b62bcccffcea1e750a19
--- /dev/null
+++ b/components/navigation_metrics/navigation_metrics.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2013 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 "components/navigation_metrics/navigation_metrics.h"
+
+#include "base/metrics/histogram.h"
+
+namespace {
+
+enum Scheme {
+ SCHEME_UNKNOWN,
+ SCHEME_HTTP,
+ SCHEME_HTTPS,
+ SCHEME_FILE,
+ SCHEME_FTP,
+ SCHEME_DATA,
+ SCHEME_JAVASCRIPT,
+ SCHEME_ABOUT,
+ SCHEME_CHROME,
+ SCHEME_MAX,
+};
+
+static const char* kSchemeNames[] = {
+ "unknown",
+ "http",
+ "https",
+ "file",
+ "ftp",
+ "data",
+ "javascript",
+ "about",
+ "chrome",
+ "max",
+};
+
+COMPILE_ASSERT(arraysize(kSchemeNames) == SCHEME_MAX + 1,
+ NavigationMetricsRecorder_name_count_mismatch);
+
+} // namespace
+
+namespace navigation_metrics {
+
+void RecordMainFrameNavigation(const GURL& url) {
+ Scheme scheme = SCHEME_UNKNOWN;
+ for (int i = 1; i < SCHEME_MAX; ++i) {
+ if (url.SchemeIs(kSchemeNames[i])) {
+ scheme = static_cast<Scheme>(i);
+ break;
+ }
+ }
+ UMA_HISTOGRAM_ENUMERATION(
+ "Navigation.MainFrameScheme", scheme, SCHEME_MAX);
+}
+
+} // namespace navigation_metrics

Powered by Google App Engine
This is Rietveld 408576698