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

Unified Diff: chrome/browser/browser_shutdown.cc

Issue 1931503002: Add BackgroundModeOptimizer that can restart the browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@PushKeepAlive
Patch Set: fix BrowserListTest.AttemptRestart Created 4 years, 5 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
Index: chrome/browser/browser_shutdown.cc
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index ab8f9d7561797948661f840a633e867733a84666..d20e541135cdc9c59ed1868048e46f5fea280ea0 100644
--- a/chrome/browser/browser_shutdown.cc
+++ b/chrome/browser/browser_shutdown.cc
@@ -47,6 +47,10 @@
#include "chrome/browser/first_run/upgrade_util.h"
#endif
+#if BUILDFLAG(ENABLE_BACKGROUND)
+#include "chrome/browser/background/background_mode_manager.h"
+#endif
+
#if defined(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h"
#endif
@@ -194,7 +198,7 @@ bool ShutdownPreThreadsStop() {
return restart_last_session;
}
-void ShutdownPostThreadsStop(bool restart_last_session) {
+void ShutdownPostThreadsStop(int shutdown_flags) {
delete g_browser_process;
g_browser_process = NULL;
@@ -214,7 +218,7 @@ void ShutdownPostThreadsStop(bool restart_last_session) {
}
#endif
- if (restart_last_session) {
+ if (shutdown_flags & RESTART_LAST_SESSION) {
#if !defined(OS_CHROMEOS)
// Make sure to relaunch the browser with the original command line plus
// the Restore Last Session flag. Note that Chrome can be launched (ie.
@@ -239,6 +243,8 @@ void ShutdownPostThreadsStop(bool restart_last_session) {
else
new_cl->AppendSwitch(it.first);
}
+ if (shutdown_flags & RESTART_IN_BACKGROUND)
+ new_cl->AppendSwitch(switches::kNoStartupWindow);
#if defined(OS_POSIX) || defined(OS_WIN)
upgrade_util::RelaunchChromeBrowser(*new_cl.get());
@@ -329,6 +335,22 @@ void ReadLastShutdownInfo() {
void SetTryingToQuit(bool quitting) {
g_trying_to_quit = quitting;
+
+ if (quitting)
+ return;
+
+ // Reset the restart-related preferences.
sky 2016/07/22 16:57:52 This just documents what the code is doing. Instea
dgn 2016/07/25 17:32:28 Done.
+ PrefService* pref_service = g_browser_process->local_state();
+ if (pref_service) {
+#if !defined(OS_ANDROID)
+ pref_service->ClearPref(prefs::kWasRestarted);
+#endif // !defined(OS_ANDROID)
+ pref_service->ClearPref(prefs::kRestartLastSessionOnShutdown);
+ }
+
+#if BUILDFLAG(ENABLE_BACKGROUND)
+ BackgroundModeManager::should_restart_in_background(false);
+#endif // BUILDFLAG(ENABLE_BACKGROUND)
}
bool IsTryingToQuit() {

Powered by Google App Engine
This is Rietveld 408576698