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

Unified Diff: chrome/browser/metrics/metrics_service.cc

Issue 28283002: Track execution phase of browser process when we log if the broswer has (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Record in UMA histograms the browser execution phase Created 7 years, 2 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 | « chrome/browser/metrics/metrics_service.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_service.cc
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 66f68d5aeec60f788dc8c6875e1a546719128ddd..ec31270d05cc48317220f9096aec4db83cea7ae7 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -325,6 +325,8 @@ int MapCrashExitCodeForHistogram(int exit_code) {
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();
}
@@ -335,6 +337,9 @@ void MarkAppCleanShutdownAndCommit() {
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
@@ -405,6 +410,8 @@ void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) {
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);
@@ -441,6 +448,7 @@ void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) {
// 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);
@@ -768,6 +776,7 @@ void MetricsService::OnAppEnterBackground() {
void MetricsService::OnAppEnterForeground() {
PrefService* pref = g_browser_process->local_state();
pref->SetBoolean(prefs::kStabilityExitedCleanly, false);
+ pref->SetInteger(prefs::kStabilityExecutionPhase, execution_phase_);
StartSchedulerIfNecessary();
}
@@ -775,6 +784,7 @@ void MetricsService::OnAppEnterForeground() {
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;
}
@@ -895,6 +905,12 @@ void MetricsService::InitializeMetricsState() {
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);
jar (doing other things) 2013/10/26 02:09:21 Perhaps this block from lines 908 to 912 should be
ramant (doing other things) 2013/10/26 03:29:35 Done.
+
#if defined(OS_WIN)
CountBrowserCrashDumpAttempts();
#endif // defined(OS_WIN)
@@ -1635,6 +1651,9 @@ void MetricsService::LogCleanShutdown() {
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)
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698