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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 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) |
138 { | 138 { |
139 return host.requireSupplement(key); | 139 return host.requireSupplement(key); |
140 } | 140 } |
141 | 141 |
142 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) |
143 { | 143 { |
144 return host ? host->requireSupplement(key) : 0; | 144 return host ? host->requireSupplement(key) : 0; |
145 } | 145 } |
146 | 146 |
147 virtual void willBeDestroyed() { } | |
148 | |
149 // FIXME: Oilpan: Remove this callback once PersistentHeapSupplementable is
removed again. | 147 // FIXME: Oilpan: Remove this callback once PersistentHeapSupplementable is
removed again. |
150 virtual void persistentHostHasBeenDestroyed() { } | 148 virtual void persistentHostHasBeenDestroyed() { } |
151 }; | 149 }; |
152 | 150 |
153 // Helper class for implementing Supplementable, HeapSupplementable, and | 151 // Helper class for implementing Supplementable, HeapSupplementable, and |
154 // PersistentHeapSupplementable. | 152 // PersistentHeapSupplementable. |
155 template<typename T, bool isGarbageCollected = false> | 153 template<typename T, bool isGarbageCollected = false> |
156 class SupplementableBase { | 154 class SupplementableBase { |
157 public: | 155 public: |
158 void provideSupplement(const char* key, typename SupplementableTraits<T, isG
arbageCollected>::SupplementArgumentType supplement) | 156 void provideSupplement(const char* key, typename SupplementableTraits<T, isG
arbageCollected>::SupplementArgumentType supplement) |
(...skipping 21 matching lines...) Expand all Loading... |
180 m_threadId = currentThread(); | 178 m_threadId = currentThread(); |
181 #endif | 179 #endif |
182 } | 180 } |
183 | 181 |
184 // We have a trace method in the SupplementableBase class to ensure we have | 182 // We have a trace method in the SupplementableBase class to ensure we have |
185 // the vtable at the first word of the object. However we don't trace the | 183 // the vtable at the first word of the object. However we don't trace the |
186 // m_supplements here, but in the partially specialized template subclasses | 184 // m_supplements here, but in the partially specialized template subclasses |
187 // since we only want to trace it for garbage collected classes. | 185 // since we only want to trace it for garbage collected classes. |
188 virtual void trace(Visitor*) { } | 186 virtual void trace(Visitor*) { } |
189 | 187 |
190 void willBeDestroyed() | |
191 { | |
192 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement
Map::iterator SupplementIterator; | |
193 for (SupplementIterator it = m_supplements.begin(); it != m_supplements.
end(); ++it) | |
194 it->value->willBeDestroyed(); | |
195 } | |
196 | |
197 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup
plementable is removed again. | 188 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup
plementable is removed again. |
198 protected: | 189 protected: |
199 GC_PLUGIN_IGNORE("") | 190 GC_PLUGIN_IGNORE("") |
200 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple
ments; | 191 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple
ments; |
201 | 192 |
202 #if ENABLE(ASSERT) | 193 #if ENABLE(ASSERT) |
203 protected: | 194 protected: |
204 SupplementableBase() : m_threadId(currentThread()) { } | 195 SupplementableBase() : m_threadId(currentThread()) { } |
205 | 196 |
206 private: | 197 private: |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 }; | 271 }; |
281 | 272 |
282 template<typename T> | 273 template<typename T> |
283 struct ThreadingTrait<SupplementableBase<T, true> > { | 274 struct ThreadingTrait<SupplementableBase<T, true> > { |
284 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; | 275 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; |
285 }; | 276 }; |
286 | 277 |
287 } // namespace blink | 278 } // namespace blink |
288 | 279 |
289 #endif // Supplementable_h | 280 #endif // Supplementable_h |
OLD | NEW |