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

Side by Side Diff: WebCore/platform/network/BlobData.h

Issue 11192017: ********** WebCore blob hacking (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 8 years, 1 month 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) 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 21 matching lines...) Expand all
32 #define BlobData_h 32 #define BlobData_h
33 33
34 #include "FileSystem.h" 34 #include "FileSystem.h"
35 #include "KURL.h" 35 #include "KURL.h"
36 #include <wtf/Forward.h> 36 #include <wtf/Forward.h>
37 #include <wtf/ThreadSafeRefCounted.h> 37 #include <wtf/ThreadSafeRefCounted.h>
38 #include <wtf/text/WTFString.h> 38 #include <wtf/text/WTFString.h>
39 39
40 namespace WebCore { 40 namespace WebCore {
41 41
42 class BlobDataHandle;
43
42 class RawData : public ThreadSafeRefCounted<RawData> { 44 class RawData : public ThreadSafeRefCounted<RawData> {
43 public: 45 public:
44 static PassRefPtr<RawData> create() 46 static PassRefPtr<RawData> create()
45 { 47 {
46 return adoptRef(new RawData()); 48 return adoptRef(new RawData());
47 } 49 }
48 50
49 void detachFromCurrentThread(); 51 void detachFromCurrentThread();
50 52
51 const char* data() const { return m_data.data(); } 53 const char* data() const { return m_data.data(); }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 BlobDataItem(const String& path, long long offset, long long length, double expectedModificationTime) 96 BlobDataItem(const String& path, long long offset, long long length, double expectedModificationTime)
95 : type(File) 97 : type(File)
96 , path(path) 98 , path(path)
97 , offset(offset) 99 , offset(offset)
98 , length(length) 100 , length(length)
99 , expectedModificationTime(expectedModificationTime) 101 , expectedModificationTime(expectedModificationTime)
100 { 102 {
101 } 103 }
102 104
103 // Constructor for Blob type. 105 // Constructor for Blob type.
104 BlobDataItem(const KURL& url, long long offset, long long length) 106 BlobDataItem(PassRefPtr<BlobDataHandle> blobDataHandle, long long offset, lo ng long length)
105 : type(Blob) 107 : type(Blob)
106 , url(url) 108 , blobDataHandle(blobDataHandle)
107 , offset(offset) 109 , offset(offset)
108 , length(length) 110 , length(length)
109 , expectedModificationTime(invalidFileTime()) 111 , expectedModificationTime(invalidFileTime())
110 { 112 {
111 } 113 }
112 114
113 #if ENABLE(FILE_SYSTEM) 115 #if ENABLE(FILE_SYSTEM)
114 // Constructor for URL type (e.g. FileSystem files). 116 // Constructor for URL type (e.g. FileSystem files).
115 BlobDataItem(const KURL& url, long long offset, long long length, double exp ectedModificationTime) 117 BlobDataItem(const KURL& url, long long offset, long long length, double exp ectedModificationTime)
116 : type(URL) 118 : type(URL)
(...skipping 16 matching lines...) Expand all
133 , URL 135 , URL
134 #endif 136 #endif
135 } type; 137 } type;
136 138
137 // For Data type. 139 // For Data type.
138 RefPtr<RawData> data; 140 RefPtr<RawData> data;
139 141
140 // For File type. 142 // For File type.
141 String path; 143 String path;
142 144
143 // For Blob or URL type. 145 // For FileSystem URL type.
144 KURL url; 146 KURL url;
145 147
148 // For Blob type.
149 RefPtr<BlobDataHandle> blobDataHandle;
150
146 long long offset; 151 long long offset;
147 long long length; 152 long long length;
148 double expectedModificationTime; 153 double expectedModificationTime;
149 154
150 private: 155 private:
151 friend class BlobData; 156 friend class BlobData;
152 157
153 // Constructor for String type (partial string). 158 // Constructor for String type (partial string).
154 BlobDataItem(PassRefPtr<RawData> data, long long offset, long long length) 159 BlobDataItem(PassRefPtr<RawData> data, long long offset, long long length)
155 : type(Data) 160 : type(Data)
(...skipping 20 matching lines...) Expand all
176 181
177 const String& contentDisposition() const { return m_contentDisposition; } 182 const String& contentDisposition() const { return m_contentDisposition; }
178 void setContentDisposition(const String& contentDisposition) { m_contentDisp osition = contentDisposition; } 183 void setContentDisposition(const String& contentDisposition) { m_contentDisp osition = contentDisposition; }
179 184
180 const BlobDataItemList& items() const { return m_items; } 185 const BlobDataItemList& items() const { return m_items; }
181 void swapItems(BlobDataItemList&); 186 void swapItems(BlobDataItemList&);
182 187
183 void appendData(PassRefPtr<RawData>, long long offset, long long length); 188 void appendData(PassRefPtr<RawData>, long long offset, long long length);
184 void appendFile(const String& path); 189 void appendFile(const String& path);
185 void appendFile(const String& path, long long offset, long long length, doub le expectedModificationTime); 190 void appendFile(const String& path, long long offset, long long length, doub le expectedModificationTime);
186 void appendBlob(const KURL&, long long offset, long long length); 191 void appendBlob(PassRefPtr<BlobDataHandle>, long long offset, long long leng th);
187 #if ENABLE(FILE_SYSTEM) 192 #if ENABLE(FILE_SYSTEM)
188 void appendURL(const KURL&, long long offset, long long length, double expec tedModificationTime); 193 void appendURL(const KURL&, long long offset, long long length, double expec tedModificationTime);
189 #endif 194 #endif
190 195
191 private: 196 private:
192 friend class BlobRegistryImpl; 197 friend class BlobRegistryImpl;
193 friend class BlobStorageData; 198 friend class BlobStorageData;
194 199
195 BlobData() { } 200 BlobData() { }
196 201
197 // This is only exposed to BlobStorageData. 202 // This is only exposed to BlobStorageData.
198 void appendData(const RawData&, long long offset, long long length); 203 void appendData(const RawData&, long long offset, long long length);
199 204
200 String m_contentType; 205 String m_contentType;
201 String m_contentDisposition; 206 String m_contentDisposition;
202 BlobDataItemList m_items; 207 BlobDataItemList m_items;
203 }; 208 };
204 209
210 // TODO: BlobDataHandle s/b in a seperate file
211
212 class BlobDataHandle : public ThreadSafeRefCounted<BlobDataHandle> {
213 public:
214 // For empty blob construction.
215 static PassRefPtr<BlobDataHandle> create()
216 {
217 return new BlobDataHandle();
218 }
219
220 // For initial creation.
221 static PassRefPtr<BlobDataHandle> create(PassOwnPtr<BlobData> data, long lon g size)
222 {
223 return new BlobDataHandle(data, size);
224 }
225
226 // For deserialization.
227 static PassRefPtr<BlobDataHandle> create(const String& uuid, const String& t ype, long long size)
228 {
229 return new BlobDataHandle(uuid, type, size);
230 }
231
232 String uuid() const { return m_uuid.isolatedCopy(); }
233 String type() const { return m_type.isolatedCopy(); }
234 unsigned long long size() { return m_size; }
235
236 ~BlobDataHandle();
237
238 private:
239 BlobDataHandle();
240 BlobDataHandle(PassOwnPtr<BlobData> data, long long size);
241 BlobDataHandle(const String& uuid, const String& type, long long size);
242
243 // FIXME: check that null or empty strings don't have some wierd thread affi nity that isolatedCopy() doesn't evade???
244 const String m_uuid;
245 const String m_type;
246 const long long m_size;
247 };
248
205 } // namespace WebCore 249 } // namespace WebCore
206 250
207 #endif // BlobData_h 251 #endif // BlobData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698