| 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 db47677f1f173c8610af362c2ab38f2c8d25bac0..f504fa072c790cd0eec13f6efdf8a9991812c3be 100644
|
| --- a/chrome/browser/lifetime/keep_alive_registry.h
|
| +++ b/chrome/browser/lifetime/keep_alive_registry.h
|
| @@ -9,26 +9,43 @@
|
|
|
| #include "base/macros.h"
|
| #include "base/memory/singleton.h"
|
| +#include "base/observer_list.h"
|
|
|
| enum class KeepAliveOrigin;
|
| +enum class KeepAliveRestartOption;
|
| +class KeepAliveStateObserver;
|
|
|
| class KeepAliveRegistry {
|
| public:
|
| static KeepAliveRegistry* GetInstance();
|
|
|
| - bool WillKeepAlive() const;
|
| + // 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 IncrementKeepAliveCount and
|
| + // AddRefModule to keep the browser alive. Tracked by https://crbug.com/587926
|
| + bool IsKeepingAlive() const;
|
| + bool IsRestartAllowed() const;
|
| +
|
| + void AddObserver(KeepAliveStateObserver* observer);
|
| + void RemoveObserver(KeepAliveStateObserver* observer);
|
|
|
| private:
|
| friend struct base::DefaultSingletonTraits<KeepAliveRegistry>;
|
| // Friend to be able to use Register/Unregister
|
| friend class ScopedKeepAlive;
|
| + friend std::ostream& operator<<(std::ostream& out,
|
| + const KeepAliveRegistry& registry);
|
|
|
| KeepAliveRegistry();
|
| ~KeepAliveRegistry();
|
|
|
| // Add/Remove entries. Do not use directly, use ScopedKeepAlive instead.
|
| - void Register(KeepAliveOrigin origin);
|
| - void Unregister(KeepAliveOrigin origin);
|
| + void Register(KeepAliveOrigin origin, KeepAliveRestartOption restart);
|
| + 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 OnRestartAllowedChanged(bool new_restart_allowed);
|
|
|
| // Tracks the registered KeepAlives, storing the origin and the number of
|
| // registered KeepAlives for each.
|
| @@ -37,7 +54,16 @@ class KeepAliveRegistry {
|
| // Total number of registered KeepAlives
|
| int registered_count_;
|
|
|
| + // Number of registered keep alives that have KeepAliveRestartOption::ENABLED.
|
| + int restart_allowed_count_;
|
| +
|
| + base::ObserverList<KeepAliveStateObserver> observers_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(KeepAliveRegistry);
|
| };
|
|
|
| +#ifndef NDEBUG
|
| +std::ostream& operator<<(std::ostream& out, const KeepAliveRegistry& registry);
|
| +#endif // ndef NDEBUG
|
| +
|
| #endif // CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_
|
|
|