| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ENABLE(ASSERT) | 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); } | |
| 192 | |
| 193 void willBeDestroyed() | 191 void willBeDestroyed() |
| 194 { | 192 { |
| 195 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement
Map::iterator SupplementIterator; | 193 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement
Map::iterator SupplementIterator; |
| 196 for (SupplementIterator it = m_supplements.begin(); it != m_supplements.
end(); ++it) | 194 for (SupplementIterator it = m_supplements.begin(); it != m_supplements.
end(); ++it) |
| 197 it->value->willBeDestroyed(); | 195 it->value->willBeDestroyed(); |
| 198 } | 196 } |
| 199 | 197 |
| 200 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup
plementable is removed again. | 198 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup
plementable is removed again. |
| 201 protected: | 199 protected: |
| 202 GC_PLUGIN_IGNORE("") | 200 GC_PLUGIN_IGNORE("") |
| 203 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple
ments; | 201 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple
ments; |
| 204 | 202 |
| 205 #if ENABLE(ASSERT) | 203 #if ENABLE(ASSERT) |
| 206 protected: | 204 protected: |
| 207 SupplementableBase() : m_threadId(currentThread()) { } | 205 SupplementableBase() : m_threadId(currentThread()) { } |
| 208 | 206 |
| 209 private: | 207 private: |
| 210 ThreadIdentifier m_threadId; | 208 ThreadIdentifier m_threadId; |
| 211 #endif | 209 #endif |
| 212 }; | 210 }; |
| 213 | 211 |
| 214 template<typename T> | 212 template<typename T> |
| 215 class HeapSupplement : public SupplementBase<T, true> { }; | 213 class HeapSupplement : public SupplementBase<T, true> { }; |
| 216 | 214 |
| 217 // FIXME: Oilpan: Move GarbageCollectedMixin to SupplementableBase<T, true> once
PersistentHeapSupplementable is removed again. | 215 // FIXME: Oilpan: Move GarbageCollectedMixin to SupplementableBase<T, true> once
PersistentHeapSupplementable is removed again. |
| 218 template<typename T> | 216 template<typename T> |
| 219 class GC_PLUGIN_IGNORE("http://crbug.com/395036") HeapSupplementable : public Su
pplementableBase<T, true>, public GarbageCollectedMixin { | 217 class HeapSupplementable : public SupplementableBase<T, true>, public GarbageCol
lectedMixin { |
| 220 public: | 218 public: |
| 221 virtual void trace(Visitor* visitor) { SupplementableBase<T, true>::trace(vi
sitor); } | 219 virtual void trace(Visitor* visitor) OVERRIDE { visitor->trace(this->m_suppl
ements); } |
| 222 }; | 220 }; |
| 223 | 221 |
| 224 template<typename T> | 222 template<typename T> |
| 225 class PersistentHeapSupplementable : public SupplementableBase<T, true> { | 223 class PersistentHeapSupplementable : public SupplementableBase<T, true> { |
| 226 public: | 224 public: |
| 227 PersistentHeapSupplementable() : m_root(this) { } | 225 PersistentHeapSupplementable() : m_root(this) { } |
| 228 virtual ~PersistentHeapSupplementable() | 226 virtual ~PersistentHeapSupplementable() |
| 229 { | 227 { |
| 230 typedef typename SupplementableTraits<T, true>::SupplementMap::iterator
SupplementIterator; | 228 typedef typename SupplementableTraits<T, true>::SupplementMap::iterator
SupplementIterator; |
| 231 for (SupplementIterator it = this->m_supplements.begin(); it != this->m_
supplements.end(); ++it) | 229 for (SupplementIterator it = this->m_supplements.begin(); it != this->m_
supplements.end(); ++it) |
| 232 it->value->persistentHostHasBeenDestroyed(); | 230 it->value->persistentHostHasBeenDestroyed(); |
| 233 } | 231 } |
| 232 |
| 233 virtual void trace(Visitor* visitor) { visitor->trace(this->m_supplements);
} |
| 234 |
| 234 private: | 235 private: |
| 235 class TraceDelegate : PersistentBase<ThreadLocalPersistents<AnyThread>, Trac
eDelegate> { | 236 class TraceDelegate : PersistentBase<ThreadLocalPersistents<AnyThread>, Trac
eDelegate> { |
| 236 public: | 237 public: |
| 237 TraceDelegate(PersistentHeapSupplementable* owner) : m_owner(owner) { } | 238 TraceDelegate(PersistentHeapSupplementable* owner) : m_owner(owner) { } |
| 238 void trace(Visitor* visitor) { m_owner->trace(visitor); } | 239 void trace(Visitor* visitor) { m_owner->trace(visitor); } |
| 239 private: | 240 private: |
| 240 PersistentHeapSupplementable* m_owner; | 241 PersistentHeapSupplementable* m_owner; |
| 241 }; | 242 }; |
| 242 | 243 |
| 243 TraceDelegate m_root; | 244 TraceDelegate m_root; |
| 244 }; | 245 }; |
| 245 | 246 |
| 246 template<typename T> | 247 template<typename T> |
| 247 class Supplement : public SupplementBase<T, false> { }; | 248 class Supplement : public SupplementBase<T, false> { }; |
| 248 | 249 |
| 249 template<typename T> | 250 template<typename T> |
| 250 class Supplementable : public SupplementableBase<T, false> { }; | 251 class Supplementable : public SupplementableBase<T, false> { |
| 252 public: |
| 253 virtual void trace(Visitor*) |
| 254 { |
| 255 // No tracing of off-heap supplements. We should not have any Supplement
able |
| 256 // object on the heap. Either the object is HeapSupplementable or if it
is |
| 257 // off heap it should use PersistentHeapSupplementable to trace any on-h
eap |
| 258 // supplements. |
| 259 COMPILE_ASSERT(!IsGarbageCollectedType<T>::value, GarbageCollectedObject
MustBeHeapSupplementable); |
| 260 } |
| 261 }; |
| 251 | 262 |
| 252 template<typename T> | 263 template<typename T> |
| 253 struct ThreadingTrait<blink::SupplementBase<T, true> > { | 264 struct ThreadingTrait<blink::SupplementBase<T, true> > { |
| 254 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; | 265 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; |
| 255 }; | 266 }; |
| 256 | 267 |
| 257 template<typename T> | 268 template<typename T> |
| 258 struct ThreadingTrait<blink::SupplementableBase<T, true> > { | 269 struct ThreadingTrait<blink::SupplementableBase<T, true> > { |
| 259 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; | 270 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; |
| 260 }; | 271 }; |
| 261 | 272 |
| 262 } // namespace blink | 273 } // namespace blink |
| 263 | 274 |
| 264 #endif // Supplementable_h | 275 #endif // Supplementable_h |
| OLD | NEW |