OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 OnStackObjectChecker_h | |
6 #define OnStackObjectChecker_h | |
7 | |
8 #include "core/CoreExport.h" | |
9 #include "wtf/HashSet.h" | |
10 #include "wtf/Noncopyable.h" | |
11 | |
12 namespace blink { | |
13 | |
14 #if ENABLE(ASSERT) | |
15 class Dictionary; | |
16 | |
17 // A lifetime checker for C++ objects which must not outlive the owner of an | |
18 // instance of this class. In general, we should rely on Oilpan or RefCounted | |
19 // to manage object lifetime. However, we don't use them for some objects | |
20 // (e.g. Dictionary) for performance reason. This checker is for such objects. | |
21 // The C++ objects to be checked must call add() on creation, and remove() on | |
22 // destruction, respectively. | |
23 class CORE_EXPORT OnStackObjectChecker final { | |
24 WTF_MAKE_NONCOPYABLE(OnStackObjectChecker); | |
25 public: | |
26 OnStackObjectChecker(); | |
27 ~OnStackObjectChecker(); | |
28 | |
29 void add(Dictionary*); | |
30 void remove(Dictionary*); | |
31 | |
32 private: | |
33 HashSet<Dictionary*> m_dictionaries; | |
34 }; | |
35 #endif | |
36 | |
37 } // namespace blink | |
38 | |
39 #endif // OnStackObjectChecker_h | |
OLD | NEW |