Index: components/metrics/metrics_service.cc |
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc |
index cf71f1460f4ec6272c701b7ee8a888f9dc1daf20..152865cb396c2e372d1a9085b1e182664f80622a 100644 |
--- a/components/metrics/metrics_service.cc |
+++ b/components/metrics/metrics_service.cc |
@@ -254,8 +254,9 @@ ResponseStatus ResponseCodeToStatus(int response_code) { |
} |
} |
-void MarkAppCleanShutdownAndCommit(PrefService* local_state) { |
- local_state->SetBoolean(metrics::prefs::kStabilityExitedCleanly, true); |
+void MarkAppCleanShutdownAndCommit(CleanExitBeacon* clean_exit_beacon, |
+ PrefService* local_state) { |
+ clean_exit_beacon->WriteBeaconValue(true); |
local_state->SetInteger(metrics::prefs::kStabilityExecutionPhase, |
MetricsService::SHUTDOWN_COMPLETE); |
// Start writing right away (write happens on a different thread). |
@@ -285,6 +286,7 @@ void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { |
DCHECK(IsSingleThreaded()); |
metrics::MetricsStateManager::RegisterPrefs(registry); |
MetricsLog::RegisterPrefs(registry); |
+ CleanExitBeacon::RegisterPrefs(registry); |
registry->RegisterInt64Pref(metrics::prefs::kInstallDate, 0); |
@@ -293,7 +295,6 @@ void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { |
registry->RegisterStringPref(metrics::prefs::kStabilityStatsVersion, |
std::string()); |
registry->RegisterInt64Pref(metrics::prefs::kStabilityStatsBuildTime, 0); |
- registry->RegisterBooleanPref(metrics::prefs::kStabilityExitedCleanly, true); |
registry->RegisterIntegerPref(metrics::prefs::kStabilityExecutionPhase, |
UNINITIALIZED_PHASE); |
registry->RegisterBooleanPref(metrics::prefs::kStabilitySessionEndCompleted, |
@@ -315,6 +316,11 @@ MetricsService::MetricsService(metrics::MetricsStateManager* state_manager, |
state_manager_(state_manager), |
client_(client), |
local_state_(local_state), |
+#if defined(OS_WIN) |
+ clean_exit_beacon_(client->GetRegistryBackupKey(), local_state), |
+#else |
+ clean_exit_beacon_(local_state), |
+#endif |
recording_active_(false), |
reporting_active_(false), |
test_mode_active_(false), |
@@ -498,7 +504,7 @@ void MetricsService::RecordCompletedSessionEnd() { |
void MetricsService::OnAppEnterBackground() { |
scheduler_->Stop(); |
- MarkAppCleanShutdownAndCommit(local_state_); |
+ MarkAppCleanShutdownAndCommit(&clean_exit_beacon_, local_state_); |
// At this point, there's no way of knowing when the process will be |
// killed, so this has to be treated similar to a shutdown, closing and |
@@ -514,12 +520,12 @@ void MetricsService::OnAppEnterBackground() { |
} |
void MetricsService::OnAppEnterForeground() { |
- local_state_->SetBoolean(metrics::prefs::kStabilityExitedCleanly, false); |
+ clean_exit_beacon_->WriteBeaconValue(false); |
Alexei Svitkine (slow)
2014/09/11 15:23:28
Shouldn't this be . instead of ->?
erikwright (departed)
2014/09/11 19:00:29
Done.
|
StartSchedulerIfNecessary(); |
} |
#else |
void MetricsService::LogNeedForCleanShutdown() { |
- local_state_->SetBoolean(metrics::prefs::kStabilityExitedCleanly, false); |
+ clean_exit_beacon_.WriteBeaconValue(false); |
// Redundant setting to be sure we call for a clean shutdown. |
clean_shutdown_status_ = NEED_TO_SHUTDOWN; |
} |
@@ -565,11 +571,11 @@ void MetricsService::InitializeMetricsState() { |
session_id_ = local_state_->GetInteger(metrics::prefs::kMetricsSessionID); |
- if (!local_state_->GetBoolean(metrics::prefs::kStabilityExitedCleanly)) { |
+ if (!clean_exit_beacon_.exited_cleanly()) { |
Alexei Svitkine (slow)
2014/09/11 15:23:28
Note: You need to sync/rebase on top of siggi's ch
erikwright (departed)
2014/09/11 19:00:29
Done.
|
IncrementPrefValue(metrics::prefs::kStabilityCrashCount); |
// Reset flag, and wait until we call LogNeedForCleanShutdown() before |
// monitoring. |
- local_state_->SetBoolean(metrics::prefs::kStabilityExitedCleanly, true); |
+ clean_exit_beacon_.WriteBeaconValue(true); |
// TODO(rtenneti): On windows, consider saving/getting execution_phase from |
// the registry. |
@@ -1153,13 +1159,14 @@ void MetricsService::RecordCurrentStabilityHistograms() { |
void MetricsService::LogCleanShutdown() { |
// Redundant hack to write pref ASAP. |
- MarkAppCleanShutdownAndCommit(local_state_); |
+ MarkAppCleanShutdownAndCommit(&clean_exit_beacon_, local_state_); |
// Redundant setting to assure that we always reset this value at shutdown |
// (and that we don't use some alternate path, and not call LogCleanShutdown). |
clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
- RecordBooleanPrefValue(metrics::prefs::kStabilityExitedCleanly, true); |
+ clean_exit_beacon_.WriteBeaconValue(true); |
+ RecordCurrentState(local_state_); |
local_state_->SetInteger(metrics::prefs::kStabilityExecutionPhase, |
MetricsService::SHUTDOWN_COMPLETE); |
} |