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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 17 matching lines...) Expand all
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"
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 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
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
137 template <typename T, typename Deleter> 147 template <typename T, typename Deleter>
138 struct CrossThreadCopier<std::unique_ptr<T, Deleter>> { 148 struct CrossThreadCopier<std::unique_ptr<T, Deleter>> {
139 STATIC_ONLY(CrossThreadCopier); 149 STATIC_ONLY(CrossThreadCopier);
140 using Type = std::unique_ptr<T, Deleter>; 150 using Type = std::unique_ptr<T, Deleter>;
141 static std::unique_ptr<T, Deleter> copy(std::unique_ptr<T, Deleter> pointer) 151 static std::unique_ptr<T, Deleter> copy(std::unique_ptr<T, Deleter> pointer)
142 { 152 {
143 return pointer; // This is in fact a move. 153 return pointer; // This is in fact a move.
144 } 154 }
145 }; 155 };
146 156
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 template <> 198 template <>
189 struct CrossThreadCopier<ResourceError> { 199 struct CrossThreadCopier<ResourceError> {
190 STATIC_ONLY(CrossThreadCopier); 200 STATIC_ONLY(CrossThreadCopier);
191 typedef ResourceError Type; 201 typedef ResourceError Type;
192 PLATFORM_EXPORT static Type copy(const ResourceError&); 202 PLATFORM_EXPORT static Type copy(const ResourceError&);
193 }; 203 };
194 204
195 template <> 205 template <>
196 struct CrossThreadCopier<ResourceRequest> { 206 struct CrossThreadCopier<ResourceRequest> {
197 STATIC_ONLY(CrossThreadCopier); 207 STATIC_ONLY(CrossThreadCopier);
198 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceRequestData>> Type; 208 typedef WTF::PassedWrapper<PassOwnPtr<CrossThreadResourceRequestData>> Type;
199 PLATFORM_EXPORT static Type copy(const ResourceRequest&); 209 PLATFORM_EXPORT static Type copy(const ResourceRequest&);
200 }; 210 };
201 211
202 template <> 212 template <>
203 struct CrossThreadCopier<ResourceResponse> { 213 struct CrossThreadCopier<ResourceResponse> {
204 STATIC_ONLY(CrossThreadCopier); 214 STATIC_ONLY(CrossThreadCopier);
205 typedef WTF::PassedWrapper<std::unique_ptr<CrossThreadResourceResponseData>> Type; 215 typedef WTF::PassedWrapper<PassOwnPtr<CrossThreadResourceResponseData>> Type ;
206 PLATFORM_EXPORT static Type copy(const ResourceResponse&); 216 PLATFORM_EXPORT static Type copy(const ResourceResponse&);
207 }; 217 };
208 218
209 template <typename T> 219 template <typename T>
210 struct CrossThreadCopier<Member<T>> { 220 struct CrossThreadCopier<Member<T>> {
211 STATIC_ONLY(CrossThreadCopier); 221 STATIC_ONLY(CrossThreadCopier);
212 static_assert(IsGarbageCollectedType<T>::value, "T must be a garbage-collect ed type."); 222 static_assert(IsGarbageCollectedType<T>::value, "T must be a garbage-collect ed type.");
213 typedef T* Type; 223 typedef T* Type;
214 static Type copy(const Member<T>& ptr) 224 static Type copy(const Member<T>& ptr)
215 { 225 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 AllowCrossThreadAccessWrapper<T*> AllowCrossThreadAccess(T* value) 259 AllowCrossThreadAccessWrapper<T*> AllowCrossThreadAccess(T* value)
250 { 260 {
251 static_assert(!IsGarbageCollectedType<T>::value, "Use wrapCrossThreadPersist ent() instead for garbage-collected pointers"); 261 static_assert(!IsGarbageCollectedType<T>::value, "Use wrapCrossThreadPersist ent() instead for garbage-collected pointers");
252 static_assert(!WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value, "U se PassRefPtr<T> instead for ThreadSafeRefCounted"); 262 static_assert(!WTF::IsSubclassOfTemplate<T, ThreadSafeRefCounted>::value, "U se PassRefPtr<T> instead for ThreadSafeRefCounted");
253 return AllowCrossThreadAccessWrapper<T*>(value); 263 return AllowCrossThreadAccessWrapper<T*>(value);
254 } 264 }
255 265
256 } // namespace blink 266 } // namespace blink
257 267
258 #endif // CrossThreadCopier_h 268 #endif // CrossThreadCopier_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/ContextMenuItem.h ('k') | third_party/WebKit/Source/platform/CrossThreadCopier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698