OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 OnStackObjectChecker_h | 5 #ifndef OnStackObjectChecker_h |
6 #define OnStackObjectChecker_h | 6 #define OnStackObjectChecker_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "wtf/HashSet.h" | 9 #include "wtf/HashSet.h" |
10 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 #if ENABLE(ASSERT) | 14 #if ENABLE(ASSERT) |
15 class Dictionary; | 15 class Dictionary; |
16 | 16 |
17 // A lifetime checker for C++ objects which must not outlive the owner of an | 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 | 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 | 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. | 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 | 21 // The C++ objects to be checked must call add() on creation, and remove() on |
22 // destruction, respectively. | 22 // destruction, respectively. |
23 class CORE_EXPORT OnStackObjectChecker final { | 23 class CORE_EXPORT OnStackObjectChecker final { |
24 WTF_MAKE_NONCOPYABLE(OnStackObjectChecker); | 24 WTF_MAKE_NONCOPYABLE(OnStackObjectChecker); |
25 public: | 25 public: |
26 OnStackObjectChecker() { } | 26 OnStackObjectChecker(); |
27 ~OnStackObjectChecker(); | 27 ~OnStackObjectChecker(); |
28 | 28 |
29 void add(Dictionary*); | 29 void add(Dictionary*); |
30 void remove(Dictionary*); | 30 void remove(Dictionary*); |
31 | 31 |
32 private: | 32 private: |
33 HashSet<Dictionary*> m_dictionaries; | 33 HashSet<Dictionary*> m_dictionaries; |
34 }; | 34 }; |
35 #endif | 35 #endif |
36 | 36 |
37 } // namespace blink | 37 } // namespace blink |
38 | 38 |
39 #endif // OnStackObjectChecker_h | 39 #endif // OnStackObjectChecker_h |
OLD | NEW |