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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 }; | 80 }; |
81 | 81 |
82 // Custom copy methods. | 82 // Custom copy methods. |
83 template<typename T> struct CrossThreadCopierBase<false, true, false, T> { | 83 template<typename T> struct CrossThreadCopierBase<false, true, false, T> { |
84 STATIC_ONLY(CrossThreadCopierBase); | 84 STATIC_ONLY(CrossThreadCopierBase); |
85 typedef typename WTF::RemoveTemplate<T, RefPtr>::Type TypeWithoutRefPtr; | 85 typedef typename WTF::RemoveTemplate<T, RefPtr>::Type TypeWithoutRefPtr; |
86 typedef typename WTF::RemoveTemplate<TypeWithoutRefPtr, PassRefPtr>::Typ
e TypeWithoutPassRefPtr; | 86 typedef typename WTF::RemoveTemplate<TypeWithoutRefPtr, PassRefPtr>::Typ
e TypeWithoutPassRefPtr; |
87 typedef typename std::remove_pointer<TypeWithoutPassRefPtr>::type RefCou
ntedType; | 87 typedef typename std::remove_pointer<TypeWithoutPassRefPtr>::type RefCou
ntedType; |
88 | 88 |
89 // Verify that only one of the above did a change. | 89 // Verify that only one of the above did a change. |
90 static_assert((WTF::IsSameType<RefPtr<RefCountedType>, T>::value | 90 static_assert((std::is_same<RefPtr<RefCountedType>, T>::value |
91 || WTF::IsSameType<PassRefPtr<RefCountedType>, T>::value | 91 || std::is_same<PassRefPtr<RefCountedType>, T>::value |
92 || WTF::IsSameType<RefCountedType*, T>::value), | 92 || std::is_same<RefCountedType*, T>::value), |
93 "only one type modification should be allowed"); | 93 "only one type modification should be allowed"); |
94 | 94 |
95 typedef PassRefPtr<RefCountedType> Type; | 95 typedef PassRefPtr<RefCountedType> Type; |
96 static Type copy(const T& refPtr) | 96 static Type copy(const T& refPtr) |
97 { | 97 { |
98 return refPtr; | 98 return refPtr; |
99 } | 99 } |
100 }; | 100 }; |
101 | 101 |
102 template<typename T> struct CrossThreadCopierBase<false, false, false, PassO
wnPtr<T>> { | 102 template<typename T> struct CrossThreadCopierBase<false, false, false, PassO
wnPtr<T>> { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 template<typename T> struct CrossThreadCopierBase<false, false, true, WeakMe
mber<T>> { | 178 template<typename T> struct CrossThreadCopierBase<false, false, true, WeakMe
mber<T>> { |
179 STATIC_ONLY(CrossThreadCopierBase); | 179 STATIC_ONLY(CrossThreadCopierBase); |
180 typedef RawPtr<T> Type; | 180 typedef RawPtr<T> Type; |
181 static Type copy(const WeakMember<T>& ptr) | 181 static Type copy(const WeakMember<T>& ptr) |
182 { | 182 { |
183 return ptr; | 183 return ptr; |
184 } | 184 } |
185 }; | 185 }; |
186 | 186 |
187 template<typename T> struct CrossThreadCopier : public CrossThreadCopierBase
<WTF::IsConvertibleToInteger<T>::value, | 187 template<typename T> struct CrossThreadCopier : public CrossThreadCopierBase
<std::is_convertible<T, int>::value, |
188 WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, RefPtr>::Type,
ThreadSafeRefCounted>::value | 188 WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, RefPtr>::Type,
ThreadSafeRefCounted>::value |
189 || WTF::IsSubclassOfTemplate<typename std::remove_pointer<T>::type,
ThreadSafeRefCounted>::value | 189 || WTF::IsSubclassOfTemplate<typename std::remove_pointer<T>::type,
ThreadSafeRefCounted>::value |
190 || WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, PassRef
Ptr>::Type, ThreadSafeRefCounted>::value, | 190 || WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, PassRef
Ptr>::Type, ThreadSafeRefCounted>::value, |
191 WTF::IsSubclassOfTemplate<typename std::remove_pointer<T>::type, Garbage
Collected>::value | 191 WTF::IsSubclassOfTemplate<typename std::remove_pointer<T>::type, Garbage
Collected>::value |
192 || WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, RawPtr>
::Type, GarbageCollected>::value | 192 || WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, RawPtr>
::Type, GarbageCollected>::value |
193 || WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, Member>
::Type, GarbageCollected>::value | 193 || WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, Member>
::Type, GarbageCollected>::value |
194 || WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, WeakMem
ber>::Type, GarbageCollected>::value, | 194 || WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, WeakMem
ber>::Type, GarbageCollected>::value, |
195 T> { | 195 T> { |
196 STATIC_ONLY(CrossThreadCopier); | 196 STATIC_ONLY(CrossThreadCopier); |
197 }; | 197 }; |
(...skipping 26 matching lines...) Expand all Loading... |
224 } | 224 } |
225 | 225 |
226 template<typename T> AllowCrossThreadAccessWrapper<const WeakPtr<T>&> AllowC
rossThreadAccess(const WeakPtr<T>& value) | 226 template<typename T> AllowCrossThreadAccessWrapper<const WeakPtr<T>&> AllowC
rossThreadAccess(const WeakPtr<T>& value) |
227 { | 227 { |
228 return AllowCrossThreadAccessWrapper<const WeakPtr<T>&>(value); | 228 return AllowCrossThreadAccessWrapper<const WeakPtr<T>&>(value); |
229 } | 229 } |
230 | 230 |
231 } // namespace blink | 231 } // namespace blink |
232 | 232 |
233 #endif // CrossThreadCopier_h | 233 #endif // CrossThreadCopier_h |
OLD | NEW |