Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Unified Diff: components/metrics/metrics_service.cc

Issue 580093004: Reset some UMA stability stats on a version change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/metrics/metrics_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/metrics_service.cc
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc
index 371eac6ea33ef55a2bdff965d5078a4a1c70ca1e..25240a2b95a66793627c2f3851e0fc5a5c2d3b17 100644
--- a/components/metrics/metrics_service.cc
+++ b/components/metrics/metrics_service.cc
@@ -558,10 +558,15 @@ void MetricsService::RecordBreakpadHasDebugger(bool has_debugger) {
// Initialization methods
void MetricsService::InitializeMetricsState() {
- local_state_->SetString(metrics::prefs::kStabilityStatsVersion,
- client_->GetVersionString());
- local_state_->SetInt64(metrics::prefs::kStabilityStatsBuildTime,
- MetricsLog::GetBuildTime());
+ const int64 buildtime = MetricsLog::GetBuildTime();
+ const std::string version = client_->GetVersionString();
+ bool version_changed = false;
+ if (local_state_->GetInt64(prefs::kStabilityStatsBuildTime) != buildtime ||
+ local_state_->GetString(prefs::kStabilityStatsVersion) != version) {
+ local_state_->SetString(metrics::prefs::kStabilityStatsVersion, version);
+ local_state_->SetInt64(metrics::prefs::kStabilityStatsBuildTime, buildtime);
+ version_changed = true;
+ }
log_manager_.LoadPersistedUnsentLogs();
@@ -589,6 +594,25 @@ void MetricsService::InitializeMetricsState() {
PrepareInitialStabilityLog();
}
+ // If no initial stability log was generated and there was a version upgrade,
+ // clear the stability stats from the previous version (so that they don't get
+ // attributed to the current version). This could otherwise happen due to a
+ // number of different edge cases, such as if the last version crashed before
+ // it could save off a system profile or if UMA reporting is disabled (which
+ // normally results in stats being accumulated).
+ if (!has_initial_stability_log_ && version_changed) {
+ for (size_t i = 0; i < metrics_providers_.size(); ++i)
+ metrics_providers_[i]->ClearSavedStabilityMetrics();
+
+ // Reset the prefs that are managed by MetricsService/MetricsLog directly.
+ local_state_->SetInteger(prefs::kStabilityCrashCount, 0);
+ local_state_->SetInteger(prefs::kStabilityExecutionPhase,
+ UNINITIALIZED_PHASE);
+ local_state_->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
+ local_state_->SetInteger(prefs::kStabilityLaunchCount, 0);
+ local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true);
+ }
+
// Update session ID.
++session_id_;
local_state_->SetInteger(metrics::prefs::kMetricsSessionID, session_id_);
« no previous file with comments | « components/metrics/metrics_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698