Commit dc347b79 authored by hashimoto's avatar hashimoto Committed by Commit bot

Record shutdown type UMA

To investigate how frequently unclean shutdown is performed.

Start recording a new UMA Shutdown.ShutdownType.
Update prefs::kShutdownType when Chrome is performing unclean shutdown with SessionEnding().

BUG=644649

Review-Url: https://codereview.chromium.org/2318373003
Cr-Commit-Position: refs/heads/master@{#419123}
parent fd83e754
......@@ -170,6 +170,21 @@ bool ShutdownPreThreadsStop() {
if (metrics)
metrics->RecordCompletedSessionEnd();
bool restart_last_session = RecordShutdownInfoPrefs();
prefs->CommitPendingWrite();
#if defined(ENABLE_RLZ)
// Cleanup any statics created by RLZ. Must be done before NotificationService
// is destroyed.
rlz::RLZTracker::CleanupRlz();
#endif
return restart_last_session;
}
bool RecordShutdownInfoPrefs() {
PrefService* prefs = g_browser_process->local_state();
if (g_shutdown_type > NOT_VALID && g_shutdown_num_processes > 0) {
// Record the shutdown info so that we can put it into a histogram at next
// startup.
......@@ -179,22 +194,13 @@ bool ShutdownPreThreadsStop() {
g_shutdown_num_processes_slow);
}
// Check local state for the restart flag so we can restart the session below.
// Check local state for the restart flag so we can restart the session later.
bool restart_last_session = false;
if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) {
restart_last_session =
prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown);
prefs->ClearPref(prefs::kRestartLastSessionOnShutdown);
}
prefs->CommitPendingWrite();
#if defined(ENABLE_RLZ)
// Cleanup any statics created by RLZ. Must be done before NotificationService
// is destroyed.
rlz::RLZTracker::CleanupRlz();
#endif
return restart_last_session;
}
......@@ -327,6 +333,8 @@ void ReadLastShutdownInfo() {
prefs->SetInteger(prefs::kShutdownNumProcesses, 0);
prefs->SetInteger(prefs::kShutdownNumProcessesSlow, 0);
UMA_HISTOGRAM_ENUMERATION("Shutdown.ShutdownType", type, kNumShutdownTypes);
// Read and delete the file on the file thread.
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
......
......@@ -36,6 +36,8 @@ enum ShutdownType {
END_SESSION
};
constexpr int kNumShutdownTypes = END_SESSION + 1;
void RegisterPrefs(PrefRegistrySimple* registry);
// Called when the browser starts shutting down so that we can measure shutdown
......@@ -52,6 +54,10 @@ ShutdownType GetShutdownType();
// Returns true if the session should be restarted.
bool ShutdownPreThreadsStop();
// Records the shutdown related prefs, and returns true if the browser should be
// restarted on exit.
bool RecordShutdownInfoPrefs();
// Performs the remaining shutdown tasks after all threads but the
// main thread have been stopped. This includes deleting g_browser_process.
//
......
......@@ -307,6 +307,13 @@ void SessionEnding() {
browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION);
// In a clean shutdown, browser_shutdown::OnShutdownStarting sets
// g_shutdown_type, and browser_shutdown::ShutdownPreThreadsStop calls
// RecordShutdownInfoPrefs to update the pref with the value. However, here
// the process is going to exit without calling ShutdownPreThreadsStop.
// Instead, here we call RecordShutdownInfoPrefs to record the shutdown info.
browser_shutdown::RecordShutdownInfoPrefs();
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST,
content::NotificationService::AllSources(),
......
......@@ -55863,6 +55863,11 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="Shutdown.ShutdownType" enum="ShutdownType">
<owner>hashimoto@chromium.org</owner>
<summary>The type of the last shutdown.</summary>
</histogram>
<histogram name="Signin" enum="SigninHelperFlow">
<owner>mlerman@chromium.org</owner>
<summary>
......@@ -94936,6 +94941,13 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="6" label="Dark resume failed"/>
</enum>
<enum name="ShutdownType" type="int">
<int value="0" label="Not valid">Invalid value.</int>
<int value="1" label="Window close">The last browser window was closed.</int>
<int value="2" label="Browser exit">User clicked on the Exit menu item.</int>
<int value="3" label="End session">OS is logging off or shutting down.</int>
</enum>
<enum name="SideloadUIEvents" type="int">
<int value="0" label="Extension installed"/>
<int value="1" label="Extension ignored"/>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment