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

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

Issue 1573283004: Oilpan: provide a weak 'this' pointer abstraction for cancellable closures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments + TODOs Created 4 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698