Index: Source/platform/heap/Handle.h |
diff --git a/Source/platform/heap/Handle.h b/Source/platform/heap/Handle.h |
index 39046ada559b1e6a46e7c7d15ea4baa19a7743dc..5c7c4c68cbd111828faf1d926a5ee22bece309ad 100644 |
--- a/Source/platform/heap/Handle.h |
+++ b/Source/platform/heap/Handle.h |
@@ -991,6 +991,16 @@ private: |
OwnPtr<Persistent<Self>> m_keepAlive; |
}; |
+template<typename T> |
+class AllowCrossThreadWeakPersistent { |
+ STACK_ALLOCATED(); |
+public: |
+ explicit AllowCrossThreadWeakPersistent(T* value) : m_value(value) { } |
+ CrossThreadWeakPersistent<T> value() const { return m_value; } |
haraken
2015/09/03 23:39:33
Just to confirm: All call sites of value() are wri
sof
2015/09/04 05:21:04
No, doing so would require teaching wtf/Functional
haraken
2015/09/04 05:23:38
Makes sense.
sof
2015/09/04 06:50:20
Added a comment + TODO next to the relevant unwrap
|
+private: |
+ CrossThreadWeakPersistent<T> m_value; |
+}; |
+ |
} // namespace blink |
namespace WTF { |
@@ -1182,6 +1192,15 @@ struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin |
}; |
template<typename T> |
+struct ParamStorageTraits<blink::AllowCrossThreadWeakPersistent<T>> { |
+ static_assert(sizeof(T), "T must be fully defined"); |
+ using StorageType = blink::CrossThreadWeakPersistent<T>; |
+ |
+ static StorageType wrap(const blink::AllowCrossThreadWeakPersistent<T>& value) { return value.value(); } |
+ static T* unwrap(const StorageType& value) { return value.get(); } |
+}; |
+ |
+template<typename T> |
PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; |
} // namespace WTF |