Chromium Code Reviews| 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 51e90bff06bf99a9d7536b783996ed9466150f2a..8597e18366a8a7c08a95f3241c4bdad1e0fe8ac6 100644 |
| --- a/chrome/browser/lifetime/keep_alive_registry.h |
| +++ b/chrome/browser/lifetime/keep_alive_registry.h |
| @@ -9,16 +9,28 @@ |
| #include "base/macros.h" |
| #include "base/memory/singleton.h" |
| +#include "base/observer_list.h" |
| +#include "chrome/browser/lifetime/keep_alive_types.h" |
| namespace keep_alive { |
| enum class Origin; |
| +enum class RestartOption; |
| } |
| +class KeepAliveStateObserver; |
| class KeepAliveRegistry { |
| public: |
| static KeepAliveRegistry* GetInstance(); |
| + void AddObserver(KeepAliveStateObserver* observer); |
| + void RemoveObserver(KeepAliveStateObserver* observer); |
| + |
| private: |
| + struct KeepAliveState { |
|
Bernhard Bauer
2016/02/24 16:54:34
Do you need this as a struct? It seems a bit easie
dgn
2016/02/24 19:08:32
Makes it easier to use compute/compare state
|
| + bool is_keeping_alive; |
| + keep_alive::RestartOption restart; |
|
Bernhard Bauer
2016/02/24 16:54:34
I'd be okay with keeping this as a boolean; I only
dgn
2016/02/24 19:08:32
Thanks, I did it initially because I was comparing
|
| + }; |
| + |
| friend struct base::DefaultSingletonTraits<KeepAliveRegistry>; |
| // Friend to be able to use Register/Unregister |
| friend class ScopedKeepAlive; |
| @@ -27,10 +39,20 @@ class KeepAliveRegistry { |
| ~KeepAliveRegistry(); |
| // Add/Remove entries. Do not use directly, use ScopedKeepAlive instead. |
| - void Register(keep_alive::Origin origin); |
| - void Unregister(keep_alive::Origin origin); |
| + void Register(keep_alive::Origin origin, keep_alive::RestartOption restart); |
| + void Unregister(keep_alive::Origin origin, keep_alive::RestartOption restart); |
| + |
| + KeepAliveState ComputeCurrentState() const; |
| + void NotifyOfStateDifferences(const KeepAliveState& previous_state); |
| + |
| + void DumpRegistryIfDebug() const; |
| std::multiset<keep_alive::Origin> registered_keep_alives_; |
| + std::multiset<keep_alive::Origin> restart_allowed_keep_alives_; |
| + |
| + KeepAliveState state_; |
|
Bernhard Bauer
2016/02/24 16:54:34
Hm... so, this is really defined by the two sets a
dgn
2016/02/24 19:08:32
Ok, I did that way in PS1 and ended up storing it
|
| + |
| + base::ObserverList<KeepAliveStateObserver> observers_; |
| DISALLOW_COPY_AND_ASSIGN(KeepAliveRegistry); |
| }; |