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

Unified Diff: chrome/browser/lifetime/keep_alive_registry.h

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/application_lifetime.cc ('k') | chrome/browser/lifetime/keep_alive_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/lifetime/keep_alive_registry.h
diff --git a/chrome/browser/lifetime/keep_alive_registry.h b/chrome/browser/lifetime/keep_alive_registry.h
index cd0d4128b71adb002eaae3d026523131524b328e..5bb6cbe4c7f1c39495b6cbd3f84f359b516bcb24 100644
--- a/chrome/browser/lifetime/keep_alive_registry.h
+++ b/chrome/browser/lifetime/keep_alive_registry.h
@@ -15,16 +15,23 @@ enum class KeepAliveOrigin;
enum class KeepAliveRestartOption;
class KeepAliveStateObserver;
+// Centralized registry that objects in the browser can use to
+// express their requirements wrt the lifetime of the browser.
+// Observers registered with it can then react as those requirements
+// change.
+// In particular, this is how the browser process knows when to stop
+// or stay alive.
+// Note: BrowserProcessImpl registers to react on changes.
+// TestingBrowserProcess does not do it, meaning that the shutdown
+// sequence does not happen during unit tests.
class KeepAliveRegistry {
public:
static KeepAliveRegistry* GetInstance();
// Methods to query the state of the registry.
- // TODO(dgn): This currently does not give a complete picture. It has no
- // information about the many places that rely on AddRefModule to keep the
- // browser alive. Tracked by https://crbug.com/587926
bool IsKeepingAlive() const;
bool IsRestartAllowed() const;
+ bool IsOriginRegistered(KeepAliveOrigin origin) const;
void AddObserver(KeepAliveStateObserver* observer);
void RemoveObserver(KeepAliveStateObserver* observer);
@@ -44,7 +51,7 @@ class KeepAliveRegistry {
void Unregister(KeepAliveOrigin origin, KeepAliveRestartOption restart);
// Methods called when a specific aspect of the state of the registry changes.
- void OnKeepingAliveChanged(bool new_keeping_alive);
+ void OnKeepAliveStateChanged(bool new_keeping_alive);
void OnRestartAllowedChanged(bool new_restart_allowed);
// Tracks the registered KeepAlives, storing the origin and the number of
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.cc ('k') | chrome/browser/lifetime/keep_alive_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698