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

Side by Side Diff: third_party/WebKit/Source/wtf/RefCounted.h

Issue 2458003002: Remove ASSERT_WITH_SECURITY_IMPLICATION. (Closed)
Patch Set: Minor formatting fix Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 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 28 matching lines...) Expand all
39 // This base class holds the non-template methods and attributes. 39 // This base class holds the non-template methods and attributes.
40 // The RefCounted class inherits from it reducing the template bloat 40 // The RefCounted class inherits from it reducing the template bloat
41 // generated by the compiler (technique called template hoisting). 41 // generated by the compiler (technique called template hoisting).
42 class WTF_EXPORT RefCountedBase { 42 class WTF_EXPORT RefCountedBase {
43 public: 43 public:
44 void ref() const { 44 void ref() const {
45 #if CHECK_REF_COUNTED_LIFECYCLE 45 #if CHECK_REF_COUNTED_LIFECYCLE
46 m_verifier.onRef(m_refCount); 46 m_verifier.onRef(m_refCount);
47 ASSERT(!m_adoptionIsRequired); 47 ASSERT(!m_adoptionIsRequired);
48 #endif 48 #endif
49 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 49 SECURITY_DCHECK(!m_deletionHasBegun);
50 ++m_refCount; 50 ++m_refCount;
51 } 51 }
52 52
53 bool hasOneRef() const { 53 bool hasOneRef() const {
54 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 54 SECURITY_DCHECK(!m_deletionHasBegun);
55 #if CHECK_REF_COUNTED_LIFECYCLE 55 #if CHECK_REF_COUNTED_LIFECYCLE
56 m_verifier.checkSafeToUse(); 56 m_verifier.checkSafeToUse();
57 #endif 57 #endif
58 return m_refCount == 1; 58 return m_refCount == 1;
59 } 59 }
60 60
61 int refCount() const { 61 int refCount() const {
62 #if CHECK_REF_COUNTED_LIFECYCLE 62 #if CHECK_REF_COUNTED_LIFECYCLE
63 m_verifier.checkSafeToUse(); 63 m_verifier.checkSafeToUse();
64 #endif 64 #endif
65 return m_refCount; 65 return m_refCount;
66 } 66 }
67 67
68 protected: 68 protected:
69 RefCountedBase() 69 RefCountedBase()
70 : m_refCount(1) 70 : m_refCount(1)
71 #if ENABLE(SECURITY_ASSERT) 71 #if ENABLE(SECURITY_ASSERT)
72 , 72 ,
73 m_deletionHasBegun(false) 73 m_deletionHasBegun(false)
74 #endif 74 #endif
75 #if CHECK_REF_COUNTED_LIFECYCLE 75 #if CHECK_REF_COUNTED_LIFECYCLE
76 , 76 ,
77 m_adoptionIsRequired(true) 77 m_adoptionIsRequired(true)
78 #endif 78 #endif
79 { 79 {
80 } 80 }
81 81
82 ~RefCountedBase() { 82 ~RefCountedBase() {
83 ASSERT_WITH_SECURITY_IMPLICATION(m_deletionHasBegun); 83 SECURITY_DCHECK(m_deletionHasBegun);
84 #if CHECK_REF_COUNTED_LIFECYCLE 84 #if CHECK_REF_COUNTED_LIFECYCLE
85 ASSERT(!m_adoptionIsRequired); 85 ASSERT(!m_adoptionIsRequired);
86 #endif 86 #endif
87 } 87 }
88 88
89 // Returns whether the pointer should be freed or not. 89 // Returns whether the pointer should be freed or not.
90 bool derefBase() const { 90 bool derefBase() const {
91 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 91 SECURITY_DCHECK(!m_deletionHasBegun);
92 #if CHECK_REF_COUNTED_LIFECYCLE 92 #if CHECK_REF_COUNTED_LIFECYCLE
93 m_verifier.onDeref(m_refCount); 93 m_verifier.onDeref(m_refCount);
94 ASSERT(!m_adoptionIsRequired); 94 ASSERT(!m_adoptionIsRequired);
95 #endif 95 #endif
96 96
97 ASSERT(m_refCount > 0); 97 ASSERT(m_refCount > 0);
98 --m_refCount; 98 --m_refCount;
99 if (!m_refCount) { 99 if (!m_refCount) {
100 #if ENABLE(SECURITY_ASSERT) 100 #if ENABLE(SECURITY_ASSERT)
101 m_deletionHasBegun = true; 101 m_deletionHasBegun = true;
(...skipping 20 matching lines...) Expand all
122 #if CHECK_REF_COUNTED_LIFECYCLE 122 #if CHECK_REF_COUNTED_LIFECYCLE
123 mutable bool m_adoptionIsRequired; 123 mutable bool m_adoptionIsRequired;
124 mutable ThreadRestrictionVerifier m_verifier; 124 mutable ThreadRestrictionVerifier m_verifier;
125 #endif 125 #endif
126 }; 126 };
127 127
128 #if CHECK_REF_COUNTED_LIFECYCLE || ENABLE(SECURITY_ASSERT) 128 #if CHECK_REF_COUNTED_LIFECYCLE || ENABLE(SECURITY_ASSERT)
129 inline void adopted(RefCountedBase* object) { 129 inline void adopted(RefCountedBase* object) {
130 if (!object) 130 if (!object)
131 return; 131 return;
132 ASSERT_WITH_SECURITY_IMPLICATION(!object->m_deletionHasBegun); 132 SECURITY_DCHECK(!object->m_deletionHasBegun);
133 #if CHECK_REF_COUNTED_LIFECYCLE 133 #if CHECK_REF_COUNTED_LIFECYCLE
134 object->m_adoptionIsRequired = false; 134 object->m_adoptionIsRequired = false;
135 #endif 135 #endif
136 } 136 }
137 #endif 137 #endif
138 138
139 template <typename T> 139 template <typename T>
140 class RefCounted : public RefCountedBase { 140 class RefCounted : public RefCountedBase {
141 WTF_MAKE_NONCOPYABLE(RefCounted); 141 WTF_MAKE_NONCOPYABLE(RefCounted);
142 142
(...skipping 16 matching lines...) Expand all
159 #else 159 #else
160 RefCounted() {} 160 RefCounted() {}
161 #endif 161 #endif
162 }; 162 };
163 163
164 } // namespace WTF 164 } // namespace WTF
165 165
166 using WTF::RefCounted; 166 using WTF::RefCounted;
167 167
168 #endif // RefCounted_h 168 #endif // RefCounted_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/HashTable.h ('k') | third_party/WebKit/Source/wtf/ThreadRestrictionVerifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698