namespace chrome {
namespace {
+#if !defined(OS_ANDROID)
// Returns true if all browsers can be closed without user interaction.
// This currently checks if there is pending download, or if it needs to
// handle unload handler.
}
return true;
}
+#endif // !defined(OS_ANDROID)
int g_keep_alive_count = 0;
#if defined(OS_CHROMEOS)
-// Whether a session manager requested to shutdown.
-bool g_session_manager_requested_shutdown = true;
+// Whether chrome should send stop request to a session manager.
+bool g_send_stop_request_to_session_manager = false;
#endif
} // namespace
// If there are no browsers and closing the last browser would quit the
// application, send the APP_TERMINATING action here. Otherwise, it will be
// sent by RemoveBrowser() when the last browser has closed.
- if (browser_shutdown::ShuttingDownWithoutClosingBrowsers() ||
- (chrome::GetTotalBrowserCount() == 0 &&
- (browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive() ||
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableBatchedShutdown)))) {
+ if (chrome::GetTotalBrowserCount() == 0 &&
+ (browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive())) {
// Tell everyone that we are shutting down.
browser_shutdown::SetTryingToQuit(true);
state->CommitPendingWrite();
}
}
- g_session_manager_requested_shutdown = false;
+ g_send_stop_request_to_session_manager = true;
// On ChromeOS, always terminate the browser, regardless of the result of
// AreAllBrowsersCloseable(). See crbug.com/123107.
chrome::NotifyAndTerminate(true);
command_line.GetSwitchValueASCII(switches::kTraceShutdown));
base::debug::TraceLog::GetInstance()->SetEnabled(
category_filter,
+ base::debug::TraceLog::RECORDING_MODE,
base::debug::TraceLog::RECORD_UNTIL_FULL);
}
TRACE_EVENT0("shutdown", "StartShutdownTracing");
pref_service->SetBoolean(prefs::kWasRestarted, true);
#if defined(OS_CHROMEOS)
- // For CrOS instead of browser restart (which is not supported) perform a full
- // sign out. Session will be only restored if user has that setting set.
- // Same session restore behavior happens in case of full restart after update.
- AttemptUserExit();
+ chromeos::BootTimesLoader::Get()->set_restart_requested();
+
+ DCHECK(!g_send_stop_request_to_session_manager);
+ // Make sure we don't send stop request to the session manager.
+ g_send_stop_request_to_session_manager = false;
+ // Run exit process in clean stack.
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&ExitCleanly));
#else
// Set the flag to restore state after the restart.
pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true);
#endif
void AttemptExit() {
+#if defined(OS_CHROMEOS)
+ // On ChromeOS, user exit and system exits are the same.
+ AttemptUserExit();
+#else
// If we know that all browsers can be closed without blocking,
// don't notify users of crashes beyond this point.
// Note that MarkAsCleanShutdown() does not set UMA's exit cleanly bit
MarkAsCleanShutdown();
#endif
AttemptExitInternal(true);
+#endif
}
#if defined(OS_CHROMEOS)
// screen locker.
if (!AreAllBrowsersCloseable())
browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION);
+ else
+ browser_shutdown::OnShutdownStarting(browser_shutdown::BROWSER_EXIT);
AttemptExitInternal(true);
}
#endif
content::ImmediateShutdownAndExitProcess();
}
-void StartKeepAlive() {
+void IncrementKeepAliveCount() {
// Increment the browser process refcount as long as we're keeping the
// application alive.
if (!WillKeepAlive())
++g_keep_alive_count;
}
-void EndKeepAlive() {
+void DecrementKeepAliveCount() {
DCHECK_GT(g_keep_alive_count, 0);
--g_keep_alive_count;
if (update_engine_client->GetLastStatus().status ==
chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
update_engine_client->RebootAfterUpdate();
- } else if (!g_session_manager_requested_shutdown) {
+ } else if (g_send_stop_request_to_session_manager) {
// Don't ask SessionManager to stop session if the shutdown request comes
// from session manager.
chromeos::DBusThreadManager::Get()->GetSessionManagerClient()
->StopSession();
}
} else {
- // If running the Chrome OS build, but we're not on the device, act
- // as if we received signal from SessionManager.
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&ExitCleanly));
+ if (g_send_stop_request_to_session_manager) {
+ // If running the Chrome OS build, but we're not on the device, act
+ // as if we received signal from SessionManager.
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&ExitCleanly));
+ }
}
#endif
}
bool ShouldStartShutdown(Browser* browser) {
if (BrowserList::GetInstance(browser->host_desktop_type())->size() > 1)
return false;
-#if defined(OS_WIN) && defined(USE_AURA)
+#if defined(OS_WIN)
// On Windows 8 the desktop and ASH environments could be active
// at the same time.
// We should not start the shutdown process in the following cases:-