summaryrefslogtreecommitdiffstats
path: root/components/navigation_metrics
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-23 20:58:25 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-23 20:58:25 +0000
commite600542d4dc7c28c5b319a24cb33037c4f7043f9 (patch)
tree5f94ee02dd38b1861f851fedb7234f3fbde0c2ec /components/navigation_metrics
parent98bca37088528b4066dac95c12ec134e1c0aa3b6 (diff)
downloadchromium_src-e600542d4dc7c28c5b319a24cb33037c4f7043f9.zip
chromium_src-e600542d4dc7c28c5b319a24cb33037c4f7043f9.tar.gz
chromium_src-e600542d4dc7c28c5b319a24cb33037c4f7043f9.tar.bz2
Move Navigation.MainFrameScheme UMA recording to //components.
This change is simply a refactoring, and does not change behavior. BUG=299173 TEST=Run chromium, check about:histograms and make sure that Navigation.MainFrameScheme matches expectations. Review URL: https://codereview.chromium.org/35693009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230508 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/navigation_metrics')
-rw-r--r--components/navigation_metrics/navigation_metrics.cc57
-rw-r--r--components/navigation_metrics/navigation_metrics.h16
2 files changed, 73 insertions, 0 deletions
diff --git a/components/navigation_metrics/navigation_metrics.cc b/components/navigation_metrics/navigation_metrics.cc
new file mode 100644
index 0000000..acbe25a
--- /dev/null
+++ b/components/navigation_metrics/navigation_metrics.cc
@@ -0,0 +1,57 @@
+// Copyright 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"
+#include "url/gurl.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
diff --git a/components/navigation_metrics/navigation_metrics.h b/components/navigation_metrics/navigation_metrics.h
new file mode 100644
index 0000000..db5eb7f
--- /dev/null
+++ b/components/navigation_metrics/navigation_metrics.h
@@ -0,0 +1,16 @@
+// Copyright 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.
+
+#ifndef COMPONENTS_NAVIGATION_METRICS_NAVIGATION_METRICS_H_
+#define COMPONENTS_NAVIGATION_METRICS_NAVIGATION_METRICS_H_
+
+class GURL;
+
+namespace navigation_metrics {
+
+void RecordMainFrameNavigation(const GURL& url);
+
+} // namespace navigation_metrics
+
+#endif // COMPONENTS_NAVIGATION_METRICS_NAVIGATION_METRICS_H_