Track execution phase of browser process and track it as
a UMA histogram.
As a first attempt, tracked the following
- Before starting metrics service,
- Before creating profile
- Before starting startup time bomb
- Before starting thread watcher
- Before starting main message loop
- Before starting shutdown time bomb
- clean shutdown.
[email protected]
Review URL: https://codereview.chromium.org/28283002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231334 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 9c1450d6..d17779b 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -329,6 +329,8 @@
void MarkAppCleanShutdownAndCommit() {
PrefService* pref = g_browser_process->local_state();
pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
+ pref->SetInteger(prefs::kStabilityExecutionPhase,
+ MetricsService::CLEAN_SHUTDOWN);
// Start writing right away (write happens on a different thread).
pref->CommitPendingWrite();
}
@@ -339,6 +341,9 @@
MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ =
MetricsService::CLEANLY_SHUTDOWN;
+MetricsService::ExecutionPhase MetricsService::execution_phase_ =
+ MetricsService::CLEAN_SHUTDOWN;
+
// This is used to quickly log stats from child process related notifications in
// MetricsService::child_stats_buffer_. The buffer's contents are transferred
// out when Local State is periodically saved. The information is then
@@ -409,6 +414,8 @@
registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string());
registry->RegisterInt64Pref(prefs::kStabilityStatsBuildTime, 0);
registry->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true);
+ registry->RegisterIntegerPref(prefs::kStabilityExecutionPhase,
+ CLEAN_SHUTDOWN);
registry->RegisterBooleanPref(prefs::kStabilitySessionEndCompleted, true);
registry->RegisterIntegerPref(prefs::kMetricsSessionID, -1);
registry->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0);
@@ -445,6 +452,7 @@
// static
void MetricsService::DiscardOldStabilityStats(PrefService* local_state) {
local_state->SetBoolean(prefs::kStabilityExitedCleanly, true);
+ local_state->SetInteger(prefs::kStabilityExecutionPhase, CLEAN_SHUTDOWN);
local_state->SetBoolean(prefs::kStabilitySessionEndCompleted, true);
local_state->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
@@ -773,6 +781,7 @@
void MetricsService::OnAppEnterForeground() {
PrefService* pref = g_browser_process->local_state();
pref->SetBoolean(prefs::kStabilityExitedCleanly, false);
+ pref->SetInteger(prefs::kStabilityExecutionPhase, execution_phase_);
StartSchedulerIfNecessary();
}
@@ -780,6 +789,7 @@
void MetricsService::LogNeedForCleanShutdown() {
PrefService* pref = g_browser_process->local_state();
pref->SetBoolean(prefs::kStabilityExitedCleanly, false);
+ pref->SetInteger(prefs::kStabilityExecutionPhase, execution_phase_);
// Redundant setting to be sure we call for a clean shutdown.
clean_shutdown_status_ = NEED_TO_SHUTDOWN;
}
@@ -898,6 +908,13 @@
// Reset flag, and wait until we call LogNeedForCleanShutdown() before
// monitoring.
pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
+
+ // TODO(rtenneti): On windows, consider saving/getting execution_phase from
+ // the registry.
+ int execution_phase = pref->GetInteger(prefs::kStabilityExecutionPhase);
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.ExecutionPhase",
+ execution_phase);
+ pref->SetInteger(prefs::kStabilityExecutionPhase, CLEAN_SHUTDOWN);
}
#if defined(OS_WIN)
@@ -1670,6 +1687,9 @@
clean_shutdown_status_ = CLEANLY_SHUTDOWN;
RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true);
+ PrefService* pref = g_browser_process->local_state();
+ pref->SetInteger(prefs::kStabilityExecutionPhase,
+ MetricsService::CLEAN_SHUTDOWN);
}
#if defined(OS_CHROMEOS)