| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return host.requireSupplement(key); | 138 return host.requireSupplement(key); |
| 139 } | 139 } |
| 140 | 140 |
| 141 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG
arbageCollected>* host, const char* key) | 141 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG
arbageCollected>* host, const char* key) |
| 142 { | 142 { |
| 143 return host ? host->requireSupplement(key) : 0; | 143 return host ? host->requireSupplement(key) : 0; |
| 144 } | 144 } |
| 145 | 145 |
| 146 virtual void trace(Visitor*) { } | 146 virtual void trace(Visitor*) { } |
| 147 virtual void willBeDestroyed() { } | 147 virtual void willBeDestroyed() { } |
| 148 |
| 149 // FIXME: Oilpan: Remove this callback once PersistentHeapSupplementable is
removed again. |
| 150 virtual void persistentHostHasBeenDestroyed() { } |
| 148 }; | 151 }; |
| 149 | 152 |
| 150 template<typename T, bool> | 153 template<typename T, bool> |
| 151 class SupplementableTracing; | 154 class SupplementableTracing; |
| 152 | 155 |
| 153 template<typename T> | 156 template<typename T> |
| 154 class SupplementableTracing<T, true> { }; | 157 class SupplementableTracing<T, true> { }; |
| 155 | 158 |
| 156 template<typename T> | 159 template<typename T> |
| 157 class SupplementableTracing<T, false> { }; | 160 class SupplementableTracing<T, false> { }; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 187 | 190 |
| 188 virtual void trace(Visitor* visitor) { visitor->trace(m_supplements); } | 191 virtual void trace(Visitor* visitor) { visitor->trace(m_supplements); } |
| 189 | 192 |
| 190 void willBeDestroyed() | 193 void willBeDestroyed() |
| 191 { | 194 { |
| 192 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement
Map::iterator SupplementIterator; | 195 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement
Map::iterator SupplementIterator; |
| 193 for (SupplementIterator it = m_supplements.begin(); it != m_supplements.
end(); ++it) | 196 for (SupplementIterator it = m_supplements.begin(); it != m_supplements.
end(); ++it) |
| 194 it->value->willBeDestroyed(); | 197 it->value->willBeDestroyed(); |
| 195 } | 198 } |
| 196 | 199 |
| 197 private: | 200 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup
plementable is removed again. |
| 198 // FIXME: Oilpan: Remove this ignore once PersistentHeapSupplementable is re
moved again. | 201 protected: |
| 199 GC_PLUGIN_IGNORE("") | 202 GC_PLUGIN_IGNORE("") |
| 200 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple
ments; | 203 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple
ments; |
| 201 | 204 |
| 202 #if ASSERT_ENABLED | 205 #if ASSERT_ENABLED |
| 203 protected: | 206 protected: |
| 204 SupplementableBase() : m_threadId(currentThread()) { } | 207 SupplementableBase() : m_threadId(currentThread()) { } |
| 205 | 208 |
| 206 private: | 209 private: |
| 207 ThreadIdentifier m_threadId; | 210 ThreadIdentifier m_threadId; |
| 208 #endif | 211 #endif |
| 209 }; | 212 }; |
| 210 | 213 |
| 211 template<typename T> | 214 template<typename T> |
| 212 class HeapSupplement : public SupplementBase<T, true> { }; | 215 class HeapSupplement : public SupplementBase<T, true> { }; |
| 213 | 216 |
| 214 // FIXME: Oilpan: Move GarbageCollectedMixin to SupplementableBase<T, true> once
PersistentHeapSupplementable is removed again. | 217 // FIXME: Oilpan: Move GarbageCollectedMixin to SupplementableBase<T, true> once
PersistentHeapSupplementable is removed again. |
| 215 template<typename T> | 218 template<typename T> |
| 216 class HeapSupplementable : public SupplementableBase<T, true>, public GarbageCol
lectedMixin { }; | 219 class HeapSupplementable : public SupplementableBase<T, true>, public GarbageCol
lectedMixin { }; |
| 217 | 220 |
| 218 template<typename T> | 221 template<typename T> |
| 219 class PersistentHeapSupplementable : public SupplementableBase<T, true> { | 222 class PersistentHeapSupplementable : public SupplementableBase<T, true> { |
| 220 public: | 223 public: |
| 221 PersistentHeapSupplementable() : m_root(this) { } | 224 PersistentHeapSupplementable() : m_root(this) { } |
| 225 virtual ~PersistentHeapSupplementable() |
| 226 { |
| 227 typedef typename SupplementableTraits<T, true>::SupplementMap::iterator
SupplementIterator; |
| 228 for (SupplementIterator it = this->m_supplements.begin(); it != this->m_
supplements.end(); ++it) |
| 229 it->value->persistentHostHasBeenDestroyed(); |
| 230 } |
| 222 private: | 231 private: |
| 223 class TraceDelegate : PersistentBase<ThreadLocalPersistents<AnyThread>, Trac
eDelegate> { | 232 class TraceDelegate : PersistentBase<ThreadLocalPersistents<AnyThread>, Trac
eDelegate> { |
| 224 public: | 233 public: |
| 225 TraceDelegate(PersistentHeapSupplementable* owner) : m_owner(owner) { } | 234 TraceDelegate(PersistentHeapSupplementable* owner) : m_owner(owner) { } |
| 226 void trace(Visitor* visitor) { m_owner->trace(visitor); } | 235 void trace(Visitor* visitor) { m_owner->trace(visitor); } |
| 227 private: | 236 private: |
| 228 PersistentHeapSupplementable* m_owner; | 237 PersistentHeapSupplementable* m_owner; |
| 229 }; | 238 }; |
| 230 | 239 |
| 231 TraceDelegate m_root; | 240 TraceDelegate m_root; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 243 }; | 252 }; |
| 244 | 253 |
| 245 template<typename T> | 254 template<typename T> |
| 246 struct ThreadingTrait<WebCore::SupplementableBase<T, true> > { | 255 struct ThreadingTrait<WebCore::SupplementableBase<T, true> > { |
| 247 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; | 256 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; |
| 248 }; | 257 }; |
| 249 | 258 |
| 250 } // namespace WebCore | 259 } // namespace WebCore |
| 251 | 260 |
| 252 #endif // Supplementable_h | 261 #endif // Supplementable_h |
| OLD | NEW |