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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
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 <map> 8 #include <map>
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 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 13
14 enum class KeepAliveOrigin; 14 enum class KeepAliveOrigin;
15 enum class KeepAliveRestartOption; 15 enum class KeepAliveRestartOption;
16 class KeepAliveStateObserver; 16 class KeepAliveStateObserver;
17 17
18 class KeepAliveRegistry { 18 class KeepAliveRegistry {
19 public: 19 public:
20 static KeepAliveRegistry* GetInstance(); 20 static KeepAliveRegistry* GetInstance();
21 21
22 // Methods to query the state of the registry. 22 // Methods to query the state of the registry.
23 // TODO(dgn): This currently does not give a complete picture. It has no
24 // information about the many places that rely on AddRefModule to keep the
25 // browser alive. Tracked by https://crbug.com/587926
26 bool IsKeepingAlive() const; 23 bool IsKeepingAlive() const;
27 bool IsRestartAllowed() const; 24 bool IsRestartAllowed() const;
25 bool IsOriginRegistered(KeepAliveOrigin origin) const;
dgn 2016/03/16 15:10:50 Should I rename it xxForTesting? I suppose it coul
sky 2016/03/17 00:02:24 I wouldn't bother.
28 26
29 void AddObserver(KeepAliveStateObserver* observer); 27 void AddObserver(KeepAliveStateObserver* observer);
30 void RemoveObserver(KeepAliveStateObserver* observer); 28 void RemoveObserver(KeepAliveStateObserver* observer);
31 29
32 private: 30 private:
33 friend struct base::DefaultSingletonTraits<KeepAliveRegistry>; 31 friend struct base::DefaultSingletonTraits<KeepAliveRegistry>;
34 // Friend to be able to use Register/Unregister 32 // Friend to be able to use Register/Unregister
35 friend class ScopedKeepAlive; 33 friend class ScopedKeepAlive;
36 friend std::ostream& operator<<(std::ostream& out, 34 friend std::ostream& operator<<(std::ostream& out,
37 const KeepAliveRegistry& registry); 35 const KeepAliveRegistry& registry);
(...skipping 22 matching lines...) Expand all
60 base::ObserverList<KeepAliveStateObserver> observers_; 58 base::ObserverList<KeepAliveStateObserver> observers_;
61 59
62 DISALLOW_COPY_AND_ASSIGN(KeepAliveRegistry); 60 DISALLOW_COPY_AND_ASSIGN(KeepAliveRegistry);
63 }; 61 };
64 62
65 #ifndef NDEBUG 63 #ifndef NDEBUG
66 std::ostream& operator<<(std::ostream& out, const KeepAliveRegistry& registry); 64 std::ostream& operator<<(std::ostream& out, const KeepAliveRegistry& registry);
67 #endif // ndef NDEBUG 65 #endif // ndef NDEBUG
68 66
69 #endif // CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_ 67 #endif // CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698