summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 21:30:59 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 21:30:59 +0000
commitd3c902b2f2d157a0e40cfe4f684c3e95fc27fc80 (patch)
tree694c48c0fcd90b04fa1db078414cd5cafdc9c161 /chrome/browser/metrics
parent8f8e5e4506f48f2d6067f4f29b32b0683e6e110a (diff)
downloadchromium_src-d3c902b2f2d157a0e40cfe4f684c3e95fc27fc80.zip
chromium_src-d3c902b2f2d157a0e40cfe4f684c3e95fc27fc80.tar.gz
chromium_src-d3c902b2f2d157a0e40cfe4f684c3e95fc27fc80.tar.bz2
Lands http://codereview.chromium.org/149404 for cmasone:
Adding a protobuf-based metrics communication scheme between Chrome OS and Chrome. Essentially, Chrome is used as a metrics upload service, and this hacks in a simple IPC mechanism for Chrome OS to use to communicate metrics info to Chrome for upload. We eventually want to do this using protobuffers over DBus, but this protobuffers-over-X-properties mechanism will work for now. TEST=none BUG=none Review URL: http://codereview.chromium.org/149459 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20539 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics')
-rw-r--r--chrome/browser/metrics/system_metrics.proto14
-rw-r--r--chrome/browser/metrics/system_metrics_logger.h28
-rw-r--r--chrome/browser/metrics/system_metrics_logger_impl.cc44
-rw-r--r--chrome/browser/metrics/system_metrics_logger_impl.h31
4 files changed, 117 insertions, 0 deletions
diff --git a/chrome/browser/metrics/system_metrics.proto b/chrome/browser/metrics/system_metrics.proto
new file mode 100644
index 0000000..5118646
--- /dev/null
+++ b/chrome/browser/metrics/system_metrics.proto
@@ -0,0 +1,14 @@
+// Copyright (c) 2009 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.
+
+package chrome_os_pb;
+
+message SystemMetrics {
+ optional int32 boot_time_ms = 1;
+ optional int32 up_time_s = 2;
+ optional int32 keystroke_window_cycling_count = 3;
+ optional int32 overview_keystroke_count = 4;
+ optional int32 overview_exit_mouse_count = 5;
+ optional int32 overview_exit_keystroke_count = 6;
+}
diff --git a/chrome/browser/metrics/system_metrics_logger.h b/chrome/browser/metrics/system_metrics_logger.h
new file mode 100644
index 0000000..83f94f6
--- /dev/null
+++ b/chrome/browser/metrics/system_metrics_logger.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2009 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 CHROME_BROWSER_METRICS_SYSTEM_METRICS_LOGGER_H_
+#define CHROME_BROWSER_METRICS_SYSTEM_METRICS_LOGGER_H_
+
+#include "base/basictypes.h"
+
+class Profile;
+
+// This is the abstract base class for a simple class that wraps up some
+// calls to chromium metrics logging helper functions. This design will
+// allow for easy mocking in unit tests.
+
+class SystemMetricsLogger {
+ public:
+ SystemMetricsLogger() {}
+ virtual ~SystemMetricsLogger() {}
+ virtual void RecordOverviewKeystroke(Profile *profile) = 0;
+ virtual void RecordOverviewExitMouse(Profile *profile) = 0;
+ virtual void RecordOverviewExitKeystroke(Profile *profile) = 0;
+ virtual void RecordWindowCycleKeystroke(Profile *profile) = 0;
+ virtual void RecordBootTime(int64 time) = 0;
+ virtual void RecordUpTime(int64 time) = 0;
+};
+
+#endif // CHROME_BROWSER_METRICS_SYSTEM_METRICS_LOGGER_H_
diff --git a/chrome/browser/metrics/system_metrics_logger_impl.cc b/chrome/browser/metrics/system_metrics_logger_impl.cc
new file mode 100644
index 0000000..b16fe5d
--- /dev/null
+++ b/chrome/browser/metrics/system_metrics_logger_impl.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2009 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/metrics/system_metrics_logger_impl.h"
+
+#include "base/basictypes.h"
+#include "base/histogram.h"
+#include "base/time.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/metrics/user_metrics.h"
+
+SystemMetricsLoggerImpl::SystemMetricsLoggerImpl() {}
+
+SystemMetricsLoggerImpl::~SystemMetricsLoggerImpl() {}
+
+void SystemMetricsLoggerImpl::RecordOverviewKeystroke(Profile *profile) {
+ UserMetrics::RecordAction(L"TabOverview_Keystroke", profile);
+}
+
+void SystemMetricsLoggerImpl::RecordOverviewExitMouse(Profile *profile) {
+ UserMetrics::RecordAction(L"TabOverview_ExitMouse", profile);
+}
+
+void SystemMetricsLoggerImpl::RecordOverviewExitKeystroke(Profile *profile) {
+ UserMetrics::RecordAction(L"TabOverview_ExitKeystroke", profile);
+}
+
+void SystemMetricsLoggerImpl::RecordWindowCycleKeystroke(Profile *profile) {
+ UserMetrics::RecordAction(L"TabOverview_WindowCycleKeystroke", profile);
+}
+
+void SystemMetricsLoggerImpl::RecordBootTime(int64 time) {
+ UMA_HISTOGRAM_CUSTOM_TIMES("ChromeOS.Boot Time",
+ base::TimeDelta::FromMilliseconds(time),
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromMinutes(1),
+ 50);
+}
+
+void SystemMetricsLoggerImpl::RecordUpTime(int64 time) {
+ UMA_HISTOGRAM_LONG_TIMES("ChromeOS.Uptime",
+ base::TimeDelta::FromSeconds(time));
+}
diff --git a/chrome/browser/metrics/system_metrics_logger_impl.h b/chrome/browser/metrics/system_metrics_logger_impl.h
new file mode 100644
index 0000000..8bcfc5b
--- /dev/null
+++ b/chrome/browser/metrics/system_metrics_logger_impl.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2009 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 CHROME_BROWSER_METRICS_SYSTEM_METRICS_LOGGER_IMPL_H_
+#define CHROME_BROWSER_METRICS_SYSTEM_METRICS_LOGGER_IMPL_H_
+
+#include "base/basictypes.h"
+#include "chrome/browser/metrics/system_metrics_logger.h"
+
+class Profile;
+
+// Wraps calls to UserMetrics::RecordAction() and the appropriate
+// version of the UMA_HISTOGRAM_*_TIMES macros, based on the metric
+// being logged
+
+class SystemMetricsLoggerImpl : public SystemMetricsLogger {
+ public:
+ SystemMetricsLoggerImpl();
+ ~SystemMetricsLoggerImpl();
+ void RecordOverviewKeystroke(Profile *profile);
+ void RecordOverviewExitMouse(Profile *profile);
+ void RecordOverviewExitKeystroke(Profile *profile);
+ void RecordWindowCycleKeystroke(Profile *profile);
+ void RecordBootTime(int64 time);
+ void RecordUpTime(int64 time);
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SystemMetricsLoggerImpl);
+};
+
+#endif // CHROME_BROWSER_METRICS_SYSTEM_METRICS_LOGGER_IMPL_H_