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

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: rebase 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..47b0a414b615b9f13c6a2040ed2b1521fb72fff5 100644
--- a/third_party/WebKit/Source/wtf/Functional.h
+++ b/third_party/WebKit/Source/wtf/Functional.h
@@ -40,7 +40,7 @@
#include <utility>
namespace blink {
-template<typename T> class CrossThreadPersistent;
+template <typename T> class Member;
}
namespace base {
@@ -216,6 +216,9 @@ template <typename T>
struct ParamStorageTraits {
typedef T StorageType;
+ static_assert(!std::is_pointer<T>::value, "Raw pointer is not allowed to bind into WTF::Function. Wrap it with either Persistent, WeakPersistent, CrossThreadPersistent, CrossThreadWeakPersistent, RefPtr or unretained.");
sof 2016/06/24 11:37:19 Shouldn't the error message be mentioning wrapPers
tzik 2016/06/24 13:13:33 OK, replaced them to wrap*.
+ static_assert(!IsSubclassOfTemplate<T, blink::Member>::value, "Member is not allowed to bind into WTF::Function. Wrap it with either Persistent, WeakPersistent, CrossThreadPersistent or CrossThreadWeakPersistenst.");
sof 2016/06/24 11:37:19 Add a case for WeakMember<>?
tzik 2016/06/24 13:13:33 Done.
+
static StorageType wrap(const T& value) { return value; } // Copy.
static StorageType wrap(T&& value) { return std::move(value); }
@@ -265,31 +268,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