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) {
return UnretainedWrapper<T, kCrossThreadAffinity>(value);
}
template <typename T>
struct ParamStorageTraits {
typedef T StorageType;
namespace internal {
template <size_t, typename T>
struct CheckGCedTypeRestriction {
static_assert(!std::is_pointer<T>::value,
"Raw pointers are not allowed to bind into WTF::Function. Wrap "
"it with either WrapPersistent, WrapWeakPersistent, "
......@@ -191,28 +191,16 @@ struct ParamStorageTraits {
"GCed type is forbidden as a bound parameters.");
};
template <typename T>
struct ParamStorageTraits<scoped_refptr<T>> {
typedef scoped_refptr<T> StorageType;
};
template <typename>
class RetainPtr;
template <typename T>
struct ParamStorageTraits<RetainPtr<T>> {
typedef RetainPtr<T> StorageType;
};
template <typename Index, typename... Args>
struct CheckGCedTypeRestrictions;
template <typename T>
struct ParamStorageTraits<PassedWrapper<T>> {
typedef PassedWrapper<T> StorageType;
template <size_t... Ns, typename... Args>
struct CheckGCedTypeRestrictions<std::index_sequence<Ns...>, Args...>
: CheckGCedTypeRestriction<Ns, Args>... {
static constexpr bool ok = true;
};
template <typename T, FunctionThreadAffinity threadAffinity>
struct ParamStorageTraits<UnretainedWrapper<T, threadAffinity>> {
typedef UnretainedWrapper<T, threadAffinity> StorageType;
};
} // namespace internal
template <typename Signature,
FunctionThreadAffinity threadAffinity = kSameThreadAffinity>
......@@ -280,12 +268,14 @@ template <FunctionThreadAffinity threadAffinity,
Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>,
threadAffinity>
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 =
base::MakeUnboundRunType<FunctionType, BoundParameters...>;
return Function<UnboundRunType, threadAffinity>(base::Bind(
function,
typename ParamStorageTraits<typename std::decay<BoundParameters>::type>::
StorageType(std::forward<BoundParameters>(bound_parameters))...));
return Function<UnboundRunType, threadAffinity>(
base::Bind(function, std::forward<BoundParameters>(bound_parameters)...));
}
template <typename FunctionType, typename... BoundParameters>
......
......@@ -44,37 +44,6 @@ class UnwrappedClass {
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 {
public:
HasWeakPtrSupport() : weak_ptr_factory_(this) {}
......@@ -93,17 +62,6 @@ class HasWeakPtrSupport {
} // 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 {
......
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