Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: Source/platform/heap/Handle.h

Issue 319593004: Oilpan:Allow custom handling of classes that contain weak pointers that are embedded in collections. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove 'typename' that Win compiler does not like Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/platform/heap/Heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 operator PassRefPtr<U>() { return PassRefPtr<U>(m_raw); } 602 operator PassRefPtr<U>() { return PassRefPtr<U>(m_raw); }
603 603
604 protected: 604 protected:
605 void verifyTypeIsGarbageCollected() const 605 void verifyTypeIsGarbageCollected() const
606 { 606 {
607 COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInMember ); 607 COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInMember );
608 } 608 }
609 609
610 T* m_raw; 610 T* m_raw;
611 611
612 template<bool x, bool y, ShouldWeakPointersBeMarkedStrongly z, typename U, t ypename V> friend struct CollectionBackingTraceTrait; 612 template<bool x, WTF::WeakHandlingFlag y, ShouldWeakPointersBeMarkedStrongly z, typename U, typename V> friend struct CollectionBackingTraceTrait;
613 friend class Visitor; 613 friend class Visitor;
614 }; 614 };
615 615
616 template<typename T> 616 template<typename T>
617 class TraceTrait<Member<T> > { 617 class TraceTrait<Member<T> > {
618 public: 618 public:
619 static void trace(Visitor* visitor, void* self) 619 static void trace(Visitor* visitor, void* self)
620 { 620 {
621 TraceTrait<T>::mark(visitor, *static_cast<Member<T>*>(self)); 621 TraceTrait<T>::mark(visitor, *static_cast<Member<T>*>(self));
622 } 622 }
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 // FIXME: Similarly, there is no need for a distinction between PeekOutType 1035 // FIXME: Similarly, there is no need for a distinction between PeekOutType
1036 // and PassOutType without reference counting. 1036 // and PassOutType without reference counting.
1037 typedef T* PeekOutType; 1037 typedef T* PeekOutType;
1038 typedef T* PassOutType; 1038 typedef T* PassOutType;
1039 1039
1040 template<typename U> 1040 template<typename U>
1041 static void store(const U& value, WebCore::WeakMember<T>& storage) { storage = value; } 1041 static void store(const U& value, WebCore::WeakMember<T>& storage) { storage = value; }
1042 1042
1043 static PeekOutType peek(const WebCore::WeakMember<T>& value) { return value; } 1043 static PeekOutType peek(const WebCore::WeakMember<T>& value) { return value; }
1044 static PassOutType passOut(const WebCore::WeakMember<T>& value) { return val ue; } 1044 static PassOutType passOut(const WebCore::WeakMember<T>& value) { return val ue; }
1045 static bool shouldRemoveFromCollection(WebCore::Visitor* visitor, WebCore::W eakMember<T>& value) { return !visitor->isAlive(value); }
1046 static void traceInCollection(WebCore::Visitor* visitor, WebCore::WeakMember <T>& weakMember, WebCore::ShouldWeakPointersBeMarkedStrongly strongify)
1047 {
1048 if (strongify == WebCore::WeakPointersActStrong)
1049 visitor->trace(reinterpret_cast<WebCore::Member<T>&>(weakMember)); / / Strongified visit.
1050 }
1045 }; 1051 };
1046 1052
1047 template<typename T> struct PtrHash<WebCore::Member<T> > : PtrHash<T*> { 1053 template<typename T> struct PtrHash<WebCore::Member<T> > : PtrHash<T*> {
1048 template<typename U> 1054 template<typename U>
1049 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } 1055 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); }
1050 static bool equal(T* a, const WebCore::Member<T>& b) { return a == b; } 1056 static bool equal(T* a, const WebCore::Member<T>& b) { return a == b; }
1051 static bool equal(const WebCore::Member<T>& a, T* b) { return a == b; } 1057 static bool equal(const WebCore::Member<T>& a, T* b) { return a == b; }
1052 template<typename U, typename V> 1058 template<typename U, typename V>
1053 static bool equal(const U& a, const V& b) { return a == b; } 1059 static bool equal(const U& a, const V& b) { return a == b; }
1054 }; 1060 };
(...skipping 26 matching lines...) Expand all
1081 template<typename T> 1087 template<typename T>
1082 struct NeedsTracing<WebCore::Member<T> > { 1088 struct NeedsTracing<WebCore::Member<T> > {
1083 static const bool value = true; 1089 static const bool value = true;
1084 }; 1090 };
1085 1091
1086 template<typename T> 1092 template<typename T>
1087 struct IsWeak<WebCore::WeakMember<T> > { 1093 struct IsWeak<WebCore::WeakMember<T> > {
1088 static const bool value = true; 1094 static const bool value = true;
1089 }; 1095 };
1090 1096
1091 template<typename Table>
1092 struct IsWeak<WebCore::HeapHashTableBacking<Table> > {
1093 static const bool value = Table::ValueTraits::isWeak;
1094 };
1095
1096 template<typename T> inline T* getPtr(const WebCore::Member<T>& p) 1097 template<typename T> inline T* getPtr(const WebCore::Member<T>& p)
1097 { 1098 {
1098 return p.get(); 1099 return p.get();
1099 } 1100 }
1100 1101
1101 template<typename T, typename U> 1102 template<typename T, typename U>
1102 struct NeedsTracing<std::pair<T, U> > { 1103 struct NeedsTracing<std::pair<T, U> > {
1103 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value; 1104 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value;
1104 }; 1105 };
1105 1106
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 template<typename T> struct ParamStorageTraits<RawPtr<T> > { 1180 template<typename T> struct ParamStorageTraits<RawPtr<T> > {
1180 typedef WebCore::CrossThreadPersistent<T> StorageType; 1181 typedef WebCore::CrossThreadPersistent<T> StorageType;
1181 1182
1182 static StorageType wrap(RawPtr<T> value) { return value.get(); } 1183 static StorageType wrap(RawPtr<T> value) { return value.get(); }
1183 static T* unwrap(const StorageType& value) { return value.get(); } 1184 static T* unwrap(const StorageType& value) { return value.get(); }
1184 }; 1185 };
1185 1186
1186 } // namespace WTF 1187 } // namespace WTF
1187 1188
1188 #endif 1189 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698