OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_ |
6 #define CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_ | 6 #define CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 | 12 |
13 struct KeepAliveOptions; | 13 struct KeepAliveOptions; |
| 14 class KeepAliveStateObserver; |
14 | 15 |
15 class KeepAliveRegistry { | 16 class KeepAliveRegistry { |
16 public: | 17 public: |
17 static KeepAliveRegistry* GetInstance(); | 18 static KeepAliveRegistry* GetInstance(); |
18 | 19 |
| 20 void SetObserver(KeepAliveStateObserver* observer); |
| 21 |
19 private: | 22 private: |
20 friend struct base::DefaultSingletonTraits<KeepAliveRegistry>; | 23 friend struct base::DefaultSingletonTraits<KeepAliveRegistry>; |
21 // Friend to be able to use Register/Unregister | 24 // Friend to be able to use Register/Unregister |
22 friend class ScopedKeepAlive; | 25 friend class ScopedKeepAlive; |
23 | 26 |
24 KeepAliveRegistry(); | 27 KeepAliveRegistry(); |
25 ~KeepAliveRegistry(); | 28 ~KeepAliveRegistry(); |
26 | 29 |
27 // Add/Remove entries. Do not use directly, use ScopedKeepAlive instead. | 30 // Add/Remove entries. Do not use directly, use ScopedKeepAlive instead. |
28 void Register(const KeepAliveOptions* options); | 31 void Register(const KeepAliveOptions* options); |
29 void Unregister(const KeepAliveOptions* options); | 32 void Unregister(const KeepAliveOptions* options); |
30 | 33 |
| 34 void DumpCurrentState() const; |
| 35 KeepAliveOptions ComputeCurrentState() const; |
| 36 void NotifyOfStateDifferences(const KeepAliveOptions& previous_state) const; |
| 37 |
| 38 KeepAliveStateObserver* observer_; |
| 39 |
31 std::multiset<const KeepAliveOptions*> registered_keep_alives_; | 40 std::multiset<const KeepAliveOptions*> registered_keep_alives_; |
| 41 std::multiset<const KeepAliveOptions*> restart_allowed_keep_alives_; |
32 | 42 |
33 DISALLOW_COPY_AND_ASSIGN(KeepAliveRegistry); | 43 DISALLOW_COPY_AND_ASSIGN(KeepAliveRegistry); |
34 }; | 44 }; |
35 | 45 |
36 #endif // CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_ | 46 #endif // CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_ |
OLD | NEW |