summaryrefslogtreecommitdiffstats
path: root/components
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 /components
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
Diffstat (limited to 'components')
-rw-r--r--components/metrics.gypi2
-rw-r--r--components/metrics/metrics_log.cc333
-rw-r--r--components/metrics/metrics_log.h141
-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
8 files changed, 533 insertions, 1 deletions
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/components/metrics/metrics_log.cc b/components/metrics/metrics_log.cc
new file mode 100644
index 0000000..e88d5f9
--- /dev/null
+++ b/components/metrics/metrics_log.cc
@@ -0,0 +1,333 @@
+// 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 "components/metrics/metrics_log.h"
+
+#include <algorithm>
+#include <string>
+#include <vector>
+
+#include "base/base64.h"
+#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/cpu.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/prefs/pref_registry_simple.h"
+#include "base/prefs/pref_service.h"
+#include "base/sha1.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/sys_info.h"
+#include "base/time/time.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"
+#include "components/variations/active_field_trials.h"
+
+#if defined(OS_ANDROID)
+#include "base/android/build_info.h"
+#endif
+
+#if defined(OS_WIN)
+#include "base/win/metro.h"
+
+// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
+extern "C" IMAGE_DOS_HEADER __ImageBase;
+#endif
+
+using metrics::MetricsLogBase;
+using metrics::ProfilerEventProto;
+using metrics::SystemProfileProto;
+typedef variations::ActiveGroupId ActiveGroupId;
+
+namespace {
+
+// Returns the date at which the current metrics client ID was created as
+// a string containing seconds since the epoch, or "0" if none was found.
+std::string GetMetricsEnabledDate(PrefService* pref) {
+ if (!pref) {
+ NOTREACHED();
+ return "0";
+ }
+
+ return pref->GetString(metrics::prefs::kMetricsReportingEnabledTimestamp);
+}
+
+// Computes a SHA-1 hash of |data| and returns it as a hex string.
+std::string ComputeSHA1(const std::string& data) {
+ const std::string sha1 = base::SHA1HashString(data);
+ return base::HexEncode(sha1.data(), sha1.size());
+}
+
+void WriteFieldTrials(const std::vector<ActiveGroupId>& field_trial_ids,
+ SystemProfileProto* system_profile) {
+ for (std::vector<ActiveGroupId>::const_iterator it =
+ field_trial_ids.begin(); it != field_trial_ids.end(); ++it) {
+ SystemProfileProto::FieldTrial* field_trial =
+ system_profile->add_field_trial();
+ field_trial->set_name_id(it->name);
+ field_trial->set_group_id(it->group);
+ }
+}
+
+// Round a timestamp measured in seconds since epoch to one with a granularity
+// of an hour. This can be used before uploaded potentially sensitive
+// timestamps.
+int64 RoundSecondsToHour(int64 time_in_seconds) {
+ return 3600 * (time_in_seconds / 3600);
+}
+
+} // namespace
+
+MetricsLog::MetricsLog(const std::string& client_id,
+ int session_id,
+ LogType log_type,
+ metrics::MetricsServiceClient* client,
+ PrefService* local_state)
+ : MetricsLogBase(client_id,
+ session_id,
+ log_type,
+ client->GetVersionString()),
+ client_(client),
+ creation_time_(base::TimeTicks::Now()),
+ local_state_(local_state) {
+ uma_proto()->mutable_system_profile()->set_channel(client_->GetChannel());
+}
+
+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,
+ base::TimeDelta uptime) {
+ DCHECK(!locked());
+ DCHECK(HasEnvironment());
+ DCHECK(!HasStabilityMetrics());
+
+ PrefService* pref = local_state_;
+ DCHECK(pref);
+
+ // Get stability attributes out of Local State, zeroing out stored values.
+ // NOTE: This could lead to some data loss if this report isn't successfully
+ // sent, but that's true for all the metrics.
+
+ WriteRequiredStabilityAttributes(pref);
+
+ // Record recent delta for critical stability metrics. We can't wait for a
+ // restart to gather these, as that delay biases our observation away from
+ // users that run happily for a looooong time. We send increments with each
+ // uma log upload, just as we send histogram data.
+ WriteRealtimeStabilityAttributes(pref, incremental_uptime, uptime);
+
+ SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
+ for (size_t i = 0; i < metrics_providers.size(); ++i)
+ metrics_providers[i]->ProvideStabilityMetrics(system_profile);
+
+ // Omit some stats unless this is the initial stability log.
+ if (log_type() != INITIAL_STABILITY_LOG)
+ return;
+
+ int incomplete_shutdown_count =
+ pref->GetInteger(metrics::prefs::kStabilityIncompleteSessionEndCount);
+ pref->SetInteger(metrics::prefs::kStabilityIncompleteSessionEndCount, 0);
+ int breakpad_registration_success_count =
+ pref->GetInteger(metrics::prefs::kStabilityBreakpadRegistrationSuccess);
+ pref->SetInteger(metrics::prefs::kStabilityBreakpadRegistrationSuccess, 0);
+ int breakpad_registration_failure_count =
+ pref->GetInteger(metrics::prefs::kStabilityBreakpadRegistrationFail);
+ pref->SetInteger(metrics::prefs::kStabilityBreakpadRegistrationFail, 0);
+ int debugger_present_count =
+ pref->GetInteger(metrics::prefs::kStabilityDebuggerPresent);
+ pref->SetInteger(metrics::prefs::kStabilityDebuggerPresent, 0);
+ int debugger_not_present_count =
+ 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).
+ SystemProfileProto::Stability* stability =
+ system_profile->mutable_stability();
+ stability->set_incomplete_shutdown_count(incomplete_shutdown_count);
+ stability->set_breakpad_registration_success_count(
+ breakpad_registration_success_count);
+ stability->set_breakpad_registration_failure_count(
+ breakpad_registration_failure_count);
+ stability->set_debugger_present_count(debugger_present_count);
+ stability->set_debugger_not_present_count(debugger_not_present_count);
+}
+
+void MetricsLog::RecordGeneralMetrics(
+ const std::vector<metrics::MetricsProvider*>& metrics_providers) {
+ for (size_t i = 0; i < metrics_providers.size(); ++i)
+ metrics_providers[i]->ProvideGeneralMetrics(uma_proto());
+}
+
+void MetricsLog::GetFieldTrialIds(
+ std::vector<ActiveGroupId>* field_trial_ids) const {
+ variations::GetFieldTrialActiveGroupIds(field_trial_ids);
+}
+
+bool MetricsLog::HasEnvironment() const {
+ return uma_proto()->system_profile().has_uma_enabled_date();
+}
+
+bool MetricsLog::HasStabilityMetrics() const {
+ return uma_proto()->system_profile().stability().has_launch_count();
+}
+
+// The server refuses data that doesn't have certain values. crashcount and
+// launchcount are currently "required" in the "stability" group.
+// TODO(isherman): Stop writing these attributes specially once the migration to
+// protobufs is complete.
+void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) {
+ 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();
+ stability->set_launch_count(launch_count);
+ stability->set_crash_count(crash_count);
+}
+
+void MetricsLog::WriteRealtimeStabilityAttributes(
+ PrefService* pref,
+ base::TimeDelta incremental_uptime,
+ base::TimeDelta uptime) {
+ // Update the stats which are critical for real-time stability monitoring.
+ // Since these are "optional," only list ones that are non-zero, as the counts
+ // are aggregated (summed) server side.
+
+ SystemProfileProto::Stability* stability =
+ uma_proto()->mutable_system_profile()->mutable_stability();
+
+ const uint64 incremental_uptime_sec = incremental_uptime.InSeconds();
+ if (incremental_uptime_sec)
+ stability->set_incremental_uptime_sec(incremental_uptime_sec);
+ const uint64 uptime_sec = uptime.InSeconds();
+ if (uptime_sec)
+ stability->set_uptime_sec(uptime_sec);
+}
+
+void MetricsLog::RecordEnvironment(
+ const std::vector<metrics::MetricsProvider*>& metrics_providers,
+ const std::vector<variations::ActiveGroupId>& synthetic_trials) {
+ DCHECK(!HasEnvironment());
+
+ SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
+
+ std::string brand_code;
+ if (client_->GetBrand(&brand_code))
+ system_profile->set_brand_code(brand_code);
+
+ int enabled_date;
+ bool success =
+ base::StringToInt(GetMetricsEnabledDate(local_state_), &enabled_date);
+ DCHECK(success);
+
+ // Reduce granularity of the enabled_date field to nearest hour.
+ system_profile->set_uma_enabled_date(RoundSecondsToHour(enabled_date));
+
+ int64 install_date = client_->GetInstallDate();
+
+ // Reduce granularity of the install_date field to nearest hour.
+ system_profile->set_install_date(RoundSecondsToHour(install_date));
+
+ system_profile->set_application_locale(client_->GetApplicationLocale());
+
+ SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware();
+
+ // By default, the hardware class is empty (i.e., unknown).
+ hardware->set_hardware_class(std::string());
+
+ hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture());
+ hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB());
+#if defined(OS_WIN)
+ hardware->set_dll_base(reinterpret_cast<uint64>(&__ImageBase));
+#endif
+
+ SystemProfileProto::OS* os = system_profile->mutable_os();
+ std::string os_name = base::SysInfo::OperatingSystemName();
+#if defined(OS_WIN)
+ // TODO(mad): This only checks whether the main process is a Metro process at
+ // upload time; not whether the collected metrics were all gathered from
+ // Metro. This is ok as an approximation for now, since users will rarely be
+ // switching from Metro to Desktop mode; but we should re-evaluate whether we
+ // can distinguish metrics more cleanly in the future: http://crbug.com/140568
+ if (base::win::IsMetroProcess())
+ os_name += " (Metro)";
+#endif
+ os->set_name(os_name);
+ os->set_version(base::SysInfo::OperatingSystemVersion());
+#if defined(OS_ANDROID)
+ os->set_fingerprint(
+ base::android::BuildInfo::GetInstance()->android_build_fp());
+#endif
+
+ base::CPU cpu_info;
+ SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu();
+ cpu->set_vendor_name(cpu_info.vendor_name());
+ cpu->set_signature(cpu_info.signature());
+
+ std::vector<ActiveGroupId> field_trial_ids;
+ GetFieldTrialIds(&field_trial_ids);
+ WriteFieldTrials(field_trial_ids, system_profile);
+ WriteFieldTrials(synthetic_trials, system_profile);
+
+ for (size_t i = 0; i < metrics_providers.size(); ++i)
+ metrics_providers[i]->ProvideSystemProfileMetrics(system_profile);
+
+ std::string serialied_system_profile;
+ std::string base64_system_profile;
+ if (system_profile->SerializeToString(&serialied_system_profile)) {
+ base::Base64Encode(serialied_system_profile, &base64_system_profile);
+ PrefService* local_state = local_state_;
+ local_state->SetString(metrics::prefs::kStabilitySavedSystemProfile,
+ base64_system_profile);
+ local_state->SetString(metrics::prefs::kStabilitySavedSystemProfileHash,
+ ComputeSHA1(serialied_system_profile));
+ }
+}
+
+bool MetricsLog::LoadSavedEnvironmentFromPrefs() {
+ PrefService* local_state = local_state_;
+ const std::string base64_system_profile =
+ local_state->GetString(metrics::prefs::kStabilitySavedSystemProfile);
+ if (base64_system_profile.empty())
+ return false;
+
+ const std::string system_profile_hash =
+ 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;
+ return base::Base64Decode(base64_system_profile, &serialied_system_profile) &&
+ ComputeSHA1(serialied_system_profile) == system_profile_hash &&
+ system_profile->ParseFromString(serialied_system_profile);
+}
+
diff --git a/components/metrics/metrics_log.h b/components/metrics/metrics_log.h
new file mode 100644
index 0000000..03b280d
--- /dev/null
+++ b/components/metrics/metrics_log.h
@@ -0,0 +1,141 @@
+// 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 COMPONENTS_METRICS_METRICS_LOG_H_
+#define COMPONENTS_METRICS_METRICS_LOG_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "components/metrics/metrics_log_base.h"
+
+class PrefRegistrySimple;
+class PrefService;
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace content {
+struct WebPluginInfo;
+}
+
+namespace metrics {
+class MetricsProvider;
+class MetricsServiceClient;
+}
+
+namespace tracked_objects {
+struct ProcessDataSnapshot;
+}
+
+namespace variations {
+struct ActiveGroupId;
+}
+
+class MetricsLog : public metrics::MetricsLogBase {
+ public:
+ // Creates a new metrics log of the specified type.
+ // |client_id| is the identifier for this profile on this installation
+ // |session_id| is an integer that's incremented on each application launch
+ // |client| is used to interact with the embedder.
+ // |local_state| is the PrefService that this instance should use.
+ // Note: |this| instance does not take ownership of the |client|, but rather
+ // stores a weak pointer to it. The caller should ensure that the |client| is
+ // valid for the lifetime of this class.
+ MetricsLog(const std::string& client_id,
+ int session_id,
+ LogType log_type,
+ metrics::MetricsServiceClient* client,
+ 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
+ // because those can't be obtained synchronously from the UI thread.
+ // A synthetic trial is one that is set up dynamically by code in Chrome. For
+ // example, a pref may be mapped to a synthetic trial such that the group
+ // is determined by the pref value.
+ void RecordEnvironment(
+ const std::vector<metrics::MetricsProvider*>& metrics_providers,
+ const std::vector<variations::ActiveGroupId>& synthetic_trials);
+
+ // Loads the environment proto that was saved by the last RecordEnvironment()
+ // call from prefs and clears the pref value. Returns true on success or false
+ // if there was no saved environment in prefs or it could not be decoded.
+ bool LoadSavedEnvironmentFromPrefs();
+
+ // Writes application stability metrics, including stability metrics provided
+ // by the specified set of |metrics_providers|. The system profile portion of
+ // the log must have already been filled in by a call to RecordEnvironment()
+ // or LoadSavedEnvironmentFromPrefs().
+ // NOTE: Has the side-effect of clearing the stability prefs..
+ //
+ // If this log is of type INITIAL_STABILITY_LOG, records additional info such
+ // as number of incomplete shutdowns as well as extra breakpad and debugger
+ // stats.
+ void RecordStabilityMetrics(
+ const std::vector<metrics::MetricsProvider*>& metrics_providers,
+ base::TimeDelta incremental_uptime,
+ base::TimeDelta uptime);
+
+ // Records general metrics based on the specified |metrics_providers|.
+ void RecordGeneralMetrics(
+ const std::vector<metrics::MetricsProvider*>& metrics_providers);
+
+ const base::TimeTicks& creation_time() const {
+ return creation_time_;
+ }
+
+ protected:
+ // Exposed for the sake of mocking in test code.
+
+ // Fills |field_trial_ids| with the list of initialized field trials name and
+ // group ids.
+ virtual void GetFieldTrialIds(
+ std::vector<variations::ActiveGroupId>* field_trial_ids) const;
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData);
+
+ // Returns true if the environment has already been filled in by a call to
+ // RecordEnvironment() or LoadSavedEnvironmentFromPrefs().
+ bool HasEnvironment() const;
+
+ // Returns true if the stability metrics have already been filled in by a
+ // call to RecordStabilityMetrics().
+ bool HasStabilityMetrics() const;
+
+ // Within the stability group, write required attributes.
+ void WriteRequiredStabilityAttributes(PrefService* pref);
+
+ // Within the stability group, write attributes that need to be updated asap
+ // and can't be delayed until the user decides to restart chromium.
+ // Delaying these stats would bias metrics away from happy long lived
+ // chromium processes (ones that don't crash, and keep on running).
+ void WriteRealtimeStabilityAttributes(PrefService* pref,
+ base::TimeDelta incremental_uptime,
+ base::TimeDelta uptime);
+
+ // Used to interact with the embedder. Weak pointer; must outlive |this|
+ // instance.
+ metrics::MetricsServiceClient* const client_;
+
+ // The time when the current log was created.
+ const base::TimeTicks creation_time_;
+
+ PrefService* local_state_;
+
+ DISALLOW_COPY_AND_ASSIGN(MetricsLog);
+};
+
+#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