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

Side by Side Diff: third_party/WebKit/Source/platform/heap/PersistentNode.h

Issue 2640163004: Replace ENABLE(ASSERT) with DCHECK_IS_ON(). (Closed)
Patch Set: Created 3 years, 11 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 PersistentNode_h 5 #ifndef PersistentNode_h
6 #define PersistentNode_h 6 #define PersistentNode_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/heap/ThreadState.h" 9 #include "platform/heap/ThreadState.h"
10 #include "wtf/Allocator.h" 10 #include "wtf/Allocator.h"
11 #include "wtf/Assertions.h" 11 #include "wtf/Assertions.h"
12 #include "wtf/PtrUtil.h" 12 #include "wtf/PtrUtil.h"
13 #include "wtf/ThreadingPrimitives.h" 13 #include "wtf/ThreadingPrimitives.h"
14 #include <memory> 14 #include <memory>
15 15
16 namespace blink { 16 namespace blink {
17 17
18 class CrossThreadPersistentRegion; 18 class CrossThreadPersistentRegion;
19 19
20 class PersistentNode final { 20 class PersistentNode final {
21 DISALLOW_NEW(); 21 DISALLOW_NEW();
22 22
23 public: 23 public:
24 PersistentNode() : m_self(nullptr), m_trace(nullptr) { ASSERT(isUnused()); } 24 PersistentNode() : m_self(nullptr), m_trace(nullptr) { ASSERT(isUnused()); }
25 25
26 #if ENABLE(ASSERT) 26 #if DCHECK_IS_ON()
27 ~PersistentNode() { 27 ~PersistentNode() {
28 // If you hit this assert, it means that the thread finished 28 // If you hit this assert, it means that the thread finished
29 // without clearing persistent handles that the thread created. 29 // without clearing persistent handles that the thread created.
30 // We don't enable the assert for the main thread because the 30 // We don't enable the assert for the main thread because the
31 // main thread finishes without clearing all persistent handles. 31 // main thread finishes without clearing all persistent handles.
32 ASSERT(isMainThread() || isUnused()); 32 ASSERT(isMainThread() || isUnused());
33 } 33 }
34 #endif 34 #endif
35 35
36 // It is dangerous to copy the PersistentNode because it breaks the 36 // It is dangerous to copy the PersistentNode because it breaks the
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 m_persistentRegion.lock(); 207 m_persistentRegion.lock();
208 } 208 }
209 ~LockScope() { m_persistentRegion.unlock(); } 209 ~LockScope() { m_persistentRegion.unlock(); }
210 210
211 private: 211 private:
212 CrossThreadPersistentRegion& m_persistentRegion; 212 CrossThreadPersistentRegion& m_persistentRegion;
213 }; 213 };
214 214
215 void tracePersistentNodes(Visitor* visitor) { 215 void tracePersistentNodes(Visitor* visitor) {
216 // If this assert triggers, you're tracing without being in a LockScope. 216 // If this assert triggers, you're tracing without being in a LockScope.
217 #if ENABLE(ASSERT) 217 #if DCHECK_IS_ON()
218 DCHECK(m_mutex.locked()); 218 DCHECK(m_mutex.locked());
219 #endif 219 #endif
220 m_persistentRegion->tracePersistentNodes( 220 m_persistentRegion->tracePersistentNodes(
221 visitor, CrossThreadPersistentRegion::shouldTracePersistentNode); 221 visitor, CrossThreadPersistentRegion::shouldTracePersistentNode);
222 } 222 }
223 223
224 void prepareForThreadStateTermination(ThreadState*); 224 void prepareForThreadStateTermination(ThreadState*);
225 225
226 NO_SANITIZE_ADDRESS 226 NO_SANITIZE_ADDRESS
227 static bool shouldTracePersistentNode(Visitor*, PersistentNode*); 227 static bool shouldTracePersistentNode(Visitor*, PersistentNode*);
(...skipping 17 matching lines...) Expand all
245 // Recursive as prepareForThreadStateTermination() clears a PersistentNode's 245 // Recursive as prepareForThreadStateTermination() clears a PersistentNode's
246 // associated Persistent<> -- it in turn freeing the PersistentNode. And both 246 // associated Persistent<> -- it in turn freeing the PersistentNode. And both
247 // CrossThreadPersistentRegion operations need a lock on the region before 247 // CrossThreadPersistentRegion operations need a lock on the region before
248 // mutating. 248 // mutating.
249 RecursiveMutex m_mutex; 249 RecursiveMutex m_mutex;
250 }; 250 };
251 251
252 } // namespace blink 252 } // namespace blink
253 253
254 #endif 254 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698