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

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

Issue 2680843006: Tidy DEFINE_(THREAD_SAFE_)STATIC_LOCAL() implementations. (Closed)
Patch Set: explain safety of HTMLTableSectionElement singletons Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Member_h 5 #ifndef Member_h
6 #define Member_h 6 #define Member_h
7 7
8 #include "wtf/Allocator.h" 8 #include "wtf/Allocator.h"
9 #include "wtf/HashFunctions.h" 9 #include "wtf/HashFunctions.h"
10 #include "wtf/HashTraits.h" 10 #include "wtf/HashTraits.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 template <typename T> 14 template <typename T>
15 class Persistent; 15 class Persistent;
16 class ScriptWrappable;
16 template <typename T> 17 template <typename T>
17 class TraceWrapperMember; 18 class TraceWrapperMember;
18 19
19 enum class TracenessMemberConfiguration { 20 enum class TracenessMemberConfiguration {
20 Traced, 21 Traced,
21 Untraced, 22 Untraced,
22 }; 23 };
23 24
24 template <typename T, 25 template <typename T,
25 TracenessMemberConfiguration tracenessConfiguration = 26 TracenessMemberConfiguration tracenessConfiguration =
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 #if DCHECK_IS_ON() 166 #if DCHECK_IS_ON()
166 if (tracenessConfiguration == TracenessMemberConfiguration::Untraced) { 167 if (tracenessConfiguration == TracenessMemberConfiguration::Untraced) {
167 m_creationThreadState = nullptr; 168 m_creationThreadState = nullptr;
168 } else { 169 } else {
169 m_creationThreadState = ThreadState::current(); 170 m_creationThreadState = ThreadState::current();
170 // Members should be created in an attached thread. But an empty 171 // Members should be created in an attached thread. But an empty
171 // value Member may be created on an unattached thread by a heap 172 // value Member may be created on an unattached thread by a heap
172 // collection iterator. 173 // collection iterator.
173 DCHECK(m_creationThreadState || !m_raw); 174 DCHECK(m_creationThreadState || !m_raw);
174 } 175 }
176
177 // If this DCHECK() triggers, you're attempting to embed a ScriptWrappable
178 // inside a static local singleton, which is unsafe.
179 // See |DEFINE_STATIC_LOCAL()| documentation for further details.
180 if (WTF::IsSubclass<T, blink::ScriptWrappable>::value) {
181 if (m_creationThreadState)
182 DCHECK(m_creationThreadState->canAllocateScriptWrappable());
haraken 2017/02/11 10:25:20 Would you help me understand why we need to have t
sof 2017/02/11 12:09:11 Good question to raise -- the "no ScriptWrappable"
183 }
175 #endif 184 #endif
176 } 185 }
177 186
178 T* m_raw; 187 T* m_raw;
179 #if DCHECK_IS_ON() 188 #if DCHECK_IS_ON()
180 const ThreadState* m_creationThreadState; 189 const ThreadState* m_creationThreadState;
181 #endif 190 #endif
182 191
183 template <bool x, 192 template <bool x,
184 WTF::WeakHandlingFlag y, 193 WTF::WeakHandlingFlag y,
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 575
567 template <typename T> 576 template <typename T>
568 struct IsTraceable<blink::TraceWrapperMember<T>> { 577 struct IsTraceable<blink::TraceWrapperMember<T>> {
569 STATIC_ONLY(IsTraceable); 578 STATIC_ONLY(IsTraceable);
570 static const bool value = true; 579 static const bool value = true;
571 }; 580 };
572 581
573 } // namespace WTF 582 } // namespace WTF
574 583
575 #endif // Member_h 584 #endif // Member_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698