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

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

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win Created 4 years, 8 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 /* 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
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 : public GarbageCollectedFinalized< NodeType> { 35 template<typename NodeType> class TreeShared : public GarbageCollectedFinalized< NodeType> {
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 ENABLE(SECURITY_ASSERT) 40 #if ENABLE(SECURITY_ASSERT)
41 , m_deletionHasBegun(false) 41 , m_deletionHasBegun(false)
42 #if ENABLE(ASSERT) 42 #if DCHECK_IS_ON()
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 DCHECK(isMainThread());
49 } 49 }
50 50
51 ~TreeShared() 51 ~TreeShared()
52 { 52 {
53 ASSERT(isMainThread()); 53 DCHECK(isMainThread());
54 ASSERT(!m_refCount); 54 DCHECK(!m_refCount);
55 ASSERT_WITH_SECURITY_IMPLICATION(m_deletionHasBegun); 55 ASSERT_WITH_SECURITY_IMPLICATION(m_deletionHasBegun);
56 ASSERT(!m_adoptionIsRequired); 56 #if DCHECK_IS_ON()
57 DCHECK(!m_adoptionIsRequired);
58 #endif
57 } 59 }
58 60
59 public: 61 public:
60 void ref() 62 void ref()
61 { 63 {
62 ASSERT(isMainThread()); 64 DCHECK(isMainThread());
63 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 65 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun);
64 ASSERT(!m_inRemovedLastRefFunction); 66 #if DCHECK_IS_ON()
65 ASSERT(!m_adoptionIsRequired); 67 DCHECK(!m_inRemovedLastRefFunction);
68 DCHECK(!m_adoptionIsRequired);
69 #endif
66 ++m_refCount; 70 ++m_refCount;
67 } 71 }
68 72
69 void deref() 73 void deref()
70 { 74 {
71 ASSERT(isMainThread()); 75 DCHECK(isMainThread());
72 ASSERT(m_refCount > 0); 76 DCHECK_GT(m_refCount, 0);
73 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 77 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun);
74 ASSERT(!m_inRemovedLastRefFunction); 78 #if DCHECK_IS_ON()
75 ASSERT(!m_adoptionIsRequired); 79 DCHECK(!m_inRemovedLastRefFunction);
80 DCHECK(!m_adoptionIsRequired);
81 #endif
76 NodeType* thisNode = static_cast<NodeType*>(this); 82 NodeType* thisNode = static_cast<NodeType*>(this);
77 if (!--m_refCount && !thisNode->hasTreeSharedParent()) { 83 if (!--m_refCount && !thisNode->hasTreeSharedParent()) {
78 #if ENABLE(ASSERT) 84 #if DCHECK_IS_ON()
79 m_inRemovedLastRefFunction = true; 85 m_inRemovedLastRefFunction = true;
80 #endif 86 #endif
81 thisNode->removedLastRef(); 87 thisNode->removedLastRef();
82 } 88 }
83 } 89 }
84 90
85 int refCount() const { return m_refCount; } 91 int refCount() const { return m_refCount; }
86 92
87 private: 93 private:
88 int m_refCount; 94 int m_refCount;
89 95
90 #if ENABLE(SECURITY_ASSERT) 96 #if ENABLE(SECURITY_ASSERT)
91 public: 97 public:
92 bool m_deletionHasBegun; 98 bool m_deletionHasBegun;
93 #if ENABLE(ASSERT) 99 #if DCHECK_IS_ON()
94 bool m_inRemovedLastRefFunction; 100 bool m_inRemovedLastRefFunction;
95 101
96 private: 102 private:
97 friend void adopted<>(TreeShared<NodeType>*); 103 friend void adopted<>(TreeShared<NodeType>*);
98 bool m_adoptionIsRequired; 104 bool m_adoptionIsRequired;
99 #endif 105 #endif
100 #endif 106 #endif
101 }; 107 };
102 108
103 #if ENABLE(SECURITY_ASSERT) 109 #if ENABLE(SECURITY_ASSERT)
104 template<typename NodeType> void adopted(TreeShared<NodeType>* object) 110 template<typename NodeType> void adopted(TreeShared<NodeType>* object)
105 { 111 {
106 if (!object) 112 if (!object)
107 return; 113 return;
108 114
109 ASSERT_WITH_SECURITY_IMPLICATION(!object->m_deletionHasBegun); 115 ASSERT_WITH_SECURITY_IMPLICATION(!object->m_deletionHasBegun);
110 #if ENABLE(ASSERT) 116 #if DCHECK_IS_ON()
111 ASSERT(!object->m_inRemovedLastRefFunction); 117 DCHECK(!object->m_inRemovedLastRefFunction);
112 object->m_adoptionIsRequired = false; 118 object->m_adoptionIsRequired = false;
113 #endif 119 #endif
114 } 120 }
115 #endif 121 #endif
116 122
117 } // namespace blink 123 } // namespace blink
118 124
119 #endif // TreeShared.h 125 #endif // TreeShared.h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698