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

Side by Side Diff: Source/core/dom/TreeShared.h

Issue 397733004: Allow assertions to be enabled in Blink Release builds. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed config.gni. Minor cleanups. Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
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 10 matching lines...) Expand all
21 #ifndef TreeShared_h 21 #ifndef TreeShared_h
22 #define TreeShared_h 22 #define TreeShared_h
23 23
24 #include "public/platform/WebPrivatePtr.h" 24 #include "public/platform/WebPrivatePtr.h"
25 #include "wtf/Assertions.h" 25 #include "wtf/Assertions.h"
26 #include "wtf/MainThread.h" 26 #include "wtf/MainThread.h"
27 #include "wtf/Noncopyable.h" 27 #include "wtf/Noncopyable.h"
28 28
29 namespace WebCore { 29 namespace WebCore {
30 30
31 #if SECURITY_ASSERT_ENABLED 31 #if ENABLE(SECURITY_ASSERT)
32 template<typename NodeType> class TreeShared; 32 template<typename NodeType> class TreeShared;
33 template<typename NodeType> void adopted(TreeShared<NodeType>*); 33 template<typename NodeType> void adopted(TreeShared<NodeType>*);
34 #endif 34 #endif
35 35
36 template<typename NodeType> class TreeShared : public NoBaseWillBeGarbageCollect edFinalized<NodeType> { 36 template<typename NodeType> class TreeShared : public NoBaseWillBeGarbageCollect edFinalized<NodeType> {
37 WTF_MAKE_NONCOPYABLE(TreeShared); 37 WTF_MAKE_NONCOPYABLE(TreeShared);
38 protected: 38 protected:
39 TreeShared() 39 TreeShared()
40 : m_refCount(1) 40 : m_refCount(1)
41 #if SECURITY_ASSERT_ENABLED 41 #if ENABLE(SECURITY_ASSERT)
42 , m_deletionHasBegun(false) 42 , m_deletionHasBegun(false)
43 #if ASSERT_ENABLED 43 #if ENABLE(ASSERT)
44 , m_inRemovedLastRefFunction(false) 44 , m_inRemovedLastRefFunction(false)
45 , m_adoptionIsRequired(true) 45 , m_adoptionIsRequired(true)
46 #endif 46 #endif
47 #endif 47 #endif
48 { 48 {
49 ASSERT(isMainThread()); 49 ASSERT(isMainThread());
50 } 50 }
51 51
52 ~TreeShared() 52 ~TreeShared()
53 { 53 {
(...skipping 15 matching lines...) Expand all
69 69
70 void deref() 70 void deref()
71 { 71 {
72 ASSERT(isMainThread()); 72 ASSERT(isMainThread());
73 ASSERT(m_refCount > 0); 73 ASSERT(m_refCount > 0);
74 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 74 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun);
75 ASSERT(!m_inRemovedLastRefFunction); 75 ASSERT(!m_inRemovedLastRefFunction);
76 ASSERT(!m_adoptionIsRequired); 76 ASSERT(!m_adoptionIsRequired);
77 NodeType* thisNode = static_cast<NodeType*>(this); 77 NodeType* thisNode = static_cast<NodeType*>(this);
78 if (!--m_refCount && !thisNode->hasTreeSharedParent()) { 78 if (!--m_refCount && !thisNode->hasTreeSharedParent()) {
79 #if ASSERT_ENABLED 79 #if ENABLE(ASSERT)
80 m_inRemovedLastRefFunction = true; 80 m_inRemovedLastRefFunction = true;
81 #endif 81 #endif
82 thisNode->removedLastRef(); 82 thisNode->removedLastRef();
83 } 83 }
84 } 84 }
85 85
86 int refCount() const { return m_refCount; } 86 int refCount() const { return m_refCount; }
87 87
88 private: 88 private:
89 int m_refCount; 89 int m_refCount;
90 90
91 #if SECURITY_ASSERT_ENABLED 91 #if ENABLE(SECURITY_ASSERT)
92 public: 92 public:
93 bool m_deletionHasBegun; 93 bool m_deletionHasBegun;
94 #if ASSERT_ENABLED 94 #if ENABLE(ASSERT)
95 bool m_inRemovedLastRefFunction; 95 bool m_inRemovedLastRefFunction;
96 96
97 private: 97 private:
98 friend void adopted<>(TreeShared<NodeType>*); 98 friend void adopted<>(TreeShared<NodeType>*);
99 bool m_adoptionIsRequired; 99 bool m_adoptionIsRequired;
100 #endif 100 #endif
101 #endif 101 #endif
102 }; 102 };
103 103
104 #if SECURITY_ASSERT_ENABLED 104 #if ENABLE(SECURITY_ASSERT)
105 template<typename NodeType> void adopted(TreeShared<NodeType>* object) 105 template<typename NodeType> void adopted(TreeShared<NodeType>* object)
106 { 106 {
107 if (!object) 107 if (!object)
108 return; 108 return;
109 109
110 ASSERT_WITH_SECURITY_IMPLICATION(!object->m_deletionHasBegun); 110 ASSERT_WITH_SECURITY_IMPLICATION(!object->m_deletionHasBegun);
111 #if ASSERT_ENABLED 111 #if ENABLE(ASSERT)
112 ASSERT(!object->m_inRemovedLastRefFunction); 112 ASSERT(!object->m_inRemovedLastRefFunction);
113 object->m_adoptionIsRequired = false; 113 object->m_adoptionIsRequired = false;
114 #endif 114 #endif
115 } 115 }
116 #endif 116 #endif
117 117
118 } 118 }
119 119
120 #endif // TreeShared.h 120 #endif // TreeShared.h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698