OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 | 382 |
383 template<typename T> | 383 template<typename T> |
384 class TraceTrait<Member<T> > { | 384 class TraceTrait<Member<T> > { |
385 public: | 385 public: |
386 static void trace(Visitor* visitor, void* self) | 386 static void trace(Visitor* visitor, void* self) |
387 { | 387 { |
388 TraceTrait<T>::mark(visitor, *static_cast<Member<T>*>(self)); | 388 TraceTrait<T>::mark(visitor, *static_cast<Member<T>*>(self)); |
389 } | 389 } |
390 }; | 390 }; |
391 | 391 |
392 // TraceTrait to allow compilation of trace method bodies when oilpan is disable d. | |
393 // This should never be called, but is needed to compile. | |
394 template<typename T> | |
395 class TraceTrait<RefPtr<T> > { | |
396 public: | |
397 static void trace(Visitor*, void*) | |
398 { | |
399 ASSERT_NOT_REACHED(); | |
zerny-chromium
2014/02/13 07:02:28
As you pointed out, this might not always be true
| |
400 } | |
401 }; | |
402 | |
392 // WeakMember is similar to Member in that it is used to point to other oilpan | 403 // WeakMember is similar to Member in that it is used to point to other oilpan |
393 // heap allocated objects. | 404 // heap allocated objects. |
394 // However instead of creating a strong pointer to the object, the WeakMember cr eates | 405 // However instead of creating a strong pointer to the object, the WeakMember cr eates |
395 // a weak pointer, which does not keep the pointee alive. Hence if all pointers to | 406 // a weak pointer, which does not keep the pointee alive. Hence if all pointers to |
396 // to a heap allocated object are weak the object will be garbage collected. At the | 407 // to a heap allocated object are weak the object will be garbage collected. At the |
397 // time of GC the weak pointers will automatically be set to null. | 408 // time of GC the weak pointers will automatically be set to null. |
398 template<typename T> | 409 template<typename T> |
399 class WeakMember : public Member<T> { | 410 class WeakMember : public Member<T> { |
400 public: | 411 public: |
401 WeakMember() : Member<T>() { } | 412 WeakMember() : Member<T>() { } |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 template<typename T> | 778 template<typename T> |
768 struct IsWeak<WebCore::WeakMember<T> > { | 779 struct IsWeak<WebCore::WeakMember<T> > { |
769 static const bool value = true; | 780 static const bool value = true; |
770 }; | 781 }; |
771 | 782 |
772 template<typename Key, typename Value, typename Extractor, typename Traits, type name KeyTraits> | 783 template<typename Key, typename Value, typename Extractor, typename Traits, type name KeyTraits> |
773 struct IsWeak<WebCore::HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTr aits> > { | 784 struct IsWeak<WebCore::HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTr aits> > { |
774 static const bool value = Traits::isWeak; | 785 static const bool value = Traits::isWeak; |
775 }; | 786 }; |
776 | 787 |
788 template<typename T> inline T* getPtr(const WebCore::Member<T>& p) | |
789 { | |
790 return p.get(); | |
791 } | |
792 | |
777 } // namespace WTF | 793 } // namespace WTF |
778 | 794 |
779 #endif | 795 #endif |
OLD | NEW |