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

Side by Side Diff: third_party/WebKit/Source/platform/CrossThreadCopier.h

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Self-review. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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
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 <memory> 43 #include <memory>
43 44
44 class SkRefCnt; 45 class SkRefCnt;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 85
85 template <typename T> 86 template <typename T>
86 struct CrossThreadCopier : public CrossThreadCopierBase<T, std::is_arithmetic<T> ::value || std::is_enum<T>::value> { 87 struct CrossThreadCopier : public CrossThreadCopierBase<T, std::is_arithmetic<T> ::value || std::is_enum<T>::value> {
87 STATIC_ONLY(CrossThreadCopier); 88 STATIC_ONLY(CrossThreadCopier);
88 }; 89 };
89 90
90 // CrossThreadCopier specializations follow. 91 // CrossThreadCopier specializations follow.
91 template <typename T> 92 template <typename T>
92 struct CrossThreadCopier<PassRefPtr<T>> : public CrossThreadCopierPassThrough<Pa ssRefPtr<T>> { 93 struct CrossThreadCopier<PassRefPtr<T>> : public CrossThreadCopierPassThrough<Pa ssRefPtr<T>> {
93 STATIC_ONLY(CrossThreadCopier); 94 STATIC_ONLY(CrossThreadCopier);
94 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."); 95 static_assert(WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value, "Pa ssRefPtr<T> can be passed across threads only if T is ThreadSafeRefCounted.");
95 }; 96 };
96 template <typename T> 97 template <typename T>
97 struct CrossThreadCopier<RefPtr<T>> : public CrossThreadCopierPassThrough<RefPtr <T>> { 98 struct CrossThreadCopier<RefPtr<T>> : public CrossThreadCopierPassThrough<RefPtr <T>> {
98 STATIC_ONLY(CrossThreadCopier); 99 STATIC_ONLY(CrossThreadCopier);
99 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."); 100 static_assert(WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value, "Re fPtr<T> can be passed across threads only if T is ThreadSafeRefCounted.");
101 };
102 template <typename T>
103 struct CrossThreadCopier<sk_sp<T>> : public CrossThreadCopierPassThrough<sk_sp<T >> {
104 STATIC_ONLY(CrossThreadCopier);
105 static_assert(std::is_base_of<SkRefCnt, T>::value, "sk_sp<T> can be passed a cross threads only if T is SkRefCnt.");
100 }; 106 };
101 107
102 // nullptr_t can be passed through without any changes. 108 // nullptr_t can be passed through without any changes.
103 template <> 109 template <>
104 struct CrossThreadCopier<std::nullptr_t> : public CrossThreadCopierPassThrough<s td::nullptr_t> { 110 struct CrossThreadCopier<std::nullptr_t> : public CrossThreadCopierPassThrough<s td::nullptr_t> {
105 STATIC_ONLY(CrossThreadCopier); 111 STATIC_ONLY(CrossThreadCopier);
106 }; 112 };
107 113
108 // To allow a type to be passed across threads using its copy constructor, add a forward declaration of the type and 114 // To allow a type to be passed across threads using its copy constructor, add a forward declaration of the type and
109 // provide a specialization of CrossThreadCopier<T> in this file, like IntRect b elow. 115 // 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
185 template <> 191 template <>
186 struct CrossThreadCopier<ResourceResponse> { 192 struct CrossThreadCopier<ResourceResponse> {
187 STATIC_ONLY(CrossThreadCopier); 193 STATIC_ONLY(CrossThreadCopier);
188 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceResponseData>> Type; 194 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceResponseData>> Type;
189 PLATFORM_EXPORT static Type copy(const ResourceResponse&); 195 PLATFORM_EXPORT static Type copy(const ResourceResponse&);
190 }; 196 };
191 197
192 } // namespace blink 198 } // namespace blink
193 199
194 #endif // CrossThreadCopier_h 200 #endif // CrossThreadCopier_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698