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

Side by Side Diff: chrome/browser/lifetime/keep_alive_registry.h

Issue 1708343002: Add ScopedKeepAlive to c/b/lifetime (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove KeepAliveOrigin::TEST Created 4 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_
6 #define CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_
7
8 #include <map>
9
10 #include "base/macros.h"
11 #include "base/memory/singleton.h"
12
13 enum class KeepAliveOrigin;
14
15 class KeepAliveRegistry {
16 public:
17 static KeepAliveRegistry* GetInstance();
18
19 bool WillKeepAlive() const;
20
21 private:
22 friend struct base::DefaultSingletonTraits<KeepAliveRegistry>;
23 // Friend to be able to use Register/Unregister
24 friend class ScopedKeepAlive;
25
26 KeepAliveRegistry();
27 ~KeepAliveRegistry();
28
29 // Add/Remove entries. Do not use directly, use ScopedKeepAlive instead.
30 void Register(KeepAliveOrigin origin);
31 void Unregister(KeepAliveOrigin origin);
32
33 // Tracks the registered KeepAlives, storing the origin and the number of
34 // registered KeepAlives for each.
35 std::map<KeepAliveOrigin, int> registered_keep_alives_;
36
37 // Total number of registered KeepAlives
38 int registered_count_;
39
40 DISALLOW_COPY_AND_ASSIGN(KeepAliveRegistry);
41 };
42
43 #endif // CHROME_BROWSER_LIFETIME_KEEP_ALIVE_REGISTRY_H_
OLDNEW
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.cc ('k') | chrome/browser/lifetime/keep_alive_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698