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 19 matching lines...) Expand all Loading... |
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" | 38 #include "wtf/PassOwnPtr.h" |
39 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
40 #include "wtf/RawPtr.h" | |
41 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
42 #include "wtf/ThreadSafeRefCounted.h" | 41 #include "wtf/ThreadSafeRefCounted.h" |
43 #include "wtf/TypeTraits.h" | 42 #include "wtf/TypeTraits.h" |
44 | 43 |
45 class SkRefCnt; | 44 class SkRefCnt; |
46 | 45 |
47 namespace blink { | 46 namespace blink { |
48 | 47 |
49 class IntRect; | 48 class IntRect; |
50 class IntSize; | 49 class IntSize; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 { | 92 { |
94 return refPtr; | 93 return refPtr; |
95 } | 94 } |
96 }; | 95 }; |
97 | 96 |
98 // A pointer to GarbageCollected. | 97 // A pointer to GarbageCollected. |
99 template <typename T> | 98 template <typename T> |
100 struct CrossThreadCopierBase<T, false, false, true> { | 99 struct CrossThreadCopierBase<T, false, false, true> { |
101 STATIC_ONLY(CrossThreadCopierBase); | 100 STATIC_ONLY(CrossThreadCopierBase); |
102 typedef typename std::remove_pointer<T>::type TypeWithoutPointer; | 101 typedef typename std::remove_pointer<T>::type TypeWithoutPointer; |
103 typedef RawPtr<TypeWithoutPointer> Type; | 102 typedef TypeWithoutPointer* Type; |
104 static Type copy(const T& ptr) | 103 static Type copy(const T& ptr) |
105 { | 104 { |
106 return ptr; | 105 return ptr; |
107 } | 106 } |
108 }; | 107 }; |
109 | 108 |
110 template <typename T> | 109 template <typename T> |
111 struct CrossThreadCopier : public CrossThreadCopierBase< | 110 struct CrossThreadCopier : public CrossThreadCopierBase< |
112 T, | 111 T, |
113 std::is_arithmetic<T>::value || std::is_enum<T>::value, | 112 std::is_arithmetic<T>::value || std::is_enum<T>::value, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 }; | 194 }; |
196 | 195 |
197 template <> | 196 template <> |
198 struct CrossThreadCopier<ResourceResponse> { | 197 struct CrossThreadCopier<ResourceResponse> { |
199 STATIC_ONLY(CrossThreadCopier); | 198 STATIC_ONLY(CrossThreadCopier); |
200 typedef PassOwnPtr<CrossThreadResourceResponseData> Type; | 199 typedef PassOwnPtr<CrossThreadResourceResponseData> Type; |
201 PLATFORM_EXPORT static Type copy(const ResourceResponse&); | 200 PLATFORM_EXPORT static Type copy(const ResourceResponse&); |
202 }; | 201 }; |
203 | 202 |
204 template <typename T> | 203 template <typename T> |
205 struct CrossThreadCopier<RawPtr<T>> { | |
206 STATIC_ONLY(CrossThreadCopier); | |
207 static_assert(IsGarbageCollectedType<T>::value, "T must be a garbage-collect
ed type."); | |
208 typedef RawPtr<T> Type; | |
209 static Type copy(const Type& ptr) | |
210 { | |
211 return ptr; | |
212 } | |
213 }; | |
214 | |
215 template <typename T> | |
216 struct CrossThreadCopier<Member<T>> { | 204 struct CrossThreadCopier<Member<T>> { |
217 STATIC_ONLY(CrossThreadCopier); | 205 STATIC_ONLY(CrossThreadCopier); |
218 static_assert(IsGarbageCollectedType<T>::value, "T must be a garbage-collect
ed type."); | 206 static_assert(IsGarbageCollectedType<T>::value, "T must be a garbage-collect
ed type."); |
219 typedef RawPtr<T> Type; | 207 typedef T* Type; |
220 static Type copy(const Member<T>& ptr) | 208 static Type copy(const Member<T>& ptr) |
221 { | 209 { |
222 return ptr; | 210 return ptr; |
223 } | 211 } |
224 }; | 212 }; |
225 | 213 |
226 template <typename T> | 214 template <typename T> |
227 struct CrossThreadCopier<WeakMember<T>> { | 215 struct CrossThreadCopier<WeakMember<T>> { |
228 STATIC_ONLY(CrossThreadCopier); | 216 STATIC_ONLY(CrossThreadCopier); |
229 static_assert(IsGarbageCollectedType<T>::value, "T must be a garbage-collect
ed type."); | 217 static_assert(IsGarbageCollectedType<T>::value, "T must be a garbage-collect
ed type."); |
230 typedef RawPtr<T> Type; | 218 typedef T* Type; |
231 static Type copy(const WeakMember<T>& ptr) | 219 static Type copy(const WeakMember<T>& ptr) |
232 { | 220 { |
233 return ptr; | 221 return ptr; |
234 } | 222 } |
235 }; | 223 }; |
236 | 224 |
237 // |T| is |C*| or |const WeakPtr<C>&|. | 225 // |T| is |C*| or |const WeakPtr<C>&|. |
238 template <typename T> | 226 template <typename T> |
239 struct AllowCrossThreadAccessWrapper { | 227 struct AllowCrossThreadAccessWrapper { |
240 STACK_ALLOCATED(); | 228 STACK_ALLOCATED(); |
(...skipping 25 matching lines...) Expand all Loading... |
266 | 254 |
267 template <typename T> | 255 template <typename T> |
268 AllowCrossThreadAccessWrapper<const WeakPtr<T>&> AllowCrossThreadAccess(const We
akPtr<T>& value) | 256 AllowCrossThreadAccessWrapper<const WeakPtr<T>&> AllowCrossThreadAccess(const We
akPtr<T>& value) |
269 { | 257 { |
270 return AllowCrossThreadAccessWrapper<const WeakPtr<T>&>(value); | 258 return AllowCrossThreadAccessWrapper<const WeakPtr<T>&>(value); |
271 } | 259 } |
272 | 260 |
273 } // namespace blink | 261 } // namespace blink |
274 | 262 |
275 #endif // CrossThreadCopier_h | 263 #endif // CrossThreadCopier_h |
OLD | NEW |