| 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 35546e4a653893ec04bb7c3f2a22ddc2ee26444d..b87042a121c566ec002724f8e26e2819ef4cb58d 100644
|
| --- a/third_party/WebKit/Source/wtf/Functional.h
|
| +++ b/third_party/WebKit/Source/wtf/Functional.h
|
| @@ -98,6 +98,11 @@ namespace WTF {
|
| // Obviously, if you create a functor this way, you shouldn't call the functor twice or more; after the second call,
|
| // the passed argument may be invalid.
|
|
|
| +enum FunctionThreadAffinity {
|
| + CrossThreadAffinity,
|
| + SameThreadAffinity
|
| +};
|
| +
|
| template <typename T>
|
| class PassedWrapper final {
|
| public:
|
| @@ -118,6 +123,30 @@ PassedWrapper<T> passed(T&& value)
|
| return PassedWrapper<T>(std::move(value));
|
| }
|
|
|
| +template <typename T, FunctionThreadAffinity threadAffinity>
|
| +class UnretainedWrapper final {
|
| +public:
|
| + explicit UnretainedWrapper(T* ptr) : m_ptr(ptr) { }
|
| + T* value() const { return m_ptr; }
|
| +
|
| +private:
|
| + T* m_ptr;
|
| +};
|
| +
|
| +template <typename T>
|
| +UnretainedWrapper<T, SameThreadAffinity> unretained(T* value)
|
| +{
|
| + static_assert(!WTF::IsGarbageCollectedType<T>::value, "unretained() + GCed type is forbidden");
|
| + return UnretainedWrapper<T, SameThreadAffinity>(value);
|
| +}
|
| +
|
| +template <typename T>
|
| +UnretainedWrapper<T, CrossThreadAffinity> crossThreadUnretained(T* value)
|
| +{
|
| + static_assert(!WTF::IsGarbageCollectedType<T>::value, "crossThreadUnretained() + GCed type is forbidden");
|
| + return UnretainedWrapper<T, CrossThreadAffinity>(value);
|
| +}
|
| +
|
| // A FunctionWrapper is a class template that can wrap a function pointer or a member function pointer and
|
| // provide a unified interface for calling that function.
|
| template <typename>
|
| @@ -231,6 +260,14 @@ struct ParamStorageTraits<PassedWrapper<T>> {
|
| static T unwrap(StorageType& value) { return value.moveOut(); }
|
| };
|
|
|
| +template <typename T, FunctionThreadAffinity threadAffinity>
|
| +struct ParamStorageTraits<UnretainedWrapper<T, threadAffinity>> {
|
| + typedef UnretainedWrapper<T, threadAffinity> StorageType;
|
| +
|
| + static StorageType wrap(const UnretainedWrapper<T, threadAffinity>& value) { return value; }
|
| + static T* unwrap(const StorageType& value) { return value.value(); }
|
| +};
|
| +
|
| template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits;
|
|
|
| template<typename T>
|
| @@ -256,11 +293,6 @@ struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, IsGarbageCo
|
| STATIC_ONLY(ParamStorageTraits);
|
| };
|
|
|
| -enum FunctionThreadAffinity {
|
| - CrossThreadAffinity,
|
| - SameThreadAffinity
|
| -};
|
| -
|
| template<typename, FunctionThreadAffinity threadAffinity = SameThreadAffinity>
|
| class Function;
|
|
|
| @@ -373,9 +405,13 @@ typedef Function<void(), CrossThreadAffinity> CrossThreadClosure;
|
|
|
| } // namespace WTF
|
|
|
| +using WTF::bind;
|
| +
|
| using WTF::passed;
|
| +using WTF::unretained;
|
| +using WTF::crossThreadUnretained;
|
| +
|
| using WTF::Function;
|
| -using WTF::bind;
|
| using WTF::SameThreadClosure;
|
| using WTF::CrossThreadClosure;
|
|
|
|
|