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 23 matching lines...) Expand all Loading... |
34 #include "platform/heap/Heap.h" | 34 #include "platform/heap/Heap.h" |
35 #include "platform/heap/HeapAllocator.h" | 35 #include "platform/heap/HeapAllocator.h" |
36 #include "platform/heap/InlinedGlobalMarkingVisitor.h" | 36 #include "platform/heap/InlinedGlobalMarkingVisitor.h" |
37 #include "platform/heap/PersistentNode.h" | 37 #include "platform/heap/PersistentNode.h" |
38 #include "platform/heap/ThreadState.h" | 38 #include "platform/heap/ThreadState.h" |
39 #include "platform/heap/TraceTraits.h" | 39 #include "platform/heap/TraceTraits.h" |
40 #include "platform/heap/Visitor.h" | 40 #include "platform/heap/Visitor.h" |
41 #include "wtf/Allocator.h" | 41 #include "wtf/Allocator.h" |
42 #include "wtf/Atomics.h" | 42 #include "wtf/Atomics.h" |
43 #include "wtf/HashFunctions.h" | 43 #include "wtf/HashFunctions.h" |
44 #include "wtf/TypeTraits.h" | |
45 | 44 |
46 #if defined(LEAK_SANITIZER) | 45 #if defined(LEAK_SANITIZER) |
47 #include "wtf/LeakAnnotations.h" | 46 #include "wtf/LeakAnnotations.h" |
48 #endif | 47 #endif |
49 | 48 |
50 namespace blink { | 49 namespace blink { |
51 | 50 |
52 // Marker used to annotate persistent objects and collections with, | 51 // Marker used to annotate persistent objects and collections with, |
53 // so as to enable reliable testing for persistent references via | 52 // so as to enable reliable testing for persistent references via |
54 // a type trait (see TypeTraits.h's IsPersistentReferenceType<>.) | 53 // a type trait (see TypeTraits.h's IsPersistentReferenceType<>.) |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 STATIC_ONLY(NeedsTracing); | 1151 STATIC_ONLY(NeedsTracing); |
1153 static const bool value = true; | 1152 static const bool value = true; |
1154 }; | 1153 }; |
1155 | 1154 |
1156 template<typename T> | 1155 template<typename T> |
1157 struct IsWeak<blink::WeakMember<T>> { | 1156 struct IsWeak<blink::WeakMember<T>> { |
1158 STATIC_ONLY(IsWeak); | 1157 STATIC_ONLY(IsWeak); |
1159 static const bool value = true; | 1158 static const bool value = true; |
1160 }; | 1159 }; |
1161 | 1160 |
1162 // For wtf/Functional.h | |
1163 template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits; | |
1164 | |
1165 // The condition of 'T must be fully defined' (except for void) is checked in | |
1166 // blink::IsGarbageCollectedType<T>::value. | |
1167 template<typename T> | |
1168 struct PointerParamStorageTraits<T*, false> { | |
1169 STATIC_ONLY(PointerParamStorageTraits); | |
1170 using StorageType = T*; | |
1171 | |
1172 static StorageType wrap(T* value) { return value; } | |
1173 static T* unwrap(const StorageType& value) { return value; } | |
1174 }; | |
1175 | |
1176 template<typename T> | |
1177 struct PointerParamStorageTraits<T*, true> { | |
1178 STATIC_ONLY(PointerParamStorageTraits); | |
1179 using StorageType = blink::CrossThreadPersistent<T>; | |
1180 | |
1181 static StorageType wrap(T* value) { return value; } | |
1182 static T* unwrap(const StorageType& value) { return value.get(); } | |
1183 }; | |
1184 | |
1185 template<typename T> | |
1186 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGa
rbageCollectedType<T>::value> { | |
1187 STATIC_ONLY(ParamStorageTraits); | |
1188 }; | |
1189 | |
1190 template<typename T> | 1161 template<typename T> |
1191 struct ParamStorageTraits<blink::WeakPersistentThisPointer<T>> { | 1162 struct ParamStorageTraits<blink::WeakPersistentThisPointer<T>> { |
1192 STATIC_ONLY(ParamStorageTraits); | 1163 STATIC_ONLY(ParamStorageTraits); |
1193 static_assert(sizeof(T), "T must be fully defined"); | 1164 static_assert(sizeof(T), "T must be fully defined"); |
1194 using StorageType = blink::WeakPersistent<T>; | 1165 using StorageType = blink::WeakPersistent<T>; |
1195 | 1166 |
1196 static StorageType wrap(const blink::WeakPersistentThisPointer<T>& value) {
return value.value(); } | 1167 static StorageType wrap(const blink::WeakPersistentThisPointer<T>& value) {
return value.value(); } |
1197 | 1168 |
1198 // WTF::FunctionWrapper<> handles WeakPtr<>, so recast this weak persistent | 1169 // WTF::FunctionWrapper<> handles WeakPtr<>, so recast this weak persistent |
1199 // into it. | 1170 // into it. |
(...skipping 15 matching lines...) Expand all Loading... |
1215 // into it. | 1186 // into it. |
1216 // | 1187 // |
1217 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like | 1188 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like |
1218 // CrossThreadWeakPersistent<>. | 1189 // CrossThreadWeakPersistent<>. |
1219 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } | 1190 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } |
1220 }; | 1191 }; |
1221 | 1192 |
1222 } // namespace WTF | 1193 } // namespace WTF |
1223 | 1194 |
1224 #endif | 1195 #endif |
OLD | NEW |