diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-19 21:19:13 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-19 21:19:13 +0000 |
commit | 225c5084d41efb256a2876180306d5484c7d0668 (patch) | |
tree | e412a835f2d6e860e2d3f9bae7d163adda9e559c /chrome | |
parent | c3778612df854a3cf1cadffe0c4a0b1518afa274 (diff) | |
download | chromium_src-225c5084d41efb256a2876180306d5484c7d0668.zip chromium_src-225c5084d41efb256a2876180306d5484c7d0668.tar.gz chromium_src-225c5084d41efb256a2876180306d5484c7d0668.tar.bz2 |
Use buildtime to ensure stability stats
r=huanr
Review URL: http://codereview.chromium.org/548058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36549 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/metrics/metrics_log.cc | 23 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_log.h | 6 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 9 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 5 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
5 files changed, 32 insertions, 12 deletions
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 4786923..4ce5273 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -38,8 +38,6 @@ inline const unsigned char* UnsignedChar(const char* input) { return reinterpret_cast<const unsigned char*>(input); } -static int64 GetBuildTime(); - // static void MetricsLog::RegisterPrefs(PrefService* local_state) { local_state->RegisterListPref(prefs::kStabilityPluginStats); @@ -316,6 +314,19 @@ std::string MetricsLog::GetVersionString() { return std::string(); } +// static +int64 MetricsLog::GetBuildTime() { + static int64 integral_build_time = 0; + if (!integral_build_time) { + Time time; + const char* kDateTime = __DATE__ " " __TIME__ " GMT"; + bool result = Time::FromString(ASCIIToWide(kDateTime).c_str(), &time); + DCHECK(result); + integral_build_time = static_cast<int64>(time.ToTimeT()); + } + return integral_build_time; +} + std::string MetricsLog::GetInstallDate() const { PrefService* pref = g_browser_process->local_state(); if (pref) { @@ -713,11 +724,3 @@ void MetricsLog::RecordHistogramDelta(const Histogram& histogram, } } } - -static int64 GetBuildTime() { - Time parsed_time; - const char* kDateTime = __DATE__ " " __TIME__ " GMT"; - bool result = Time::FromString(ASCIIToWide(kDateTime).c_str(), &parsed_time); - DCHECK(result); - return static_cast<int64>(parsed_time.ToTimeT()); -} diff --git a/chrome/browser/metrics/metrics_log.h b/chrome/browser/metrics/metrics_log.h index c8e7691..c1d5ff2 100644 --- a/chrome/browser/metrics/metrics_log.h +++ b/chrome/browser/metrics/metrics_log.h @@ -106,6 +106,12 @@ class MetricsLog { // Get the current version of the application as a string. static std::string GetVersionString(); + // Get the GMT buildtime for the current binary, expressed in seconds since + // Januray 1, 1970 GMT. + // The value is used to identify when a new build is run, so that previous + // reliability stats, from other builds, can be abandoned. + static int64 GetBuildTime(); + // Use |extension| in all uploaded appversions in addition to the standard // version string. static void set_version_extension(const std::string& extension) { diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 610792c..54cc138 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -322,6 +322,7 @@ void MetricsService::RegisterPrefs(PrefService* local_state) { local_state->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); local_state->RegisterInt64Pref(prefs::kStabilityUptimeSec, 0); local_state->RegisterStringPref(prefs::kStabilityStatsVersion, L""); + local_state->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0); local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); local_state->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); local_state->RegisterIntegerPref(prefs::kMetricsSessionID, -1); @@ -664,13 +665,17 @@ void MetricsService::InitializeMetricsState() { PrefService* pref = g_browser_process->local_state(); DCHECK(pref); - if (WideToUTF8(pref->GetString(prefs::kStabilityStatsVersion)) != - MetricsLog::GetVersionString()) { + if ((pref->GetInt64(prefs::kStabilityStatsBuildTime) + != MetricsLog::GetBuildTime()) || + (WideToUTF8(pref->GetString(prefs::kStabilityStatsVersion)) + != MetricsLog::GetVersionString())) { // This is a new version, so we don't want to confuse the stats about the // old version with info that we upload. DiscardOldStabilityStats(pref); pref->SetString(prefs::kStabilityStatsVersion, UTF8ToWide(MetricsLog::GetVersionString())); + pref->SetInt64(prefs::kStabilityStatsBuildTime, + MetricsLog::GetBuildTime()); } // Update session ID diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 31228ba..84f9267 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -353,6 +353,11 @@ const wchar_t kStabilityExitedCleanly[] = const wchar_t kStabilityStatsVersion[] = L"user_experience_metrics.stability.stats_version"; +// Build time, in seconds since an epoch, which is used to assure that stability +// metrics reported reflect stability of the same build. +extern const wchar_t kStabilityStatsBuildTime[] = + L"user_experience_metrics.stability.stats_buildtime"; + // False if we received a session end and either we crashed during processing // the session end or ran out of time and windows terminated us. const wchar_t kStabilitySessionEndCompleted[] = diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 740971d..3331a0ca 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -136,6 +136,7 @@ extern const wchar_t kProfilePrefix[]; extern const wchar_t kStabilityExitedCleanly[]; extern const wchar_t kStabilityStatsVersion[]; +extern const wchar_t kStabilityStatsBuildTime[]; extern const wchar_t kStabilitySessionEndCompleted[]; extern const wchar_t kStabilityLaunchCount[]; extern const wchar_t kStabilityCrashCount[]; |