OLD | NEW |
---|---|
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 template<bool> | 112 template<bool> |
113 class SupplementTracing; | 113 class SupplementTracing; |
114 | 114 |
115 template<> | 115 template<> |
116 class SupplementTracing<true> : public GarbageCollectedMixin { }; | 116 class SupplementTracing<true> : public GarbageCollectedMixin { }; |
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 virtual void trace(Visitor*) { } | |
122 }; | 123 }; |
123 | 124 |
124 template<typename T, bool isGarbageCollected = false> | 125 template<typename T, bool isGarbageCollected = false> |
125 class SupplementBase : public SupplementTracing<isGarbageCollected> { | 126 class SupplementBase : public SupplementTracing<isGarbageCollected> { |
126 public: | 127 public: |
127 #if ENABLE(SECURITY_ASSERT) | 128 #if ENABLE(SECURITY_ASSERT) |
128 virtual bool isRefCountedWrapper() const { return false; } | 129 virtual bool isRefCountedWrapper() const { return false; } |
129 #endif | 130 #endif |
130 | 131 |
131 static void provideTo(SupplementableBase<T, isGarbageCollected>& host, const char* key, typename SupplementableTraits<T, isGarbageCollected>::SupplementArgu mentType supplement) | 132 static void provideTo(SupplementableBase<T, isGarbageCollected>& host, const char* key, typename SupplementableTraits<T, isGarbageCollected>::SupplementArgu mentType supplement) |
132 { | 133 { |
133 host.provideSupplement(key, supplement); | 134 host.provideSupplement(key, supplement); |
134 } | 135 } |
135 | 136 |
136 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>& host, const char* key) | 137 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>& host, const char* key) |
137 { | 138 { |
138 return host.requireSupplement(key); | 139 return host.requireSupplement(key); |
139 } | 140 } |
140 | 141 |
141 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>* host, const char* key) | 142 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>* host, const char* key) |
142 { | 143 { |
143 return host ? host->requireSupplement(key) : 0; | 144 return host ? host->requireSupplement(key) : 0; |
144 } | 145 } |
145 | 146 |
146 virtual void trace(Visitor*) { } | |
147 virtual void willBeDestroyed() { } | 147 virtual void willBeDestroyed() { } |
148 | 148 |
149 // FIXME: Oilpan: Remove this callback once PersistentHeapSupplementable is removed again. | 149 // FIXME: Oilpan: Remove this callback once PersistentHeapSupplementable is removed again. |
150 virtual void persistentHostHasBeenDestroyed() { } | 150 virtual void persistentHostHasBeenDestroyed() { } |
151 }; | 151 }; |
152 | 152 |
153 template<typename T, bool> | 153 template<typename T, bool> |
154 class SupplementableTracing; | 154 class SupplementableTracing; |
155 | 155 |
156 template<typename T> | 156 // We have a trace method in the specializations of SupplementableTracing to |
157 class SupplementableTracing<T, true> { }; | 157 // ensure we have the vtable at the first word of the object. However we don't |
158 // trace the m_supplements here, but in the partially specialized template | |
159 // subclasses since we only want to trace it for garbage collected classes. | |
158 | 160 |
159 template<typename T> | 161 template<typename T> |
160 class SupplementableTracing<T, false> { }; | 162 class SupplementableTracing<T, true> { |
sof
2014/08/13 12:29:09
What value does this templated class add now?
zerny-chromium
2014/08/13 13:07:01
None really. I'll remove it. The reason it is/was
| |
163 public: | |
164 virtual void trace(Visitor*) { } | |
165 }; | |
166 | |
167 template<typename T> | |
168 class SupplementableTracing<T, false> { | |
169 public: | |
170 virtual void trace(Visitor*) { } | |
171 }; | |
161 | 172 |
162 // Helper class for implementing Supplementable, HeapSupplementable, and | 173 // Helper class for implementing Supplementable, HeapSupplementable, and |
163 // PersistentHeapSupplementable. | 174 // PersistentHeapSupplementable. |
164 template<typename T, bool isGarbageCollected = false> | 175 template<typename T, bool isGarbageCollected = false> |
165 class SupplementableBase : public SupplementableTracing<T, isGarbageCollected> { | 176 class SupplementableBase : public SupplementableTracing<T, isGarbageCollected> { |
166 public: | 177 public: |
167 void provideSupplement(const char* key, typename SupplementableTraits<T, isG arbageCollected>::SupplementArgumentType supplement) | 178 void provideSupplement(const char* key, typename SupplementableTraits<T, isG arbageCollected>::SupplementArgumentType supplement) |
168 { | 179 { |
169 ASSERT(m_threadId == currentThread()); | 180 ASSERT(m_threadId == currentThread()); |
170 ASSERT(!this->m_supplements.get(key)); | 181 ASSERT(!this->m_supplements.get(key)); |
(...skipping 12 matching lines...) Expand all Loading... | |
183 return this->m_supplements.get(key); | 194 return this->m_supplements.get(key); |
184 } | 195 } |
185 | 196 |
186 void reattachThread() | 197 void reattachThread() |
187 { | 198 { |
188 #if ENABLE(ASSERT) | 199 #if ENABLE(ASSERT) |
189 m_threadId = currentThread(); | 200 m_threadId = currentThread(); |
190 #endif | 201 #endif |
191 } | 202 } |
192 | 203 |
193 // We have a trace method in the SupplementableBase class to ensure we have | |
194 // the vtable at the first word of the object. However we don't trace the | |
195 // m_supplements here, but in the partially specialized template subclasses | |
196 // since we only want to trace it for garbage collected classes. | |
197 virtual void trace(Visitor*) { } | |
198 | |
199 void willBeDestroyed() | 204 void willBeDestroyed() |
200 { | 205 { |
201 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement Map::iterator SupplementIterator; | 206 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement Map::iterator SupplementIterator; |
202 for (SupplementIterator it = m_supplements.begin(); it != m_supplements. end(); ++it) | 207 for (SupplementIterator it = m_supplements.begin(); it != m_supplements. end(); ++it) |
203 it->value->willBeDestroyed(); | 208 it->value->willBeDestroyed(); |
204 } | 209 } |
205 | 210 |
206 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup plementable is removed again. | 211 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup plementable is removed again. |
207 protected: | 212 protected: |
208 GC_PLUGIN_IGNORE("") | 213 GC_PLUGIN_IGNORE("") |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 }; | 294 }; |
290 | 295 |
291 template<typename T> | 296 template<typename T> |
292 struct ThreadingTrait<blink::SupplementableBase<T, true> > { | 297 struct ThreadingTrait<blink::SupplementableBase<T, true> > { |
293 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; | 298 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; |
294 }; | 299 }; |
295 | 300 |
296 } // namespace blink | 301 } // namespace blink |
297 | 302 |
298 #endif // Supplementable_h | 303 #endif // Supplementable_h |
OLD | NEW |