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 17 matching lines...) Expand all Loading... |
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 "platform/heap/Handle.h" | 35 #include "platform/heap/Handle.h" |
36 #include "wtf/Assertions.h" | 36 #include "wtf/Assertions.h" |
37 #include "wtf/Forward.h" | 37 #include "wtf/Forward.h" |
38 #include "wtf/PassOwnPtr.h" | |
39 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
40 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
41 #include "wtf/ThreadSafeRefCounted.h" | 40 #include "wtf/ThreadSafeRefCounted.h" |
42 #include "wtf/TypeTraits.h" | 41 #include "wtf/TypeTraits.h" |
| 42 #include <memory> |
43 | 43 |
44 class SkRefCnt; | 44 class SkRefCnt; |
45 | 45 |
46 namespace WTF { | 46 namespace WTF { |
47 | 47 |
48 template <typename T> | 48 template <typename T> |
49 class PassedWrapper; | 49 class PassedWrapper; |
50 | 50 |
51 } | 51 } |
52 | 52 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 template <> | 127 template <> |
128 struct CrossThreadCopier<IntRect> : public CrossThreadCopierPassThrough<IntRect>
{ | 128 struct CrossThreadCopier<IntRect> : public CrossThreadCopierPassThrough<IntRect>
{ |
129 STATIC_ONLY(CrossThreadCopier); | 129 STATIC_ONLY(CrossThreadCopier); |
130 }; | 130 }; |
131 | 131 |
132 template <> | 132 template <> |
133 struct CrossThreadCopier<IntSize> : public CrossThreadCopierPassThrough<IntSize>
{ | 133 struct CrossThreadCopier<IntSize> : public CrossThreadCopierPassThrough<IntSize>
{ |
134 STATIC_ONLY(CrossThreadCopier); | 134 STATIC_ONLY(CrossThreadCopier); |
135 }; | 135 }; |
136 | 136 |
137 template <typename T> | |
138 struct CrossThreadCopier<PassOwnPtr<T>> { | |
139 STATIC_ONLY(CrossThreadCopier); | |
140 typedef PassOwnPtr<T> Type; | |
141 static Type copy(Type ownPtr) | |
142 { | |
143 return ownPtr; | |
144 } | |
145 }; | |
146 | |
147 template <typename T, typename Deleter> | 137 template <typename T, typename Deleter> |
148 struct CrossThreadCopier<std::unique_ptr<T, Deleter>> { | 138 struct CrossThreadCopier<std::unique_ptr<T, Deleter>> { |
149 STATIC_ONLY(CrossThreadCopier); | 139 STATIC_ONLY(CrossThreadCopier); |
150 using Type = std::unique_ptr<T, Deleter>; | 140 using Type = std::unique_ptr<T, Deleter>; |
151 static std::unique_ptr<T, Deleter> copy(std::unique_ptr<T, Deleter> pointer) | 141 static std::unique_ptr<T, Deleter> copy(std::unique_ptr<T, Deleter> pointer) |
152 { | 142 { |
153 return pointer; // This is in fact a move. | 143 return pointer; // This is in fact a move. |
154 } | 144 } |
155 }; | 145 }; |
156 | 146 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 template <> | 188 template <> |
199 struct CrossThreadCopier<ResourceError> { | 189 struct CrossThreadCopier<ResourceError> { |
200 STATIC_ONLY(CrossThreadCopier); | 190 STATIC_ONLY(CrossThreadCopier); |
201 typedef ResourceError Type; | 191 typedef ResourceError Type; |
202 PLATFORM_EXPORT static Type copy(const ResourceError&); | 192 PLATFORM_EXPORT static Type copy(const ResourceError&); |
203 }; | 193 }; |
204 | 194 |
205 template <> | 195 template <> |
206 struct CrossThreadCopier<ResourceRequest> { | 196 struct CrossThreadCopier<ResourceRequest> { |
207 STATIC_ONLY(CrossThreadCopier); | 197 STATIC_ONLY(CrossThreadCopier); |
208 typedef WTF::PassedWrapper<PassOwnPtr<CrossThreadResourceRequestData>> Type; | 198 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceRequestData>>
Type; |
209 PLATFORM_EXPORT static Type copy(const ResourceRequest&); | 199 PLATFORM_EXPORT static Type copy(const ResourceRequest&); |
210 }; | 200 }; |
211 | 201 |
212 template <> | 202 template <> |
213 struct CrossThreadCopier<ResourceResponse> { | 203 struct CrossThreadCopier<ResourceResponse> { |
214 STATIC_ONLY(CrossThreadCopier); | 204 STATIC_ONLY(CrossThreadCopier); |
215 typedef WTF::PassedWrapper<PassOwnPtr<CrossThreadResourceResponseData>> Type
; | 205 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceResponseData>>
Type; |
216 PLATFORM_EXPORT static Type copy(const ResourceResponse&); | 206 PLATFORM_EXPORT static Type copy(const ResourceResponse&); |
217 }; | 207 }; |
218 | 208 |
219 template <typename T> | 209 template <typename T> |
220 struct CrossThreadCopier<Member<T>> { | 210 struct CrossThreadCopier<Member<T>> { |
221 STATIC_ONLY(CrossThreadCopier); | 211 STATIC_ONLY(CrossThreadCopier); |
222 static_assert(IsGarbageCollectedType<T>::value, "T must be a garbage-collect
ed type."); | 212 static_assert(IsGarbageCollectedType<T>::value, "T must be a garbage-collect
ed type."); |
223 typedef T* Type; | 213 typedef T* Type; |
224 static Type copy(const Member<T>& ptr) | 214 static Type copy(const Member<T>& ptr) |
225 { | 215 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 AllowCrossThreadAccessWrapper<T*> AllowCrossThreadAccess(T* value) | 249 AllowCrossThreadAccessWrapper<T*> AllowCrossThreadAccess(T* value) |
260 { | 250 { |
261 static_assert(!IsGarbageCollectedType<T>::value, "Use wrapCrossThreadPersist
ent() instead for garbage-collected pointers"); | 251 static_assert(!IsGarbageCollectedType<T>::value, "Use wrapCrossThreadPersist
ent() instead for garbage-collected pointers"); |
262 static_assert(!WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value, "U
se PassRefPtr<T> instead for ThreadSafeRefCounted"); | 252 static_assert(!WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value, "U
se PassRefPtr<T> instead for ThreadSafeRefCounted"); |
263 return AllowCrossThreadAccessWrapper<T*>(value); | 253 return AllowCrossThreadAccessWrapper<T*>(value); |
264 } | 254 } |
265 | 255 |
266 } // namespace blink | 256 } // namespace blink |
267 | 257 |
268 #endif // CrossThreadCopier_h | 258 #endif // CrossThreadCopier_h |
OLD | NEW |