summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 10:52:08 +0000
committerblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 10:52:08 +0000
commit91b1d919e2a0a4b7323b0f0e4e1f2452a4feeb64 (patch)
treee9b69f3a84f5dfe1933973e45e9a0af8d0197f38
parent6e46364a43d24b0a314048b00833e54aa2121498 (diff)
downloadchromium_src-91b1d919e2a0a4b7323b0f0e4e1f2452a4feeb64.zip
chromium_src-91b1d919e2a0a4b7323b0f0e4e1f2452a4feeb64.tar.gz
chromium_src-91b1d919e2a0a4b7323b0f0e4e1f2452a4feeb64.tar.bz2
Move MetricsLog into the Metrics component.
Also moves the prefs that MetricsLog uses. Leaves the unittest in //chrome for the time being as it has //chrome dependencies that will need to be worked through. BUG=374208 Review URL: https://codereview.chromium.org/310513008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275057 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/metrics/chrome_metrics_service_client.cc6
-rw-r--r--chrome/browser/metrics/chrome_metrics_service_client.h1
-rw-r--r--chrome/browser/metrics/metrics_log_unittest.cc12
-rw-r--r--chrome/browser/metrics/metrics_service.cc32
-rw-r--r--chrome/browser/metrics/metrics_service.h2
-rw-r--r--chrome/browser/metrics/metrics_service_browsertest.cc4
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/pref_names.cc36
-rw-r--r--chrome/common/pref_names.h10
-rw-r--r--components/metrics.gypi2
-rw-r--r--components/metrics/metrics_log.cc (renamed from chrome/browser/metrics/metrics_log.cc)67
-rw-r--r--components/metrics/metrics_log.h (renamed from chrome/browser/metrics/metrics_log.h)14
-rw-r--r--components/metrics/metrics_pref_names.cc36
-rw-r--r--components/metrics/metrics_pref_names.h9
-rw-r--r--components/metrics/metrics_service_client.h3
-rw-r--r--components/metrics/test_metrics_service_client.cc7
-rw-r--r--components/metrics/test_metrics_service_client.h3
17 files changed, 137 insertions, 109 deletions
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc
index 763d43a..011cb34 100644
--- a/chrome/browser/metrics/chrome_metrics_service_client.cc
+++ b/chrome/browser/metrics/chrome_metrics_service_client.cc
@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
+#include "base/prefs/pref_service.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -27,6 +28,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/crash_keys.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
#include "components/metrics/net/net_metrics_log_uploader.h"
#include "content/public/browser/browser_thread.h"
@@ -180,6 +182,10 @@ std::string ChromeMetricsServiceClient::GetVersionString() {
return version;
}
+int64 ChromeMetricsServiceClient::GetInstallDate() {
+ return g_browser_process->local_state()->GetInt64(prefs::kInstallDate);
+}
+
void ChromeMetricsServiceClient::OnLogUploadComplete() {
// Collect network stats after each UMA upload.
network_stats_uploader_.CollectAndReportNetworkStats();
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.h b/chrome/browser/metrics/chrome_metrics_service_client.h
index aba5945..63bf92e 100644
--- a/chrome/browser/metrics/chrome_metrics_service_client.h
+++ b/chrome/browser/metrics/chrome_metrics_service_client.h
@@ -43,6 +43,7 @@ class ChromeMetricsServiceClient : public metrics::MetricsServiceClient,
virtual bool GetBrand(std::string* brand_code) OVERRIDE;
virtual metrics::SystemProfileProto::Channel GetChannel() OVERRIDE;
virtual std::string GetVersionString() OVERRIDE;
+ virtual int64 GetInstallDate() OVERRIDE;
virtual void OnLogUploadComplete() OVERRIDE;
virtual void StartGatheringMetrics(
const base::Closure& done_callback) OVERRIDE;
diff --git a/chrome/browser/metrics/metrics_log_unittest.cc b/chrome/browser/metrics/metrics_log_unittest.cc
index 45768f0..8e22afd 100644
--- a/chrome/browser/metrics/metrics_log_unittest.cc
+++ b/chrome/browser/metrics/metrics_log_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/metrics/metrics_log.h"
+#include "components/metrics/metrics_log.h"
#include <string>
@@ -82,7 +82,6 @@ class TestMetricsLog : public MetricsLog {
private:
void InitPrefs() {
- prefs_->SetInt64(prefs::kInstallDate, kInstallDate);
prefs_->SetString(metrics::prefs::kMetricsReportingEnabledTimestamp,
base::Int64ToString(kEnabledDate));
}
@@ -174,6 +173,7 @@ class MetricsLogTest : public testing::Test {
TEST_F(MetricsLogTest, RecordEnvironment) {
metrics::TestMetricsServiceClient client;
+ client.set_install_date(kInstallDate);
TestMetricsLog log(
kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs_);
@@ -189,7 +189,7 @@ TEST_F(MetricsLogTest, RecordEnvironment) {
// Check that the system profile has also been written to prefs.
const std::string base64_system_profile =
- prefs_.GetString(prefs::kStabilitySavedSystemProfile);
+ prefs_.GetString(metrics::prefs::kStabilitySavedSystemProfile);
EXPECT_FALSE(base64_system_profile.empty());
std::string serialied_system_profile;
EXPECT_TRUE(base::Base64Decode(base64_system_profile,
@@ -200,10 +200,12 @@ TEST_F(MetricsLogTest, RecordEnvironment) {
}
TEST_F(MetricsLogTest, LoadSavedEnvironmentFromPrefs) {
- const char* kSystemProfilePref = prefs::kStabilitySavedSystemProfile;
- const char* kSystemProfileHashPref = prefs::kStabilitySavedSystemProfileHash;
+ const char* kSystemProfilePref = metrics::prefs::kStabilitySavedSystemProfile;
+ const char* kSystemProfileHashPref =
+ metrics::prefs::kStabilitySavedSystemProfileHash;
metrics::TestMetricsServiceClient client;
+ client.set_install_date(kInstallDate);
// The pref value is empty, so loading it from prefs should fail.
{
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 8575be8..9f594dc 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -186,13 +186,13 @@
#include "chrome/browser/io_thread.h"
#include "chrome/browser/metrics/chrome_stability_metrics_provider.h"
#include "chrome/browser/metrics/gpu_metrics_provider.h"
-#include "chrome/browser/metrics/metrics_log.h"
#include "chrome/browser/metrics/network_metrics_provider.h"
#include "chrome/browser/metrics/omnibox_metrics_provider.h"
#include "chrome/browser/metrics/profiler_metrics_provider.h"
#include "chrome/browser/metrics/tracking_synchronizer.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/variations/variations_util.h"
+#include "components/metrics/metrics_log.h"
#include "components/metrics/metrics_log_base.h"
#include "components/metrics/metrics_log_manager.h"
#include "components/metrics/metrics_log_uploader.h"
@@ -310,6 +310,7 @@ MetricsService::ExecutionPhase MetricsService::execution_phase_ =
void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) {
DCHECK(IsSingleThreaded());
metrics::MetricsStateManager::RegisterPrefs(registry);
+ MetricsLog::RegisterPrefs(registry);
registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0);
registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0);
@@ -320,19 +321,6 @@ void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) {
UNINITIALIZED_PHASE);
registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true);
registry->RegisterIntegerPref(metrics::prefs::kMetricsSessionID, -1);
- registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0);
- registry->RegisterIntegerPref(prefs::kStabilityCrashCount, 0);
- registry->RegisterIntegerPref(prefs::kStabilityIncompleteSessionEndCount, 0);
- registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationFail, 0);
- registry->RegisterIntegerPref(prefs::kStabilityBreakpadRegistrationSuccess,
- 0);
- registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0);
- registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0);
-
- registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile,
- std::string());
- registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash,
- std::string());
registry->RegisterListPref(metrics::prefs::kMetricsInitialLogs);
registry->RegisterListPref(metrics::prefs::kMetricsOngoingLogs);
@@ -607,16 +595,16 @@ void MetricsService::SetExecutionPhase(ExecutionPhase execution_phase,
void MetricsService::RecordBreakpadRegistration(bool success) {
if (!success)
- IncrementPrefValue(prefs::kStabilityBreakpadRegistrationFail);
+ IncrementPrefValue(metrics::prefs::kStabilityBreakpadRegistrationFail);
else
- IncrementPrefValue(prefs::kStabilityBreakpadRegistrationSuccess);
+ IncrementPrefValue(metrics::prefs::kStabilityBreakpadRegistrationSuccess);
}
void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) {
if (!has_debugger)
- IncrementPrefValue(prefs::kStabilityDebuggerNotPresent);
+ IncrementPrefValue(metrics::prefs::kStabilityDebuggerNotPresent);
else
- IncrementPrefValue(prefs::kStabilityDebuggerPresent);
+ IncrementPrefValue(metrics::prefs::kStabilityDebuggerPresent);
}
//------------------------------------------------------------------------------
@@ -636,7 +624,7 @@ void MetricsService::InitializeMetricsState() {
session_id_ = local_state_->GetInteger(metrics::prefs::kMetricsSessionID);
if (!local_state_->GetBoolean(prefs::kStabilityExitedCleanly)) {
- IncrementPrefValue(prefs::kStabilityCrashCount);
+ IncrementPrefValue(metrics::prefs::kStabilityCrashCount);
// Reset flag, and wait until we call LogNeedForCleanShutdown() before
// monitoring.
local_state_->SetBoolean(prefs::kStabilityExitedCleanly, true);
@@ -659,13 +647,13 @@ void MetricsService::InitializeMetricsState() {
local_state_->SetInteger(metrics::prefs::kMetricsSessionID, session_id_);
// Stability bookkeeping
- IncrementPrefValue(prefs::kStabilityLaunchCount);
+ IncrementPrefValue(metrics::prefs::kStabilityLaunchCount);
DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_);
SetExecutionPhase(START_METRICS_RECORDING, local_state_);
if (!local_state_->GetBoolean(prefs::kStabilitySessionEndCompleted)) {
- IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount);
+ IncrementPrefValue(metrics::prefs::kStabilityIncompleteSessionEndCount);
// This is marked false when we get a WM_ENDSESSION.
local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true);
}
@@ -1039,7 +1027,7 @@ void MetricsService::StageNewLog() {
void MetricsService::PrepareInitialStabilityLog() {
DCHECK_EQ(INITIALIZED, state_);
- DCHECK_NE(0, local_state_->GetInteger(prefs::kStabilityCrashCount));
+ DCHECK_NE(0, local_state_->GetInteger(metrics::prefs::kStabilityCrashCount));
scoped_ptr<MetricsLog> initial_stability_log(
CreateLog(MetricsLog::INITIAL_STABILITY_LOG));
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h
index 18eb612..c56b469 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -26,8 +26,8 @@
#include "base/strings/string16.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
-#include "chrome/browser/metrics/metrics_log.h"
#include "chrome/browser/metrics/tracking_synchronizer_observer.h"
+#include "components/metrics/metrics_log.h"
#include "components/metrics/metrics_log_manager.h"
#include "components/metrics/metrics_provider.h"
#include "components/metrics/metrics_service_observer.h"
diff --git a/chrome/browser/metrics/metrics_service_browsertest.cc b/chrome/browser/metrics/metrics_service_browsertest.cc
index d87f5b7..328f994 100644
--- a/chrome/browser/metrics/metrics_service_browsertest.cc
+++ b/chrome/browser/metrics/metrics_service_browsertest.cc
@@ -64,7 +64,7 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, CloseRenderersNormally) {
// Verify that the expected stability metrics were recorded.
const PrefService* prefs = g_browser_process->local_state();
- EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount));
+ EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount));
EXPECT_EQ(3, prefs->GetInteger(prefs::kStabilityPageLoadCount));
EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityRendererCrashCount));
// TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly
@@ -100,7 +100,7 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, MAYBE_CrashRenderers) {
}
// Verify that the expected stability metrics were recorded.
- EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount));
+ EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount));
EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount));
EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount));
// TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index d77bf97..3ae4eec 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1225,8 +1225,6 @@
'browser/metrics/gpu_metrics_provider.cc',
'browser/metrics/gpu_metrics_provider.h',
'browser/metrics/metric_event_duration_details.h',
- 'browser/metrics/metrics_log.cc',
- 'browser/metrics/metrics_log.h',
'browser/metrics/metrics_service.cc',
'browser/metrics/metrics_service.h',
'browser/metrics/metrics_service_accessor.cc',
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index c7a9e43..6211af2 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1399,30 +1399,10 @@ const char kStabilityStatsBuildTime[] =
const char kStabilitySessionEndCompleted[] =
"user_experience_metrics.stability.session_end_completed";
-// Number of times the application was launched since last report.
-const char kStabilityLaunchCount[] =
- "user_experience_metrics.stability.launch_count";
-
-// Number of times the application exited uncleanly since the last report.
-const char kStabilityCrashCount[] =
- "user_experience_metrics.stability.crash_count";
-
-// Number of times the session end did not complete.
-const char kStabilityIncompleteSessionEndCount[] =
- "user_experience_metrics.stability.incomplete_session_end_count";
-
// Number of times a page load event occurred since the last report.
const char kStabilityPageLoadCount[] =
"user_experience_metrics.stability.page_load_count";
-// Base64 encoded serialized UMA system profile proto from the previous session.
-const char kStabilitySavedSystemProfile[] =
- "user_experience_metrics.stability.saved_system_profile";
-
-// SHA-1 hash of the serialized UMA system profile proto (hex encoded).
-const char kStabilitySavedSystemProfileHash[] =
- "user_experience_metrics.stability.saved_system_profile_hash";
-
// Number of times a renderer process crashed since the last report.
const char kStabilityRendererCrashCount[] =
"user_experience_metrics.stability.renderer_crash_count";
@@ -1492,22 +1472,6 @@ const char kStabilityCrashedActivityCounts[] =
"user_experience_metrics.stability.crashed_activity_counts";
#endif
-// Number of times the browser has been able to register crash reporting.
-const char kStabilityBreakpadRegistrationSuccess[] =
- "user_experience_metrics.stability.breakpad_registration_ok";
-
-// Number of times the browser has failed to register crash reporting.
-const char kStabilityBreakpadRegistrationFail[] =
- "user_experience_metrics.stability.breakpad_registration_fail";
-
-// Number of times the browser has been run under a debugger.
-const char kStabilityDebuggerPresent[] =
- "user_experience_metrics.stability.debugger_present";
-
-// Number of times the browser has not been run under a debugger.
-const char kStabilityDebuggerNotPresent[] =
- "user_experience_metrics.stability.debugger_not_present";
-
// The keys below are used for the dictionaries in the
// kStabilityPluginStats list.
const char kStabilityPluginName[] = "name";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 6e8a424..bda86ac 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -456,12 +456,7 @@ extern const char kStabilityExitedCleanly[];
extern const char kStabilityStatsVersion[];
extern const char kStabilityStatsBuildTime[];
extern const char kStabilitySessionEndCompleted[];
-extern const char kStabilityLaunchCount[];
-extern const char kStabilityCrashCount[];
-extern const char kStabilityIncompleteSessionEndCount[];
extern const char kStabilityPageLoadCount[];
-extern const char kStabilitySavedSystemProfile[];
-extern const char kStabilitySavedSystemProfileHash[];
extern const char kStabilityRendererCrashCount[];
extern const char kStabilityExtensionRendererCrashCount[];
extern const char kStabilityLaunchTimeSec[];
@@ -478,11 +473,6 @@ extern const char kStabilityLaunchedActivityCounts[];
extern const char kStabilityCrashedActivityCounts[];
#endif
-extern const char kStabilityBreakpadRegistrationSuccess[];
-extern const char kStabilityBreakpadRegistrationFail[];
-extern const char kStabilityDebuggerPresent[];
-extern const char kStabilityDebuggerNotPresent[];
-
extern const char kStabilityPluginStats[];
extern const char kStabilityPluginName[];
extern const char kStabilityPluginLaunches[];
diff --git a/components/metrics.gypi b/components/metrics.gypi
index e9f8fcc..f1473c4 100644
--- a/components/metrics.gypi
+++ b/components/metrics.gypi
@@ -24,6 +24,8 @@
'metrics/machine_id_provider_win.cc',
'metrics/metrics_hashes.cc',
'metrics/metrics_hashes.h',
+ 'metrics/metrics_log.cc',
+ 'metrics/metrics_log.h',
'metrics/metrics_log_base.cc',
'metrics/metrics_log_base.h',
'metrics/metrics_log_uploader.cc',
diff --git a/chrome/browser/metrics/metrics_log.cc b/components/metrics/metrics_log.cc
index 8ec2087..e88d5f9 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/components/metrics/metrics_log.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 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/metrics_log.h"
+#include "components/metrics/metrics_log.h"
#include <algorithm>
#include <string>
@@ -21,7 +21,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
#include "base/time/time.h"
-#include "chrome/common/pref_names.h"
+#include "components/metrics/metrics_pref_names.h"
#include "components/metrics/metrics_provider.h"
#include "components/metrics/metrics_service_client.h"
#include "components/metrics/proto/system_profile.pb.h"
@@ -99,6 +99,25 @@ MetricsLog::MetricsLog(const std::string& client_id,
MetricsLog::~MetricsLog() {}
+// static
+void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) {
+ registry->RegisterIntegerPref(metrics::prefs::kStabilityLaunchCount, 0);
+ registry->RegisterIntegerPref(metrics::prefs::kStabilityCrashCount, 0);
+ registry->RegisterIntegerPref(
+ metrics::prefs::kStabilityIncompleteSessionEndCount, 0);
+ registry->RegisterIntegerPref(
+ metrics::prefs::kStabilityBreakpadRegistrationFail, 0);
+ registry->RegisterIntegerPref(
+ metrics::prefs::kStabilityBreakpadRegistrationSuccess, 0);
+ registry->RegisterIntegerPref(metrics::prefs::kStabilityDebuggerPresent, 0);
+ registry->RegisterIntegerPref(metrics::prefs::kStabilityDebuggerNotPresent,
+ 0);
+ registry->RegisterStringPref(metrics::prefs::kStabilitySavedSystemProfile,
+ std::string());
+ registry->RegisterStringPref(metrics::prefs::kStabilitySavedSystemProfileHash,
+ std::string());
+}
+
void MetricsLog::RecordStabilityMetrics(
const std::vector<metrics::MetricsProvider*>& metrics_providers,
base::TimeDelta incremental_uptime,
@@ -131,20 +150,20 @@ void MetricsLog::RecordStabilityMetrics(
return;
int incomplete_shutdown_count =
- pref->GetInteger(prefs::kStabilityIncompleteSessionEndCount);
- pref->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
+ pref->GetInteger(metrics::prefs::kStabilityIncompleteSessionEndCount);
+ pref->SetInteger(metrics::prefs::kStabilityIncompleteSessionEndCount, 0);
int breakpad_registration_success_count =
- pref->GetInteger(prefs::kStabilityBreakpadRegistrationSuccess);
- pref->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0);
+ pref->GetInteger(metrics::prefs::kStabilityBreakpadRegistrationSuccess);
+ pref->SetInteger(metrics::prefs::kStabilityBreakpadRegistrationSuccess, 0);
int breakpad_registration_failure_count =
- pref->GetInteger(prefs::kStabilityBreakpadRegistrationFail);
- pref->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0);
+ pref->GetInteger(metrics::prefs::kStabilityBreakpadRegistrationFail);
+ pref->SetInteger(metrics::prefs::kStabilityBreakpadRegistrationFail, 0);
int debugger_present_count =
- pref->GetInteger(prefs::kStabilityDebuggerPresent);
- pref->SetInteger(prefs::kStabilityDebuggerPresent, 0);
+ pref->GetInteger(metrics::prefs::kStabilityDebuggerPresent);
+ pref->SetInteger(metrics::prefs::kStabilityDebuggerPresent, 0);
int debugger_not_present_count =
- pref->GetInteger(prefs::kStabilityDebuggerNotPresent);
- pref->SetInteger(prefs::kStabilityDebuggerNotPresent, 0);
+ pref->GetInteger(metrics::prefs::kStabilityDebuggerNotPresent);
+ pref->SetInteger(metrics::prefs::kStabilityDebuggerNotPresent, 0);
// TODO(jar): The following are all optional, so we *could* optimize them for
// values of zero (and not include them).
@@ -183,10 +202,10 @@ bool MetricsLog::HasStabilityMetrics() const {
// TODO(isherman): Stop writing these attributes specially once the migration to
// protobufs is complete.
void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) {
- int launch_count = pref->GetInteger(prefs::kStabilityLaunchCount);
- pref->SetInteger(prefs::kStabilityLaunchCount, 0);
- int crash_count = pref->GetInteger(prefs::kStabilityCrashCount);
- pref->SetInteger(prefs::kStabilityCrashCount, 0);
+ int launch_count = pref->GetInteger(metrics::prefs::kStabilityLaunchCount);
+ pref->SetInteger(metrics::prefs::kStabilityLaunchCount, 0);
+ int crash_count = pref->GetInteger(metrics::prefs::kStabilityCrashCount);
+ pref->SetInteger(metrics::prefs::kStabilityCrashCount, 0);
SystemProfileProto::Stability* stability =
uma_proto()->mutable_system_profile()->mutable_stability();
@@ -232,7 +251,7 @@ void MetricsLog::RecordEnvironment(
// Reduce granularity of the enabled_date field to nearest hour.
system_profile->set_uma_enabled_date(RoundSecondsToHour(enabled_date));
- int64 install_date = local_state_->GetInt64(prefs::kInstallDate);
+ int64 install_date = client_->GetInstallDate();
// Reduce granularity of the install_date field to nearest hour.
system_profile->set_install_date(RoundSecondsToHour(install_date));
@@ -286,9 +305,9 @@ void MetricsLog::RecordEnvironment(
if (system_profile->SerializeToString(&serialied_system_profile)) {
base::Base64Encode(serialied_system_profile, &base64_system_profile);
PrefService* local_state = local_state_;
- local_state->SetString(prefs::kStabilitySavedSystemProfile,
+ local_state->SetString(metrics::prefs::kStabilitySavedSystemProfile,
base64_system_profile);
- local_state->SetString(prefs::kStabilitySavedSystemProfileHash,
+ local_state->SetString(metrics::prefs::kStabilitySavedSystemProfileHash,
ComputeSHA1(serialied_system_profile));
}
}
@@ -296,14 +315,14 @@ void MetricsLog::RecordEnvironment(
bool MetricsLog::LoadSavedEnvironmentFromPrefs() {
PrefService* local_state = local_state_;
const std::string base64_system_profile =
- local_state->GetString(prefs::kStabilitySavedSystemProfile);
+ local_state->GetString(metrics::prefs::kStabilitySavedSystemProfile);
if (base64_system_profile.empty())
return false;
const std::string system_profile_hash =
- local_state->GetString(prefs::kStabilitySavedSystemProfileHash);
- local_state->ClearPref(prefs::kStabilitySavedSystemProfile);
- local_state->ClearPref(prefs::kStabilitySavedSystemProfileHash);
+ local_state->GetString(metrics::prefs::kStabilitySavedSystemProfileHash);
+ local_state->ClearPref(metrics::prefs::kStabilitySavedSystemProfile);
+ local_state->ClearPref(metrics::prefs::kStabilitySavedSystemProfileHash);
SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
std::string serialied_system_profile;
diff --git a/chrome/browser/metrics/metrics_log.h b/components/metrics/metrics_log.h
index 786baf7..03b280d 100644
--- a/chrome/browser/metrics/metrics_log.h
+++ b/components/metrics/metrics_log.h
@@ -1,21 +1,20 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 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.
// This file defines a set of user experience metrics data recorded by
// the MetricsService. This is the unit of data that is sent to the server.
-#ifndef CHROME_BROWSER_METRICS_METRICS_LOG_H_
-#define CHROME_BROWSER_METRICS_METRICS_LOG_H_
+#ifndef COMPONENTS_METRICS_METRICS_LOG_H_
+#define COMPONENTS_METRICS_METRICS_LOG_H_
#include <string>
#include <vector>
#include "base/basictypes.h"
-#include "chrome/common/variations/variations_util.h"
#include "components/metrics/metrics_log_base.h"
-#include "ui/gfx/size.h"
+class PrefRegistrySimple;
class PrefService;
namespace base {
@@ -56,6 +55,9 @@ class MetricsLog : public metrics::MetricsLogBase {
PrefService* local_state);
virtual ~MetricsLog();
+ // Registers local state prefs used by this class.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
// Records the current operating environment, including metrics provided by
// the specified set of |metrics_providers|. Takes the list of installed
// plugins, Google Update statistics, and synthetic trial IDs as parameters
@@ -136,4 +138,4 @@ class MetricsLog : public metrics::MetricsLogBase {
DISALLOW_COPY_AND_ASSIGN(MetricsLog);
};
-#endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_
+#endif // COMPONENTS_METRICS_METRICS_LOG_H_
diff --git a/components/metrics/metrics_pref_names.cc b/components/metrics/metrics_pref_names.cc
index 500909c..68b5f72 100644
--- a/components/metrics/metrics_pref_names.cc
+++ b/components/metrics/metrics_pref_names.cc
@@ -55,5 +55,41 @@ const char kMetricsReportingEnabledTimestamp[] =
// The metrics client session ID.
const char kMetricsSessionID[] = "user_experience_metrics.session_id";
+// Number of times the browser has been able to register crash reporting.
+const char kStabilityBreakpadRegistrationSuccess[] =
+ "user_experience_metrics.stability.breakpad_registration_ok";
+
+// Number of times the browser has failed to register crash reporting.
+const char kStabilityBreakpadRegistrationFail[] =
+ "user_experience_metrics.stability.breakpad_registration_fail";
+
+// Number of times the application exited uncleanly since the last report.
+const char kStabilityCrashCount[] =
+ "user_experience_metrics.stability.crash_count";
+
+// Number of times the browser has been run under a debugger.
+const char kStabilityDebuggerPresent[] =
+ "user_experience_metrics.stability.debugger_present";
+
+// Number of times the browser has not been run under a debugger.
+const char kStabilityDebuggerNotPresent[] =
+ "user_experience_metrics.stability.debugger_not_present";
+
+// Number of times the session end did not complete.
+const char kStabilityIncompleteSessionEndCount[] =
+ "user_experience_metrics.stability.incomplete_session_end_count";
+
+// Number of times the application was launched since last report.
+const char kStabilityLaunchCount[] =
+ "user_experience_metrics.stability.launch_count";
+
+// Base64 encoded serialized UMA system profile proto from the previous session.
+const char kStabilitySavedSystemProfile[] =
+ "user_experience_metrics.stability.saved_system_profile";
+
+// SHA-1 hash of the serialized UMA system profile proto (hex encoded).
+const char kStabilitySavedSystemProfileHash[] =
+ "user_experience_metrics.stability.saved_system_profile_hash";
+
} // namespace prefs
} // namespace metrics
diff --git a/components/metrics/metrics_pref_names.h b/components/metrics/metrics_pref_names.h
index 2f59fef..b52365d 100644
--- a/components/metrics/metrics_pref_names.h
+++ b/components/metrics/metrics_pref_names.h
@@ -20,6 +20,15 @@ extern const char kMetricsOngoingLogs[];
extern const char kMetricsResetIds[];
extern const char kMetricsReportingEnabledTimestamp[];
extern const char kMetricsSessionID[];
+extern const char kStabilityBreakpadRegistrationSuccess[];
+extern const char kStabilityBreakpadRegistrationFail[];
+extern const char kStabilityCrashCount[];
+extern const char kStabilityDebuggerPresent[];
+extern const char kStabilityDebuggerNotPresent[];
+extern const char kStabilityIncompleteSessionEndCount[];
+extern const char kStabilityLaunchCount[];
+extern const char kStabilitySavedSystemProfile[];
+extern const char kStabilitySavedSystemProfileHash[];
} // namespace prefs
} // namespace metrics
diff --git a/components/metrics/metrics_service_client.h b/components/metrics/metrics_service_client.h
index 1fcfb6e..1ef3188 100644
--- a/components/metrics/metrics_service_client.h
+++ b/components/metrics/metrics_service_client.h
@@ -42,6 +42,9 @@ class MetricsServiceClient {
// Returns the version of the application as a string.
virtual std::string GetVersionString() = 0;
+ // Returns the install date of the application, in seconds since the epoch.
+ virtual int64 GetInstallDate() = 0;
+
// Called by the metrics service when a log has been uploaded.
virtual void OnLogUploadComplete() = 0;
diff --git a/components/metrics/test_metrics_service_client.cc b/components/metrics/test_metrics_service_client.cc
index 8d1b337..b17d3d3 100644
--- a/components/metrics/test_metrics_service_client.cc
+++ b/components/metrics/test_metrics_service_client.cc
@@ -12,7 +12,8 @@ namespace metrics {
// static
const char TestMetricsServiceClient::kBrandForTesting[] = "brand_for_testing";
-TestMetricsServiceClient::TestMetricsServiceClient() {
+TestMetricsServiceClient::TestMetricsServiceClient()
+ : install_date_(0) {
}
TestMetricsServiceClient::~TestMetricsServiceClient() {
@@ -43,6 +44,10 @@ std::string TestMetricsServiceClient::GetVersionString() {
return "5.0.322.0-64-devel";
}
+int64 TestMetricsServiceClient::GetInstallDate() {
+ return install_date_;
+}
+
void TestMetricsServiceClient::OnLogUploadComplete() {
}
diff --git a/components/metrics/test_metrics_service_client.h b/components/metrics/test_metrics_service_client.h
index 407109d..1b06b43 100644
--- a/components/metrics/test_metrics_service_client.h
+++ b/components/metrics/test_metrics_service_client.h
@@ -27,6 +27,7 @@ class TestMetricsServiceClient : public MetricsServiceClient {
virtual bool GetBrand(std::string* brand_code) OVERRIDE;
virtual SystemProfileProto::Channel GetChannel() OVERRIDE;
virtual std::string GetVersionString() OVERRIDE;
+ virtual int64 GetInstallDate() OVERRIDE;
virtual void OnLogUploadComplete() OVERRIDE;
virtual void StartGatheringMetrics(
const base::Closure& done_callback) OVERRIDE;
@@ -38,9 +39,11 @@ class TestMetricsServiceClient : public MetricsServiceClient {
const base::Callback<void(int)>& on_upload_complete) OVERRIDE;
const std::string& get_client_id() const { return client_id_; }
+ void set_install_date(int64 install_date) { install_date_ = install_date; }
private:
std::string client_id_;
+ int64 install_date_;
};
} // namespace metrics