| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef CrossThreadCopier_h | 31 #ifndef CrossThreadCopier_h |
| 32 #define CrossThreadCopier_h | 32 #define CrossThreadCopier_h |
| 33 | 33 |
| 34 #include "platform/PlatformExport.h" | 34 #include "platform/PlatformExport.h" |
| 35 #include "third_party/skia/include/core/SkRefCnt.h" |
| 35 #include "wtf/Assertions.h" | 36 #include "wtf/Assertions.h" |
| 36 #include "wtf/Forward.h" | 37 #include "wtf/Forward.h" |
| 37 #include "wtf/Functional.h" // FunctionThreadAffinity | 38 #include "wtf/Functional.h" // FunctionThreadAffinity |
| 38 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
| 40 #include "wtf/ThreadSafeRefCounted.h" | 41 #include "wtf/ThreadSafeRefCounted.h" |
| 41 #include "wtf/TypeTraits.h" | 42 #include "wtf/TypeTraits.h" |
| 42 #include "wtf/WeakPtr.h" | 43 #include "wtf/WeakPtr.h" |
| 43 #include <memory> | 44 #include <memory> |
| 44 | 45 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 86 |
| 86 template <typename T> | 87 template <typename T> |
| 87 struct CrossThreadCopier : public CrossThreadCopierBase<T, std::is_arithmetic<T>
::value || std::is_enum<T>::value> { | 88 struct CrossThreadCopier : public CrossThreadCopierBase<T, std::is_arithmetic<T>
::value || std::is_enum<T>::value> { |
| 88 STATIC_ONLY(CrossThreadCopier); | 89 STATIC_ONLY(CrossThreadCopier); |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 // CrossThreadCopier specializations follow. | 92 // CrossThreadCopier specializations follow. |
| 92 template <typename T> | 93 template <typename T> |
| 93 struct CrossThreadCopier<PassRefPtr<T>> : public CrossThreadCopierPassThrough<Pa
ssRefPtr<T>> { | 94 struct CrossThreadCopier<PassRefPtr<T>> : public CrossThreadCopierPassThrough<Pa
ssRefPtr<T>> { |
| 94 STATIC_ONLY(CrossThreadCopier); | 95 STATIC_ONLY(CrossThreadCopier); |
| 95 static_assert(WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value || s
td::is_base_of<SkRefCnt, T>::value, "PassRefPtr<T> can be passed across threads
only if T is ThreadSafeRefCounted or SkRefCnt."); | 96 static_assert(WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value, "Pa
ssRefPtr<T> can be passed across threads only if T is ThreadSafeRefCounted."); |
| 96 }; | 97 }; |
| 97 template <typename T> | 98 template <typename T> |
| 98 struct CrossThreadCopier<RefPtr<T>> : public CrossThreadCopierPassThrough<RefPtr
<T>> { | 99 struct CrossThreadCopier<RefPtr<T>> : public CrossThreadCopierPassThrough<RefPtr
<T>> { |
| 99 STATIC_ONLY(CrossThreadCopier); | 100 STATIC_ONLY(CrossThreadCopier); |
| 100 static_assert(WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value || s
td::is_base_of<SkRefCnt, T>::value, "RefPtr<T> can be passed across threads only
if T is ThreadSafeRefCounted or SkRefCnt."); | 101 static_assert(WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value, "Re
fPtr<T> can be passed across threads only if T is ThreadSafeRefCounted."); |
| 102 }; |
| 103 template <typename T> |
| 104 struct CrossThreadCopier<sk_sp<T>> : public CrossThreadCopierPassThrough<sk_sp<T
>> { |
| 105 STATIC_ONLY(CrossThreadCopier); |
| 106 static_assert(std::is_base_of<SkRefCnt, T>::value, "sk_sp<T> can be passed a
cross threads only if T is SkRefCnt."); |
| 101 }; | 107 }; |
| 102 | 108 |
| 103 // nullptr_t can be passed through without any changes. | 109 // nullptr_t can be passed through without any changes. |
| 104 template <> | 110 template <> |
| 105 struct CrossThreadCopier<std::nullptr_t> : public CrossThreadCopierPassThrough<s
td::nullptr_t> { | 111 struct CrossThreadCopier<std::nullptr_t> : public CrossThreadCopierPassThrough<s
td::nullptr_t> { |
| 106 STATIC_ONLY(CrossThreadCopier); | 112 STATIC_ONLY(CrossThreadCopier); |
| 107 }; | 113 }; |
| 108 | 114 |
| 109 // To allow a type to be passed across threads using its copy constructor, add a
forward declaration of the type and | 115 // To allow a type to be passed across threads using its copy constructor, add a
forward declaration of the type and |
| 110 // provide a specialization of CrossThreadCopier<T> in this file, like IntRect b
elow. | 116 // provide a specialization of CrossThreadCopier<T> in this file, like IntRect b
elow. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 template <> | 192 template <> |
| 187 struct CrossThreadCopier<ResourceResponse> { | 193 struct CrossThreadCopier<ResourceResponse> { |
| 188 STATIC_ONLY(CrossThreadCopier); | 194 STATIC_ONLY(CrossThreadCopier); |
| 189 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceResponseData>>
Type; | 195 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceResponseData>>
Type; |
| 190 PLATFORM_EXPORT static Type copy(const ResourceResponse&); | 196 PLATFORM_EXPORT static Type copy(const ResourceResponse&); |
| 191 }; | 197 }; |
| 192 | 198 |
| 193 } // namespace blink | 199 } // namespace blink |
| 194 | 200 |
| 195 #endif // CrossThreadCopier_h | 201 #endif // CrossThreadCopier_h |
| OLD | NEW |