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

Side by Side Diff: Source/platform/Supplementable.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) 2012 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2012 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 14 matching lines...) Expand all
25 25
26 #ifndef Supplementable_h 26 #ifndef Supplementable_h
27 #define Supplementable_h 27 #define Supplementable_h
28 28
29 #include "platform/heap/Handle.h" 29 #include "platform/heap/Handle.h"
30 #include "wtf/Assertions.h" 30 #include "wtf/Assertions.h"
31 #include "wtf/HashMap.h" 31 #include "wtf/HashMap.h"
32 #include "wtf/OwnPtr.h" 32 #include "wtf/OwnPtr.h"
33 #include "wtf/PassOwnPtr.h" 33 #include "wtf/PassOwnPtr.h"
34 34
35 #if ASSERT_ENABLED 35 #if ENABLE(ASSERT)
36 #include "wtf/Threading.h" 36 #include "wtf/Threading.h"
37 #endif 37 #endif
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 // What you should know about Supplementable and Supplement 41 // What you should know about Supplementable and Supplement
42 // ======================================================== 42 // ========================================================
43 // Supplementable and Supplement instances are meant to be thread local. They 43 // Supplementable and Supplement instances are meant to be thread local. They
44 // should only be accessed from within the thread that created them. The 44 // should only be accessed from within the thread that created them. The
45 // 2 classes are not designed for safe access from another thread. Violating 45 // 2 classes are not designed for safe access from another thread. Violating
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 template<> 118 template<>
119 class SupplementTracing<false> { 119 class SupplementTracing<false> {
120 public: 120 public:
121 virtual ~SupplementTracing() { } 121 virtual ~SupplementTracing() { }
122 }; 122 };
123 123
124 template<typename T, bool isGarbageCollected = false> 124 template<typename T, bool isGarbageCollected = false>
125 class SupplementBase : public SupplementTracing<isGarbageCollected> { 125 class SupplementBase : public SupplementTracing<isGarbageCollected> {
126 public: 126 public:
127 #if SECURITY_ASSERT_ENABLED 127 #if ENABLE(SECURITY_ASSERT)
128 virtual bool isRefCountedWrapper() const { return false; } 128 virtual bool isRefCountedWrapper() const { return false; }
129 #endif 129 #endif
130 130
131 static void provideTo(SupplementableBase<T, isGarbageCollected>& host, const char* key, typename SupplementableTraits<T, isGarbageCollected>::SupplementArgu mentType supplement) 131 static void provideTo(SupplementableBase<T, isGarbageCollected>& host, const char* key, typename SupplementableTraits<T, isGarbageCollected>::SupplementArgu mentType supplement)
132 { 132 {
133 host.provideSupplement(key, supplement); 133 host.provideSupplement(key, supplement);
134 } 134 }
135 135
136 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>& host, const char* key) 136 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>& host, const char* key)
137 { 137 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 177
178 SupplementBase<T, isGarbageCollected>* requireSupplement(const char* key) 178 SupplementBase<T, isGarbageCollected>* requireSupplement(const char* key)
179 { 179 {
180 ASSERT(m_threadId == currentThread()); 180 ASSERT(m_threadId == currentThread());
181 return this->m_supplements.get(key); 181 return this->m_supplements.get(key);
182 } 182 }
183 183
184 void reattachThread() 184 void reattachThread()
185 { 185 {
186 #if ASSERT_ENABLED 186 #if ENABLE(ASSERT)
187 m_threadId = currentThread(); 187 m_threadId = currentThread();
188 #endif 188 #endif
189 } 189 }
190 190
191 virtual void trace(Visitor* visitor) { visitor->trace(m_supplements); } 191 virtual void trace(Visitor* visitor) { visitor->trace(m_supplements); }
192 192
193 void willBeDestroyed() 193 void willBeDestroyed()
194 { 194 {
195 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement Map::iterator SupplementIterator; 195 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement Map::iterator SupplementIterator;
196 for (SupplementIterator it = m_supplements.begin(); it != m_supplements. end(); ++it) 196 for (SupplementIterator it = m_supplements.begin(); it != m_supplements. end(); ++it)
197 it->value->willBeDestroyed(); 197 it->value->willBeDestroyed();
198 } 198 }
199 199
200 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup plementable is removed again. 200 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup plementable is removed again.
201 protected: 201 protected:
202 GC_PLUGIN_IGNORE("") 202 GC_PLUGIN_IGNORE("")
203 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple ments; 203 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple ments;
204 204
205 #if ASSERT_ENABLED 205 #if ENABLE(ASSERT)
206 protected: 206 protected:
207 SupplementableBase() : m_threadId(currentThread()) { } 207 SupplementableBase() : m_threadId(currentThread()) { }
208 208
209 private: 209 private:
210 ThreadIdentifier m_threadId; 210 ThreadIdentifier m_threadId;
211 #endif 211 #endif
212 }; 212 };
213 213
214 template<typename T> 214 template<typename T>
215 class HeapSupplement : public SupplementBase<T, true> { }; 215 class HeapSupplement : public SupplementBase<T, true> { };
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 }; 252 };
253 253
254 template<typename T> 254 template<typename T>
255 struct ThreadingTrait<WebCore::SupplementableBase<T, true> > { 255 struct ThreadingTrait<WebCore::SupplementableBase<T, true> > {
256 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 256 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
257 }; 257 };
258 258
259 } // namespace WebCore 259 } // namespace WebCore
260 260
261 #endif // Supplementable_h 261 #endif // Supplementable_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698