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

Unified Diff: third_party/WebKit/Source/wtf/Functional.h

Issue 2000673003: Split out Members, Persistents and SelfKeepAlive in separate headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Phase out blink::IsGarbageCollectedType<T> Created 4 years, 7 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 | « third_party/WebKit/Source/web/WebRemoteFrameImpl.h ('k') | third_party/WebKit/Source/wtf/TypeTraits.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/Functional.h
diff --git a/third_party/WebKit/Source/wtf/Functional.h b/third_party/WebKit/Source/wtf/Functional.h
index de82d7dc1d98b2315fdbce6b9530e62d9b89e719..fab1abfd5862d205b0c6c703e22957954f23754e 100644
--- a/third_party/WebKit/Source/wtf/Functional.h
+++ b/third_party/WebKit/Source/wtf/Functional.h
@@ -38,6 +38,10 @@
#include <tuple>
#include <utility>
+namespace blink {
+template<typename T> class CrossThreadPersistent;
+}
+
namespace WTF {
// Functional.h provides a very simple way to bind a function pointer and arguments together into a function object
@@ -232,6 +236,31 @@ struct ParamStorageTraits<PassedWrapper<T>> {
static T unwrap(StorageType& value) { return value.moveOut(); }
};
+template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits;
+
+template<typename T>
+struct PointerParamStorageTraits<T*, false> {
+ STATIC_ONLY(PointerParamStorageTraits);
+ using StorageType = T*;
+
+ static StorageType wrap(T* value) { return value; }
+ static T* unwrap(const StorageType& value) { return value; }
+};
+
+template<typename T>
+struct PointerParamStorageTraits<T*, true> {
+ STATIC_ONLY(PointerParamStorageTraits);
+ using StorageType = blink::CrossThreadPersistent<T>;
+
+ static StorageType wrap(T* value) { return value; }
+ static T* unwrap(const StorageType& value) { return value.get(); }
+};
+
+template<typename T>
+struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, IsGarbageCollectedType<T>::value> {
+ STATIC_ONLY(ParamStorageTraits);
+};
+
enum FunctionThreadAffinity {
CrossThreadAffinity,
SameThreadAffinity
« no previous file with comments | « third_party/WebKit/Source/web/WebRemoteFrameImpl.h ('k') | third_party/WebKit/Source/wtf/TypeTraits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698