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

Unified Diff: third_party/WebKit/Source/platform/heap/HeapAllocator.h

Issue 2007283002: Allow CrossThreadPersistent in collections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/heap/HeapAllocator.h
diff --git a/third_party/WebKit/Source/platform/heap/HeapAllocator.h b/third_party/WebKit/Source/platform/heap/HeapAllocator.h
index 40e0d381d90225e8c4bdae2271e9e72bf48ae07b..2c1cf3547e56e0c45d3a4a3d72f893d7db83e322 100644
--- a/third_party/WebKit/Source/platform/heap/HeapAllocator.h
+++ b/third_party/WebKit/Source/platform/heap/HeapAllocator.h
@@ -6,6 +6,7 @@
#define HeapAllocator_h
#include "platform/heap/Heap.h"
+#include "platform/heap/Persistent.h"
#include "platform/heap/TraceTraits.h"
#include "wtf/Allocator.h"
#include "wtf/Assertions.h"
@@ -422,6 +423,16 @@ template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTrai
static const bool canMoveWithMemcpy = true;
};
+template <typename T, blink::WeaknessPersistentConfiguration weaknessConfiguration, blink::CrossThreadnessPersistentConfiguration crossThreadnessConfiguration>
+struct VectorTraits<blink::PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>>
+ : VectorTraitsBase<blink::PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>> {
+ STATIC_ONLY(VectorTraits);
+ static const bool needsDestruction = true;
+ static const bool canInitializeWithMemset = true;
+ static const bool canClearUnusedSlotsWithMemset = false;
+ static const bool canMoveWithMemcpy = true;
+};
+
template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTraitsBase<blink::HeapVector<T, 0>> {
STATIC_ONLY(VectorTraits);
static const bool needsDestruction = false;
@@ -454,53 +465,35 @@ template <typename T, size_t inlineCapacity> struct VectorTraits<blink::HeapDequ
static const bool canMoveWithMemcpy = VectorTraits<T>::canMoveWithMemcpy;
};
-template<typename T> struct HashTraits<blink::Member<T>> : SimpleClassHashTraits<blink::Member<T>> {
- STATIC_ONLY(HashTraits);
- // FIXME: The distinction between PeekInType and PassInType is there for
+template<typename T, typename H> struct HandleHashTraits : SimpleClassHashTraits<H> {
+ STATIC_ONLY(HandleHashTraits);
+ // TODO: The distinction between PeekInType and PassInType is there for
// the sake of the reference counting handles. When they are gone the two
// types can be merged into PassInType.
- // FIXME: Implement proper const'ness for iterator types. Requires support
+ // TODO: Implement proper const'ness for iterator types. Requires support
// in the marking Visitor.
using PeekInType = T*;
using PassInType = T*;
- using IteratorGetType = blink::Member<T>*;
- using IteratorConstGetType = const blink::Member<T>*;
- using IteratorReferenceType = blink::Member<T>&;
- using IteratorConstReferenceType = const blink::Member<T>&;
+ using IteratorGetType = H*;
+ using IteratorConstGetType = const H*;
+ using IteratorReferenceType = H&;
+ using IteratorConstReferenceType = const H&;
static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { return *x; }
static IteratorConstReferenceType getToReferenceConstConversion(IteratorConstGetType x) { return *x; }
using PeekOutType = T*;
template<typename U>
- static void store(const U& value, blink::Member<T>& storage) { storage = value; }
+ static void store(const U& value, H& storage) { storage = value; }
- static PeekOutType peek(const blink::Member<T>& value) { return value; }
+ static PeekOutType peek(const H& value) { return value; }
};
-template<typename T> struct HashTraits<blink::WeakMember<T>> : SimpleClassHashTraits<blink::WeakMember<T>> {
+template<typename T> struct HashTraits<blink::Member<T>> : HandleHashTraits<T, blink::Member<T>> { };
+
+template<typename T> struct HashTraits<blink::WeakMember<T>> : HandleHashTraits<T, blink::WeakMember<T>> {
STATIC_ONLY(HashTraits);
static const bool needsDestruction = false;
- // FIXME: The distinction between PeekInType and PassInType is there for
- // the sake of the reference counting handles. When they are gone the two
- // types can be merged into PassInType.
- // FIXME: Implement proper const'ness for iterator types. Requires support
- // in the marking Visitor.
- using PeekInType = T*;
- using PassInType = T*;
- using IteratorGetType = blink::WeakMember<T>*;
- using IteratorConstGetType = const blink::WeakMember<T>*;
- using IteratorReferenceType = blink::WeakMember<T>&;
- using IteratorConstReferenceType = const blink::WeakMember<T>&;
- static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { return *x; }
- static IteratorConstReferenceType getToReferenceConstConversion(IteratorConstGetType x) { return *x; }
-
- using PeekOutType = T*;
-
- template<typename U>
- static void store(const U& value, blink::WeakMember<T>& storage) { storage = value; }
-
- static PeekOutType peek(const blink::WeakMember<T>& value) { return value; }
template<typename VisitorDispatcher>
static bool traceInCollection(VisitorDispatcher visitor, blink::WeakMember<T>& weakMember, ShouldWeakPointersBeMarkedStrongly strongify)
@@ -513,27 +506,9 @@ template<typename T> struct HashTraits<blink::WeakMember<T>> : SimpleClassHashTr
}
};
-template<typename T> struct HashTraits<blink::UntracedMember<T>> : SimpleClassHashTraits<blink::UntracedMember<T>> {
+template<typename T> struct HashTraits<blink::UntracedMember<T>> : HandleHashTraits<T, blink::UntracedMember<T>> {
STATIC_ONLY(HashTraits);
static const bool needsDestruction = false;
- // FIXME: The distinction between PeekInType and PassInType is there for
- // the sake of the reference counting handles. When they are gone the two
- // types can be merged into PassInType.
- // FIXME: Implement proper const'ness for iterator types.
- using PeekInType = T*;
- using PassInType = T*;
- using IteratorGetType = blink::UntracedMember<T>*;
- using IteratorConstGetType = const blink::UntracedMember<T>*;
- using IteratorReferenceType = blink::UntracedMember<T>&;
- using IteratorConstReferenceType = const blink::UntracedMember<T>&;
- static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { return *x; }
- static IteratorConstReferenceType getToReferenceConstConversion(IteratorConstGetType x) { return *x; }
- using PeekOutType = T*;
-
- template<typename U>
- static void store(const U& value, blink::UntracedMember<T>& storage) { storage = value; }
-
- static PeekOutType peek(const blink::UntracedMember<T>& value) { return value; }
};
template<typename T, size_t inlineCapacity>
@@ -551,6 +526,10 @@ struct IsGarbageCollectedType<ListHashSetNode<T, blink::HeapListHashSetAllocator
static const bool value = true;
};
+template<typename T> struct HashTraits<blink::Persistent<T>> : HandleHashTraits<T, blink::Persistent<T>> { };
+
+template<typename T> struct HashTraits<blink::CrossThreadPersistent<T>> : HandleHashTraits<T, blink::CrossThreadPersistent<T>> { };
+
} // namespace WTF
#endif

Powered by Google App Engine
This is Rietveld 408576698