summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 22:00:16 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 22:00:16 +0000
commit5ccaa41d72d5241e76bad7f16c3e0147d990584b (patch)
treec3d4ec81cc6ccb79f6aa0e923930f7781bcb4e90 /chrome/browser/metrics
parent2581e577597dd0f435ae1e6fe918df912bb98248 (diff)
downloadchromium_src-5ccaa41d72d5241e76bad7f16c3e0147d990584b.zip
chromium_src-5ccaa41d72d5241e76bad7f16c3e0147d990584b.tar.gz
chromium_src-5ccaa41d72d5241e76bad7f16c3e0147d990584b.tar.bz2
Use Chrome to transport Chrome OS metrics.
Chrome periodically reads the content of a well-know file, and parses it into name-value pairs, each representing a Chrome OS metrics event. The events are then logged using the normal UMA mechanism. The file is then truncated to zero size. Chrome uses flock() to synchronize accesses to the file. BUG=none TEST=compiled and run Linux and Chrome OS versions. Verified that uploaded Chrome OS events appear in about:histograms. Also external_metrics_unittest.cc tests the collection of metrics messages from the well-known file. patch written by semenzato_google.com original code review: http://codereview.chromium.org/378013 (plus http://codereview.chromium.org/346041) Review URL: http://codereview.chromium.org/394010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics')
-rw-r--r--chrome/browser/metrics/metrics_service.cc11
-rw-r--r--chrome/browser/metrics/metrics_service.h15
-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
5 files changed, 26 insertions, 103 deletions
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index a16ced2..c49886a 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -197,6 +197,10 @@
#include "chrome/installer/util/browser_distribution.h"
#endif
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/external_metrics.h"
+#endif
+
using base::Time;
using base::TimeDelta;
@@ -1921,3 +1925,10 @@ static bool IsSingleThreaded() {
thread_id = PlatformThread::CurrentId();
return PlatformThread::CurrentId() == thread_id;
}
+
+#if defined(OS_CHROMEOS)
+void MetricsService::StartExternalMetrics(Profile* profile) {
+ external_metrics_ = new chromeos::ExternalMetrics;
+ external_metrics_->Start(profile);
+}
+#endif
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h
index 03b181f..9fa21fc 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -25,6 +25,10 @@
#include "webkit/glue/webplugininfo.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/external_metrics.h"
+#endif
+
class BookmarkModel;
class BookmarkNode;
class HistogramSynchronizer;
@@ -120,6 +124,12 @@ class MetricsService : public NotificationObserver,
// at shutdown, but we can do it as we reduce the list as well.
void StoreUnsentLogs();
+#if defined(OS_CHROMEOS)
+ // Start the external metrics service, which collects metrics from Chrome OS
+ // and passes them to UMA.
+ void StartExternalMetrics(Profile* profile);
+#endif
+
private:
// The MetricsService has a lifecycle that is stored as a state.
// See metrics_service.cc for description of this lifecycle.
@@ -496,6 +506,11 @@ class MetricsService : public NotificationObserver,
// Indicate that a timer for sending the next log has already been queued.
bool timer_pending_;
+#if defined(OS_CHROMEOS)
+ // The external metric service is used to log ChromeOS UMA events.
+ scoped_refptr<chromeos::ExternalMetrics> external_metrics_;
+#endif
+
FRIEND_TEST(MetricsServiceTest, ClientIdGeneratesAllZeroes);
FRIEND_TEST(MetricsServiceTest, ClientIdGeneratesCorrectly);
FRIEND_TEST(MetricsServiceTest, ClientIdCorrectlyFormatted);
diff --git a/chrome/browser/metrics/system_metrics_logger.h b/chrome/browser/metrics/system_metrics_logger.h
deleted file mode 100644
index 83f94f6..0000000
--- a/chrome/browser/metrics/system_metrics_logger.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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
deleted file mode 100644
index b16fe5d..0000000
--- a/chrome/browser/metrics/system_metrics_logger_impl.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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
deleted file mode 100644
index 8bcfc5b..0000000
--- a/chrome/browser/metrics/system_metrics_logger_impl.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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_