diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/metrics/metrics_log.cc | 3 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_log.h | 6 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 37 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.h | 8 |
4 files changed, 49 insertions, 5 deletions
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 27cb88e..a504b11 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -280,7 +280,8 @@ void MetricsLog::EndElement() { DCHECK_GE(result, 0); } -std::string MetricsLog::GetVersionString() const { +// static +std::string MetricsLog::GetVersionString() { scoped_ptr<FileVersionInfo> version_info( FileVersionInfo::CreateFileVersionInfoForCurrentModule()); if (version_info.get()) { diff --git a/chrome/browser/metrics/metrics_log.h b/chrome/browser/metrics/metrics_log.h index 63ac23d..0f63538 100644 --- a/chrome/browser/metrics/metrics_log.h +++ b/chrome/browser/metrics/metrics_log.h @@ -103,6 +103,9 @@ class MetricsLog { // Return a base64-encoded MD5 hash of the given string. static std::string CreateBase64Hash(const std::string& string); + // Get the current version of the application as a string. + static std::string GetVersionString(); + protected: // Returns a string containing the current time. // Virtual so that it can be overridden for testing. @@ -146,9 +149,6 @@ class MetricsLog { // Write the attributes that are common to every metrics event type. void WriteCommonEventAttributes(); - // Get the current version of the application as a string. - std::string GetVersionString() const; - // Returns the date at which the current metrics client ID was created as // a string containing milliseconds since the epoch, or "0" if none was found. std::string GetInstallDate() const; diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 2906ef3..4d34ebb 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -306,6 +306,7 @@ void MetricsService::RegisterPrefs(PrefService* local_state) { local_state->RegisterStringPref(prefs::kStabilityLaunchTimeSec, L"0"); local_state->RegisterStringPref(prefs::kStabilityLastTimestampSec, L"0"); local_state->RegisterStringPref(prefs::kStabilityUptimeSec, L"0"); + local_state->RegisterStringPref(prefs::kStabilityStatsVersion, L""); local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); local_state->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true); local_state->RegisterIntegerPref(prefs::kMetricsSessionID, -1); @@ -336,6 +337,31 @@ void MetricsService::RegisterPrefs(PrefService* local_state) { local_state->RegisterListPref(prefs::kMetricsOngoingLogs); } +// static +void MetricsService::DiscardOldStabilityStats(PrefService* local_state) { + local_state->SetBoolean(prefs::kStabilityExitedCleanly, true); + + local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); + local_state->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); + local_state->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); + local_state->SetInteger(prefs::kStabilityDebuggerPresent, 0); + local_state->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); + + local_state->SetInteger(prefs::kStabilityLaunchCount, 0); + local_state->SetInteger(prefs::kStabilityCrashCount, 0); + + local_state->SetInteger(prefs::kStabilityPageLoadCount, 0); + local_state->SetInteger(prefs::kStabilityRendererCrashCount, 0); + local_state->SetInteger(prefs::kStabilityRendererHangCount, 0); + + local_state->SetInteger(prefs::kSecurityRendererOnSboxDesktop, 0); + local_state->SetInteger(prefs::kSecurityRendererOnDefaultDesktop, 0); + + local_state->SetString(prefs::kStabilityUptimeSec, L"0"); + + local_state->ClearPref(prefs::kStabilityPluginStats); +} + MetricsService::MetricsService() : recording_active_(false), reporting_active_(false), @@ -550,6 +576,15 @@ void MetricsService::InitializeMetricsState() { PrefService* pref = g_browser_process->local_state(); DCHECK(pref); + if (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())); + } + client_id_ = WideToUTF8(pref->GetString(prefs::kMetricsClientID)); if (client_id_.empty()) { client_id_ = GenerateClientID(); @@ -779,7 +814,7 @@ void MetricsService::PushPendingLogsToUnsentLists() { state_ = SEND_OLD_INITIAL_LOGS; } else { // TODO(jar): Verify correctness in other states, including sending unsent - // iniitial logs. + // initial logs. PushPendingLogTextToUnsentOngoingLogs(); } DiscardPendingLog(); diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h index d42d953..630d2de 100644 --- a/chrome/browser/metrics/metrics_service.h +++ b/chrome/browser/metrics/metrics_service.h @@ -122,6 +122,14 @@ class MetricsService : public NotificationObserver, class GetPluginListTask; class GetPluginListTaskComplete; + // When we start a new version of Chromium (different from our last run), we + // need to discard the old crash stats so that we don't attribute crashes etc. + // in the old version to the current version (via current logs). + // Without this, a common reason to finally start a new version is to crash + // the old version (after an autoupdate has arrived), and so we'd bias + // initial results towards showing crashes :-(. + static void DiscardOldStabilityStats(PrefService* local_state); + // Sets and gets whether metrics recording is active. // SetRecording(false) also forces a persistent save of logging state (if // anything has been recorded, or transmitted). |