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

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

Issue 2096623002: Update ParamStorageTraits to disallow raw pointers and Member<> (2/5) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@unretained
Patch Set: typo fix Created 4 years, 6 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 | no next file » | 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 3cfa5c133fb9824cec5cc89f3d2c2a7bb7c8678e..18be42ace56872ec3d235b15d9625a8011bdaa99 100644
--- a/third_party/WebKit/Source/wtf/Functional.h
+++ b/third_party/WebKit/Source/wtf/Functional.h
@@ -40,7 +40,8 @@
#include <utility>
namespace blink {
-template<typename T> class CrossThreadPersistent;
+template <typename T> class Member;
+template <typename T> class WeakMember;
}
namespace base {
@@ -216,6 +217,9 @@ template <typename T>
struct ParamStorageTraits {
typedef T StorageType;
+ static_assert(!std::is_pointer<T>::value, "Raw pointers are not allowed to bind into WTF::Function. Wrap it with either wrapPersistent, wrapWeakPersistent, wrapCrossThreadPersistent, wrapCrossThreadWeakPersistent, RefPtr or unretained.");
+ static_assert(!IsSubclassOfTemplate<T, blink::Member>::value && !IsSubclassOfTemplate<T, blink::WeakMember>::value, "Member and WeakMember are not allowed to bind into WTF::Function. Wrap it with either wrapPersistent, wrapWeakPersistent, wrapCrossThreadPersistent or wrapCrossThreadWeakPersistent.");
+
static StorageType wrap(const T& value) { return value; } // Copy.
static StorageType wrap(T&& value) { return std::move(value); }
@@ -265,31 +269,6 @@ struct ParamStorageTraits<UnretainedWrapper<T, threadAffinity>> {
static T* unwrap(const StorageType& value) { return value.value(); }
};
-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);
-};
-
template<typename, FunctionThreadAffinity threadAffinity = SameThreadAffinity>
class Function;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698