Commit 47bfa3dc authored by tzik's avatar tzik Committed by Commit Bot

Remove WTF::ParamStorageTraits

This removes WTF::ParamStorageTraits, as its type conversion is no
longer used. Its type assertions are moved to CheckGCedTypeRestriction.

Bug: 771087
Change-Id: I405fa4c38ae051dda6a1a75d3dbdd8c4a46586c7
Reviewed-on: https://chromium-review.googlesource.com/745762Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512790}
parent 0cebb740
...@@ -172,10 +172,10 @@ UnretainedWrapper<T, kCrossThreadAffinity> CrossThreadUnretained(T* value) { ...@@ -172,10 +172,10 @@ UnretainedWrapper<T, kCrossThreadAffinity> CrossThreadUnretained(T* value) {
return UnretainedWrapper<T, kCrossThreadAffinity>(value); return UnretainedWrapper<T, kCrossThreadAffinity>(value);
} }
template <typename T> namespace internal {
struct ParamStorageTraits {
typedef T StorageType;
template <size_t, typename T>
struct CheckGCedTypeRestriction {
static_assert(!std::is_pointer<T>::value, static_assert(!std::is_pointer<T>::value,
"Raw pointers are not allowed to bind into WTF::Function. Wrap " "Raw pointers are not allowed to bind into WTF::Function. Wrap "
"it with either WrapPersistent, WrapWeakPersistent, " "it with either WrapPersistent, WrapWeakPersistent, "
...@@ -191,28 +191,16 @@ struct ParamStorageTraits { ...@@ -191,28 +191,16 @@ struct ParamStorageTraits {
"GCed type is forbidden as a bound parameters."); "GCed type is forbidden as a bound parameters.");
}; };
template <typename T> template <typename Index, typename... Args>
struct ParamStorageTraits<scoped_refptr<T>> { struct CheckGCedTypeRestrictions;
typedef scoped_refptr<T> StorageType;
};
template <typename>
class RetainPtr;
template <typename T>
struct ParamStorageTraits<RetainPtr<T>> {
typedef RetainPtr<T> StorageType;
};
template <typename T> template <size_t... Ns, typename... Args>
struct ParamStorageTraits<PassedWrapper<T>> { struct CheckGCedTypeRestrictions<std::index_sequence<Ns...>, Args...>
typedef PassedWrapper<T> StorageType; : CheckGCedTypeRestriction<Ns, Args>... {
static constexpr bool ok = true;
}; };
template <typename T, FunctionThreadAffinity threadAffinity> } // namespace internal
struct ParamStorageTraits<UnretainedWrapper<T, threadAffinity>> {
typedef UnretainedWrapper<T, threadAffinity> StorageType;
};
template <typename Signature, template <typename Signature,
FunctionThreadAffinity threadAffinity = kSameThreadAffinity> FunctionThreadAffinity threadAffinity = kSameThreadAffinity>
...@@ -280,12 +268,14 @@ template <FunctionThreadAffinity threadAffinity, ...@@ -280,12 +268,14 @@ template <FunctionThreadAffinity threadAffinity,
Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>, Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>,
threadAffinity> threadAffinity>
BindInternal(FunctionType function, BoundParameters&&... bound_parameters) { BindInternal(FunctionType function, BoundParameters&&... bound_parameters) {
static_assert(internal::CheckGCedTypeRestrictions<
std::index_sequence_for<BoundParameters...>,
std::decay_t<BoundParameters>...>::ok,
"A bound argument uses a bad pattern.");
using UnboundRunType = using UnboundRunType =
base::MakeUnboundRunType<FunctionType, BoundParameters...>; base::MakeUnboundRunType<FunctionType, BoundParameters...>;
return Function<UnboundRunType, threadAffinity>(base::Bind( return Function<UnboundRunType, threadAffinity>(
function, base::Bind(function, std::forward<BoundParameters>(bound_parameters)...));
typename ParamStorageTraits<typename std::decay<BoundParameters>::type>::
StorageType(std::forward<BoundParameters>(bound_parameters))...));
} }
template <typename FunctionType, typename... BoundParameters> template <typename FunctionType, typename... BoundParameters>
......
...@@ -44,37 +44,6 @@ class UnwrappedClass { ...@@ -44,37 +44,6 @@ class UnwrappedClass {
int value_; int value_;
}; };
// This class must be wrapped in bind() and unwrapped in closure execution.
class ClassToBeWrapped {
WTF_MAKE_NONCOPYABLE(ClassToBeWrapped);
public:
explicit ClassToBeWrapped(int value) : value_(value) {}
int Value() const { return value_; }
private:
int value_;
};
class WrappedClass {
public:
WrappedClass(const ClassToBeWrapped& to_be_wrapped)
: value_(to_be_wrapped.Value()) {}
explicit WrappedClass(int value) : value_(value) {}
UnwrappedClass Unwrap() const { return UnwrappedClass(value_); }
private:
int value_;
};
template <>
struct ParamStorageTraits<ClassToBeWrapped> {
using StorageType = WrappedClass;
};
class HasWeakPtrSupport { class HasWeakPtrSupport {
public: public:
HasWeakPtrSupport() : weak_ptr_factory_(this) {} HasWeakPtrSupport() : weak_ptr_factory_(this) {}
...@@ -93,17 +62,6 @@ class HasWeakPtrSupport { ...@@ -93,17 +62,6 @@ class HasWeakPtrSupport {
} // namespace WTF } // namespace WTF
namespace base {
template <>
struct BindUnwrapTraits<WTF::WrappedClass> {
static WTF::UnwrappedClass Unwrap(const WTF::WrappedClass& wrapped) {
return wrapped.Unwrap();
}
};
} // namespace base
namespace WTF { namespace WTF {
namespace { namespace {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment