| Index: third_party/WebKit/Source/platform/heap/Handle.h
|
| diff --git a/third_party/WebKit/Source/platform/heap/Handle.h b/third_party/WebKit/Source/platform/heap/Handle.h
|
| index 49d3f33e2e717c08c92c3d0f119052c99b777240..2d13ec28386c20ab95e99039aa8605963437d981 100644
|
| --- a/third_party/WebKit/Source/platform/heap/Handle.h
|
| +++ b/third_party/WebKit/Source/platform/heap/Handle.h
|
| @@ -1299,11 +1299,17 @@ private:
|
| Persistent<Self> m_keepAlive;
|
| };
|
|
|
| +// 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 AllowCrossThreadWeakPersistent {
|
| +class CrossThreadWeakPersistentThisPointer {
|
| STACK_ALLOCATED();
|
| public:
|
| - explicit AllowCrossThreadWeakPersistent(T* value) : m_value(value) { }
|
| + explicit CrossThreadWeakPersistentThisPointer(T* value) : m_value(value) { }
|
| CrossThreadWeakPersistent<T> value() const { return m_value; }
|
| private:
|
| CrossThreadWeakPersistent<T> m_value;
|
| @@ -1569,15 +1575,18 @@ struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin
|
| };
|
|
|
| template<typename T>
|
| -struct ParamStorageTraits<blink::AllowCrossThreadWeakPersistent<T>> {
|
| +struct ParamStorageTraits<blink::CrossThreadWeakPersistentThisPointer<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 StorageType wrap(const blink::CrossThreadWeakPersistentThisPointer<T>& value) { return value.value(); }
|
|
|
| - // Currently assume that the call sites of this unwrap() account for cleared weak references also.
|
| - // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (CrossThread)WeakPersistent.
|
| - static T* unwrap(const StorageType& value) { return value.get(); }
|
| + // 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())); }
|
| };
|
|
|
| template<typename T>
|
|
|