Chromium Code Reviews| Index: third_party/WebKit/Source/platform/heap/Persistent.h |
| diff --git a/third_party/WebKit/Source/platform/heap/Persistent.h b/third_party/WebKit/Source/platform/heap/Persistent.h |
| index cf48b4999cb220e2d1de7bad996087414fd7474d..61fe73d0deecc7c26d959875b5408e64fa28e916 100644 |
| --- a/third_party/WebKit/Source/platform/heap/Persistent.h |
| +++ b/third_party/WebKit/Source/platform/heap/Persistent.h |
| @@ -640,32 +640,6 @@ public: |
| } |
| }; |
| -// Only a very reduced form of weak heap object references can currently be held |
| -// by WTF::Closure<>s. i.e., bound as a 'this' pointer only. |
| -// |
| -// TODO(sof): once wtf/Functional.h is able to work over platform/heap/ types |
| -// (like CrossThreadWeakPersistent<>), drop the restriction on weak persistent |
| -// use by function closures (and rename this ad-hoc type.) |
| -template<typename T> |
| -class WeakPersistentThisPointer { |
| - STACK_ALLOCATED(); |
| -public: |
| - explicit WeakPersistentThisPointer(T* value) : m_value(value) { } |
| - WeakPersistent<T> value() const { return m_value; } |
| -private: |
| - WeakPersistent<T> m_value; |
| -}; |
| - |
| -template<typename T> |
| -class CrossThreadWeakPersistentThisPointer { |
| - STACK_ALLOCATED(); |
| -public: |
| - explicit CrossThreadWeakPersistentThisPointer(T* value) : m_value(value) { } |
| - CrossThreadWeakPersistent<T> value() const { return m_value; } |
| -private: |
| - CrossThreadWeakPersistent<T> m_value; |
| -}; |
| - |
| template <typename T> |
| Persistent<T> wrapPersistent(T* value) |
| { |
| @@ -673,11 +647,23 @@ Persistent<T> wrapPersistent(T* value) |
| } |
| template <typename T> |
| +WeakPersistent<T> wrapWeakPersistent(T* value) |
| +{ |
| + return WeakPersistent<T>(value); |
| +} |
| + |
| +template <typename T> |
| CrossThreadPersistent<T> wrapCrossThreadPersistent(T* value) |
| { |
| return CrossThreadPersistent<T>(value); |
| } |
| +template <typename T> |
| +CrossThreadWeakPersistent<T> wrapCrossThreadWeakPersistent(T* value) |
| +{ |
| + return CrossThreadWeakPersistent<T>(value); |
| +} |
| + |
| // Comparison operators between (Weak)Members, Persistents, and UntracedMembers. |
| template<typename T, typename U> inline bool operator==(const Member<T>& a, const Member<U>& b) { return a.get() == b.get(); } |
| template<typename T, typename U> inline bool operator!=(const Member<T>& a, const Member<U>& b) { return a.get() != b.get(); } |
| @@ -717,38 +703,17 @@ struct DefaultHash<blink::CrossThreadWeakPersistent<T>> { |
| using Hash = MemberHash<T>; |
| }; |
| -template<typename T> |
| -struct ParamStorageTraits<blink::WeakPersistentThisPointer<T>> { |
| - STATIC_ONLY(ParamStorageTraits); |
| - static_assert(sizeof(T), "T must be fully defined"); |
| - using StorageType = blink::WeakPersistent<T>; |
| - |
| - static StorageType wrap(const blink::WeakPersistentThisPointer<T>& value) { return value.value(); } |
| +} // namespace WTF |
| - // WTF::FunctionWrapper<> handles WeakPtr<>, so recast this weak persistent |
| - // into it. |
| - // |
| - // TODO(sof): remove this hack once wtf/Functional.h can also work with a type like |
| - // WeakPersistent<>. |
| - static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakReference<T>::create(value.get())); } |
| -}; |
| +namespace base { |
| -template<typename T> |
| -struct ParamStorageTraits<blink::CrossThreadWeakPersistentThisPointer<T>> { |
| - STATIC_ONLY(ParamStorageTraits); |
| - static_assert(sizeof(T), "T must be fully defined"); |
| - using StorageType = blink::CrossThreadWeakPersistent<T>; |
| +template <typename T> |
| +struct IsWeakReceiver<blink::WeakPersistent<T>> : std::true_type {}; |
|
sof
2016/06/24 08:56:02
It would be good to have (HeapTest) unit tests for
tzik
2016/06/24 09:41:41
Done.
|
| - static StorageType wrap(const blink::CrossThreadWeakPersistentThisPointer<T>& value) { return value.value(); } |
| +template <typename T> |
| +struct IsWeakReceiver<blink::CrossThreadWeakPersistent<T>> : std::true_type {}; |
| - // WTF::FunctionWrapper<> handles WeakPtr<>, so recast this weak persistent |
| - // into it. |
| - // |
| - // TODO(sof): remove this hack once wtf/Functional.h can also work with a type like |
| - // CrossThreadWeakPersistent<>. |
| - static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakReference<T>::create(value.get())); } |
| -}; |
| +} |
| -} // namespace WTF |
| #endif // Persistent_h |