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

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: address comments. disable feature by default 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
« no previous file with comments | « chrome/browser/browser_shutdown.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_shutdown.cc
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index ab8f9d7561797948661f840a633e867733a84666..c49479297643f4d0130cc046a7d6647862043701 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,24 @@ void ReadLastShutdownInfo() {
void SetTryingToQuit(bool quitting) {
g_trying_to_quit = quitting;
+
+ if (quitting)
+ return;
+
+ // Reset the restart-related preferences. They get set unconditionally through
+ // calls such as chrome::AttemptRestart(), and need to be reset if the restart
+ // attempt is cancelled.
+ 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::set_should_restart_in_background(false);
+#endif // BUILDFLAG(ENABLE_BACKGROUND)
}
bool IsTryingToQuit() {
« no previous file with comments | « chrome/browser/browser_shutdown.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698