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

Unified Diff: chrome/browser/sessions/session_restore.cc

Issue 1803143002: Replace BrowserProces::AddRefModule/RemoveModule by ScopedKeepAlive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 9 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/lifetime/keep_alive_types.cc ('k') | chrome/browser/sessions/session_restore_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_restore.cc
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index cd897b1857ec5719960961aa1dcd9d9d6c00f34b..ada8811e02d6cc5fd5acc838a2fbaeee5945bf9b 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -27,6 +27,8 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/lifetime/keep_alive_types.h"
+#include "chrome/browser/lifetime/scoped_keep_alive.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/sessions/session_restore_delegate.h"
@@ -114,10 +116,8 @@ class SessionRestoreImpl : public content::NotificationObserver {
active_session_restorers->insert(this);
- // When asynchronous its possible for there to be no windows. To make sure
- // Chrome doesn't prematurely exit AddRef the process. We'll release in the
- // destructor when restore is done.
- g_browser_process->AddRefModule();
+ keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::SESSION_RESTORE,
+ KeepAliveRestartOption::DISABLED));
}
bool synchronous() const { return synchronous_; }
@@ -249,8 +249,6 @@ class SessionRestoreImpl : public content::NotificationObserver {
delete active_session_restorers;
active_session_restorers = nullptr;
}
-
- g_browser_process->ReleaseModule();
}
void Observe(int type,
@@ -718,6 +716,11 @@ class SessionRestoreImpl : public content::NotificationObserver {
content::NotificationRegistrar registrar_;
+ // When asynchronous it's possible for there to be no windows. To make sure
+ // Chrome doesn't prematurely exit we register a KeepAlive for the lifetime
+ // of this object.
+ scoped_ptr<ScopedKeepAlive> keep_alive_;
+
// The time we started the restore.
base::TimeTicks restore_started_;
« no previous file with comments | « chrome/browser/lifetime/keep_alive_types.cc ('k') | chrome/browser/sessions/session_restore_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698