OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2009, 2010, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2009, 2010, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 21 matching lines...) Expand all Loading... |
32 template<typename NodeType> void adopted(TreeShared<NodeType>*); | 32 template<typename NodeType> void adopted(TreeShared<NodeType>*); |
33 #endif | 33 #endif |
34 | 34 |
35 template<typename NodeType> class TreeShared { | 35 template<typename NodeType> class TreeShared { |
36 WTF_MAKE_NONCOPYABLE(TreeShared); | 36 WTF_MAKE_NONCOPYABLE(TreeShared); |
37 protected: | 37 protected: |
38 TreeShared() | 38 TreeShared() |
39 : m_refCount(1) | 39 : m_refCount(1) |
40 #if SECURITY_ASSERT_ENABLED | 40 #if SECURITY_ASSERT_ENABLED |
41 , m_deletionHasBegun(false) | 41 , m_deletionHasBegun(false) |
42 #if !ASSERT_DISABLED | 42 #if ASSERT_ENABLED |
43 , m_inRemovedLastRefFunction(false) | 43 , m_inRemovedLastRefFunction(false) |
44 , m_adoptionIsRequired(true) | 44 , m_adoptionIsRequired(true) |
45 #endif | 45 #endif |
46 #endif | 46 #endif |
47 { | 47 { |
48 ASSERT(isMainThread()); | 48 ASSERT(isMainThread()); |
49 } | 49 } |
50 | 50 |
51 ~TreeShared() | 51 ~TreeShared() |
52 { | 52 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 { | 86 { |
87 return m_refCount; | 87 return m_refCount; |
88 } | 88 } |
89 | 89 |
90 private: | 90 private: |
91 int m_refCount; | 91 int m_refCount; |
92 | 92 |
93 #if SECURITY_ASSERT_ENABLED | 93 #if SECURITY_ASSERT_ENABLED |
94 public: | 94 public: |
95 bool m_deletionHasBegun; | 95 bool m_deletionHasBegun; |
96 #if !ASSERT_DISABLED | 96 #if ASSERT_ENABLED |
97 bool m_inRemovedLastRefFunction; | 97 bool m_inRemovedLastRefFunction; |
98 | 98 |
99 private: | 99 private: |
100 friend void adopted<>(TreeShared<NodeType>*); | 100 friend void adopted<>(TreeShared<NodeType>*); |
101 bool m_adoptionIsRequired; | 101 bool m_adoptionIsRequired; |
102 #endif | 102 #endif |
103 #endif | 103 #endif |
104 }; | 104 }; |
105 | 105 |
106 #if SECURITY_ASSERT_ENABLED | 106 #if SECURITY_ASSERT_ENABLED |
107 template<typename NodeType> inline void adopted(TreeShared<NodeType>* object) | 107 template<typename NodeType> inline void adopted(TreeShared<NodeType>* object) |
108 { | 108 { |
109 if (!object) | 109 if (!object) |
110 return; | 110 return; |
111 ASSERT_WITH_SECURITY_IMPLICATION(!object->m_deletionHasBegun); | 111 ASSERT_WITH_SECURITY_IMPLICATION(!object->m_deletionHasBegun); |
112 #if !ASSERT_DISABLED | 112 #if !ASSERT_DISABLED |
113 ASSERT(!object->m_inRemovedLastRefFunction); | 113 ASSERT(!object->m_inRemovedLastRefFunction); |
114 object->m_adoptionIsRequired = false; | 114 object->m_adoptionIsRequired = false; |
115 #endif | 115 #endif |
116 } | 116 } |
117 #endif | 117 #endif |
118 | 118 |
119 } | 119 } |
120 | 120 |
121 #endif // TreeShared.h | 121 #endif // TreeShared.h |
OLD | NEW |