OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 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 BlobData_h | 31 #ifndef BlobData_h |
32 #define BlobData_h | 32 #define BlobData_h |
33 | 33 |
34 #include "base/gtest_prod_util.h" | 34 #include "base/gtest_prod_util.h" |
35 #include "platform/FileMetadata.h" | 35 #include "platform/FileMetadata.h" |
36 #include "platform/weborigin/KURL.h" | 36 #include "platform/weborigin/KURL.h" |
37 #include "wtf/Forward.h" | 37 #include "wtf/Forward.h" |
| 38 #include "wtf/PassOwnPtr.h" |
38 #include "wtf/ThreadSafeRefCounted.h" | 39 #include "wtf/ThreadSafeRefCounted.h" |
39 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
40 #include <memory> | |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 class BlobDataHandle; | 44 class BlobDataHandle; |
45 | 45 |
46 class PLATFORM_EXPORT RawData : public ThreadSafeRefCounted<RawData> { | 46 class PLATFORM_EXPORT RawData : public ThreadSafeRefCounted<RawData> { |
47 public: | 47 public: |
48 static PassRefPtr<RawData> create() | 48 static PassRefPtr<RawData> create() |
49 { | 49 { |
50 return adoptRef(new RawData()); | 50 return adoptRef(new RawData()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 { | 157 { |
158 } | 158 } |
159 }; | 159 }; |
160 | 160 |
161 typedef Vector<BlobDataItem> BlobDataItemList; | 161 typedef Vector<BlobDataItem> BlobDataItemList; |
162 | 162 |
163 class PLATFORM_EXPORT BlobData { | 163 class PLATFORM_EXPORT BlobData { |
164 USING_FAST_MALLOC(BlobData); | 164 USING_FAST_MALLOC(BlobData); |
165 WTF_MAKE_NONCOPYABLE(BlobData); | 165 WTF_MAKE_NONCOPYABLE(BlobData); |
166 public: | 166 public: |
167 static std::unique_ptr<BlobData> create(); | 167 static PassOwnPtr<BlobData> create(); |
168 | 168 |
169 // Detaches from current thread so that it can be passed to another thread. | 169 // Detaches from current thread so that it can be passed to another thread. |
170 void detachFromCurrentThread(); | 170 void detachFromCurrentThread(); |
171 | 171 |
172 const String& contentType() const { return m_contentType; } | 172 const String& contentType() const { return m_contentType; } |
173 void setContentType(const String&); | 173 void setContentType(const String&); |
174 | 174 |
175 const BlobDataItemList& items() const { return m_items; } | 175 const BlobDataItemList& items() const { return m_items; } |
176 | 176 |
177 void appendBytes(const void*, size_t length); | 177 void appendBytes(const void*, size_t length); |
(...skipping 23 matching lines...) Expand all Loading... |
201 | 201 |
202 class PLATFORM_EXPORT BlobDataHandle : public ThreadSafeRefCounted<BlobDataHandl
e> { | 202 class PLATFORM_EXPORT BlobDataHandle : public ThreadSafeRefCounted<BlobDataHandl
e> { |
203 public: | 203 public: |
204 // For empty blob construction. | 204 // For empty blob construction. |
205 static PassRefPtr<BlobDataHandle> create() | 205 static PassRefPtr<BlobDataHandle> create() |
206 { | 206 { |
207 return adoptRef(new BlobDataHandle()); | 207 return adoptRef(new BlobDataHandle()); |
208 } | 208 } |
209 | 209 |
210 // For initial creation. | 210 // For initial creation. |
211 static PassRefPtr<BlobDataHandle> create(std::unique_ptr<BlobData> data, lon
g long size) | 211 static PassRefPtr<BlobDataHandle> create(PassOwnPtr<BlobData> data, long lon
g size) |
212 { | 212 { |
213 return adoptRef(new BlobDataHandle(std::move(data), size)); | 213 return adoptRef(new BlobDataHandle(std::move(data), size)); |
214 } | 214 } |
215 | 215 |
216 // For deserialization of script values and ipc messages. | 216 // For deserialization of script values and ipc messages. |
217 static PassRefPtr<BlobDataHandle> create(const String& uuid, const String& t
ype, long long size) | 217 static PassRefPtr<BlobDataHandle> create(const String& uuid, const String& t
ype, long long size) |
218 { | 218 { |
219 return adoptRef(new BlobDataHandle(uuid, type, size)); | 219 return adoptRef(new BlobDataHandle(uuid, type, size)); |
220 } | 220 } |
221 | 221 |
222 String uuid() const { return m_uuid.isolatedCopy(); } | 222 String uuid() const { return m_uuid.isolatedCopy(); } |
223 String type() const { return m_type.isolatedCopy(); } | 223 String type() const { return m_type.isolatedCopy(); } |
224 unsigned long long size() const { return m_size; } | 224 unsigned long long size() const { return m_size; } |
225 | 225 |
226 ~BlobDataHandle(); | 226 ~BlobDataHandle(); |
227 | 227 |
228 private: | 228 private: |
229 BlobDataHandle(); | 229 BlobDataHandle(); |
230 BlobDataHandle(std::unique_ptr<BlobData>, long long size); | 230 BlobDataHandle(PassOwnPtr<BlobData>, long long size); |
231 BlobDataHandle(const String& uuid, const String& type, long long size); | 231 BlobDataHandle(const String& uuid, const String& type, long long size); |
232 | 232 |
233 const String m_uuid; | 233 const String m_uuid; |
234 const String m_type; | 234 const String m_type; |
235 const long long m_size; | 235 const long long m_size; |
236 }; | 236 }; |
237 | 237 |
238 } // namespace blink | 238 } // namespace blink |
239 | 239 |
240 #endif // BlobData_h | 240 #endif // BlobData_h |
OLD | NEW |