Chromium Code Reviews| 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 <unordered_map> | 8 #include <unordered_map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 bool IsRestartAllowed() const; | 33 bool IsRestartAllowed() const; |
| 34 bool IsOriginRegistered(KeepAliveOrigin origin) const; | 34 bool IsOriginRegistered(KeepAliveOrigin origin) const; |
| 35 | 35 |
| 36 void AddObserver(KeepAliveStateObserver* observer); | 36 void AddObserver(KeepAliveStateObserver* observer); |
| 37 void RemoveObserver(KeepAliveStateObserver* observer); | 37 void RemoveObserver(KeepAliveStateObserver* observer); |
| 38 | 38 |
| 39 // Returns whether restart would be allowed if all the keep alives for the | 39 // Returns whether restart would be allowed if all the keep alives for the |
| 40 // provided |origins| were not registered. | 40 // provided |origins| were not registered. |
| 41 bool WouldRestartWithout(const std::vector<KeepAliveOrigin>& origins) const; | 41 bool WouldRestartWithout(const std::vector<KeepAliveOrigin>& origins) const; |
| 42 | 42 |
| 43 // TODO(sammiequon): This is used to help debug the crash in crbug.com/660962. | |
| 44 // Remove this when the crash is fixed or if verified to not be related to | |
| 45 // this. | |
| 46 std::string ToString() const; | |
|
sky
2017/03/22 03:56:16
How about naming this more specifically, possibly
| |
| 47 | |
| 43 private: | 48 private: |
| 44 friend struct base::DefaultSingletonTraits<KeepAliveRegistry>; | 49 friend struct base::DefaultSingletonTraits<KeepAliveRegistry>; |
| 45 // Friend to be able to use Register/Unregister | 50 // Friend to be able to use Register/Unregister |
| 46 friend class ScopedKeepAlive; | 51 friend class ScopedKeepAlive; |
| 47 friend std::ostream& operator<<(std::ostream& out, | 52 friend std::ostream& operator<<(std::ostream& out, |
| 48 const KeepAliveRegistry& registry); | 53 const KeepAliveRegistry& registry); |
| 49 | 54 |
| 50 // TODO(dgn): Remove this when std::hash supports enums directly (c++14) | 55 // TODO(dgn): Remove this when std::hash supports enums directly (c++14) |
| 51 // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148 | 56 // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148 |
| 52 struct EnumClassHash { | 57 struct EnumClassHash { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 // Number of registered keep alives that have KeepAliveRestartOption::ENABLED. | 91 // Number of registered keep alives that have KeepAliveRestartOption::ENABLED. |
| 87 int restart_allowed_count_; | 92 int restart_allowed_count_; |
| 88 | 93 |
| 89 base::ObserverList<KeepAliveStateObserver> observers_; | 94 base::ObserverList<KeepAliveStateObserver> observers_; |
| 90 | 95 |
| 91 DISALLOW_COPY_AND_ASSIGN(KeepAliveRegistry); | 96 DISALLOW_COPY_AND_ASSIGN(KeepAliveRegistry); |
| 92 }; | 97 }; |
| 93 | 98 |
| 94 | 99 |
| 95 #endif // CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_ | 100 #endif // CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_ |
| OLD | NEW |