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

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

Issue 1312843009: Improve CancellableTaskFactory handling and Oilpan usage. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add unwrap() clarification Created 5 years, 3 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 | « Source/core/html/parser/HTMLParserScheduler.cpp ('k') | Source/platform/scheduler/CancellableTaskFactory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Handle.h
diff --git a/Source/platform/heap/Handle.h b/Source/platform/heap/Handle.h
index 39046ada559b1e6a46e7c7d15ea4baa19a7743dc..9a2b182c15acd852b73c01cfc133349000fc5408 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; }
+private:
+ CrossThreadWeakPersistent<T> m_value;
+};
+
} // namespace blink
namespace WTF {
@@ -1182,6 +1192,18 @@ 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(); }
+
+ // 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(); }
+};
+
+template<typename T>
PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete;
} // namespace WTF
« no previous file with comments | « Source/core/html/parser/HTMLParserScheduler.cpp ('k') | Source/platform/scheduler/CancellableTaskFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698