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

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

Issue 1999343002: Unify and provide one IsGarbageCollectedType<T> implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit test 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/platform/heap/HeapTest.cpp ('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..694963ae2bbf6c31b8e9394669225d86d7af404f 100644
--- a/third_party/WebKit/Source/wtf/Functional.h
+++ b/third_party/WebKit/Source/wtf/Functional.h
@@ -34,10 +34,15 @@
#include "wtf/PtrUtil.h"
#include "wtf/RefPtr.h"
#include "wtf/ThreadSafeRefCounted.h"
+#include "wtf/TypeTraits.h"
#include "wtf/WeakPtr.h"
#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 +237,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/platform/heap/HeapTest.cpp ('k') | third_party/WebKit/Source/wtf/TypeTraits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698