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

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: 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
Index: components/metrics/metrics_service.cc
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc
index 371eac6ea33ef55a2bdff965d5078a4a1c70ca1e..94d3d5376adee657d1ab6ad646f1db11f15f5dd1 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,21 @@ void MetricsService::InitializeMetricsState() {
PrepareInitialStabilityLog();
}
+ // If no initial stability log was generated and there was a version upgrade,
+ // reset stability stats from the previous version.
Ilya Sherman 2014/09/18 18:30:20 nit: I'd go into a bit more detail here on why thi
Alexei Svitkine (slow) 2014/09/18 20:21:14 Done.
+ 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_);
« components/metrics/metrics_provider.h ('K') | « components/metrics/metrics_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698