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

Unified Diff: components/metrics/metrics_service.cc

Issue 558653002: Allow MetricsProviders to request an initial stability log. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
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
« no previous file with comments | « components/metrics/metrics_service.h ('k') | components/metrics/metrics_service_unittest.cc » ('j') | 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 3c499c14e671415bfd2414e05389a73f4720fd9d..f2fd2e31e4d5bd57bbcd5005e2e24255b38922d2 100644
--- a/components/metrics/metrics_service.cc
+++ b/components/metrics/metrics_service.cc
@@ -566,11 +566,14 @@ void MetricsService::InitializeMetricsState() {
session_id_ = local_state_->GetInteger(metrics::prefs::kMetricsSessionID);
- if (!local_state_->GetBoolean(metrics::prefs::kStabilityExitedCleanly)) {
- IncrementPrefValue(metrics::prefs::kStabilityCrashCount);
- // Reset flag, and wait until we call LogNeedForCleanShutdown() before
- // monitoring.
- local_state_->SetBoolean(metrics::prefs::kStabilityExitedCleanly, true);
+ if (ShouldPrepareStabilityLog()) {
+ if (!local_state_->GetBoolean(metrics::prefs::kStabilityExitedCleanly)) {
Alexei Svitkine (slow) 2014/09/09 15:34:28 It's kind of confusing to have the check for this
Sigurður Ásgeirsson 2014/09/09 17:13:40 Yups, that's much clearer.
+ IncrementPrefValue(metrics::prefs::kStabilityCrashCount);
+
+ // Reset flag, and wait until we call LogNeedForCleanShutdown() before
+ // monitoring.
+ local_state_->SetBoolean(metrics::prefs::kStabilityExitedCleanly, true);
+ }
// TODO(rtenneti): On windows, consider saving/getting execution_phase from
// the registry.
@@ -909,9 +912,22 @@ void MetricsService::StageNewLog() {
DCHECK(log_manager_.has_staged_log());
}
+bool MetricsService::ShouldPrepareStabilityLog() {
+ // Prepare a stability log if we had a crash in the previous session.
+ if (!local_state_->GetBoolean(metrics::prefs::kStabilityExitedCleanly))
+ return true;
+
+ // Or if any of the registered providers request it.
+ for (size_t i = 0; i < metrics_providers_.size(); ++i) {
+ if (metrics_providers_[i]->HasStabilityMetrics())
+ return true;
+ }
+
+ return false;
+}
+
void MetricsService::PrepareInitialStabilityLog() {
DCHECK_EQ(INITIALIZED, state_);
- DCHECK_NE(0, local_state_->GetInteger(metrics::prefs::kStabilityCrashCount));
scoped_ptr<MetricsLog> initial_stability_log(
CreateLog(MetricsLog::INITIAL_STABILITY_LOG));
« no previous file with comments | « components/metrics/metrics_service.h ('k') | components/metrics/metrics_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698