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

Side by Side Diff: Source/core/platform/network/BlobData.h

Issue 23992003: blob hacking webcore style (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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) 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 22 matching lines...) Expand all
33 33
34 #include "platform/FileMetadata.h" 34 #include "platform/FileMetadata.h"
35 #include "weborigin/KURL.h" 35 #include "weborigin/KURL.h"
36 #include "wtf/Forward.h" 36 #include "wtf/Forward.h"
37 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
38 #include "wtf/ThreadSafeRefCounted.h" 38 #include "wtf/ThreadSafeRefCounted.h"
39 #include "wtf/text/WTFString.h" 39 #include "wtf/text/WTFString.h"
40 40
41 namespace WebCore { 41 namespace WebCore {
42 42
43 class BlobDataHandle;
44
43 class RawData : public ThreadSafeRefCounted<RawData> { 45 class RawData : public ThreadSafeRefCounted<RawData> {
44 public: 46 public:
45 static PassRefPtr<RawData> create() 47 static PassRefPtr<RawData> create()
46 { 48 {
47 return adoptRef(new RawData()); 49 return adoptRef(new RawData());
48 } 50 }
49 51
50 void detachFromCurrentThread(); 52 void detachFromCurrentThread();
51 53
52 const char* data() const { return m_data.data(); } 54 const char* data() const { return m_data.data(); }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 BlobDataItem(const String& path, long long offset, long long length, double expectedModificationTime) 97 BlobDataItem(const String& path, long long offset, long long length, double expectedModificationTime)
96 : type(File) 98 : type(File)
97 , path(path) 99 , path(path)
98 , offset(offset) 100 , offset(offset)
99 , length(length) 101 , length(length)
100 , expectedModificationTime(expectedModificationTime) 102 , expectedModificationTime(expectedModificationTime)
101 { 103 {
102 } 104 }
103 105
104 // Constructor for Blob type. 106 // Constructor for Blob type.
105 BlobDataItem(const KURL& url, long long offset, long long length) 107 BlobDataItem(PassRefPtr<BlobDataHandle> blobDataHandle, long long offset, lo ng long length)
106 : type(Blob) 108 : type(Blob)
107 , url(url) 109 , blobDataHandle(blobDataHandle)
108 , offset(offset) 110 , offset(offset)
109 , length(length) 111 , length(length)
110 , expectedModificationTime(invalidFileTime()) 112 , expectedModificationTime(invalidFileTime())
111 { 113 {
112 } 114 }
113 115
114 // Constructor for URL type (e.g. FileSystem files). 116 // Constructor for FileSystem file type.
115 BlobDataItem(const KURL& url, long long offset, long long length, double exp ectedModificationTime) 117 BlobDataItem(const KURL& fileSystemURL, long long offset, long long length, double expectedModificationTime)
116 : type(URL) 118 : type(FileSystemURL)
117 , url(url) 119 , fileSystemURL(fileSystemURL)
118 , offset(offset) 120 , offset(offset)
119 , length(length) 121 , length(length)
120 , expectedModificationTime(expectedModificationTime) 122 , expectedModificationTime(expectedModificationTime)
121 { 123 {
122 } 124 }
123 125
124 // Detaches from current thread so that it can be passed to another thread. 126 // Detaches from current thread so that it can be passed to another thread.
125 void detachFromCurrentThread(); 127 void detachFromCurrentThread();
126 128
127 enum { 129 enum {
128 Data, 130 Data,
129 File, 131 File,
130 Blob, 132 Blob,
131 URL 133 FileSystemURL
132 } type; 134 } type;
133 135
134 // For Data type. 136 RefPtr<RawData> data; // For Data type.
135 RefPtr<RawData> data; 137 String path; // For File type.
136 138 KURL fileSystemURL; // For FileSystemURL type.
137 // For File type. 139 RefPtr<BlobDataHandle> blobDataHandle; // For Blob type.
138 String path;
139
140 // For Blob or URL type.
141 KURL url;
142 140
143 long long offset; 141 long long offset;
144 long long length; 142 long long length;
145 double expectedModificationTime; 143 double expectedModificationTime;
146 144
147 private: 145 private:
148 friend class BlobData; 146 friend class BlobData;
149 147
150 // Constructor for String type (partial string). 148 // Constructor for String type (partial string).
151 BlobDataItem(PassRefPtr<RawData> data, long long offset, long long length) 149 BlobDataItem(PassRefPtr<RawData> data, long long offset, long long length)
(...skipping 21 matching lines...) Expand all
173 171
174 const String& contentDisposition() const { return m_contentDisposition; } 172 const String& contentDisposition() const { return m_contentDisposition; }
175 void setContentDisposition(const String& contentDisposition) { m_contentDisp osition = contentDisposition; } 173 void setContentDisposition(const String& contentDisposition) { m_contentDisp osition = contentDisposition; }
176 174
177 const BlobDataItemList& items() const { return m_items; } 175 const BlobDataItemList& items() const { return m_items; }
178 void swapItems(BlobDataItemList&); 176 void swapItems(BlobDataItemList&);
179 177
180 void appendData(PassRefPtr<RawData>, long long offset, long long length); 178 void appendData(PassRefPtr<RawData>, long long offset, long long length);
181 void appendFile(const String& path); 179 void appendFile(const String& path);
182 void appendFile(const String& path, long long offset, long long length, doub le expectedModificationTime); 180 void appendFile(const String& path, long long offset, long long length, doub le expectedModificationTime);
183 void appendBlob(const KURL&, long long offset, long long length); 181 void appendBlob(PassRefPtr<BlobDataHandle>, long long offset, long long leng th);
184 void appendURL(const KURL&, long long offset, long long length, double expec tedModificationTime); 182 void appendFileSystemURL(const KURL&, long long offset, long long length, do uble expectedModificationTime);
185 183
186 private: 184 private:
187 friend class BlobRegistryImpl; 185 friend class BlobRegistryImpl;
188 friend class BlobStorageData; 186 friend class BlobStorageData;
189 187
190 BlobData() { } 188 BlobData() { }
191 189
192 // This is only exposed to BlobStorageData. 190 // This is only exposed to BlobStorageData.
193 void appendData(const RawData&, long long offset, long long length); 191 void appendData(const RawData&, long long offset, long long length);
194 192
195 String m_contentType; 193 String m_contentType;
196 String m_contentDisposition; 194 String m_contentDisposition;
197 BlobDataItemList m_items; 195 BlobDataItemList m_items;
198 }; 196 };
199 197
200 // FIXME: This class is mostly place holder until I get farther along with 198
201 // https://bugs.webkit.org/show_bug.cgi?id=108733 and more specifically with lan ding
202 // https://codereview.chromium.org/11192017/.
203 class BlobDataHandle : public ThreadSafeRefCounted<BlobDataHandle> { 199 class BlobDataHandle : public ThreadSafeRefCounted<BlobDataHandle> {
204 public: 200 public:
201 // For empty blob construction.
202 static PassRefPtr<BlobDataHandle> create()
203 {
204 return adoptRef(new BlobDataHandle());
205 }
206
207 // For initial creation.
205 static PassRefPtr<BlobDataHandle> create(PassOwnPtr<BlobData> data, long lon g size) 208 static PassRefPtr<BlobDataHandle> create(PassOwnPtr<BlobData> data, long lon g size)
206 { 209 {
207 return adoptRef(new BlobDataHandle(data, size)); 210 return adoptRef(new BlobDataHandle(data, size));
208 } 211 }
209 212
213 // For deserialization of script values and ipc messages.
214 static PassRefPtr<BlobDataHandle> create(const String& uuid, const String& t ype, long long size)
215 {
216 return adoptRef(new BlobDataHandle(uuid, type, size));
217 }
218
219 String uuid() const { return m_uuid.isolatedCopy(); }
220 String type() const { return m_type.isolatedCopy(); }
221 unsigned long long size() { return m_size; }
222
210 ~BlobDataHandle(); 223 ~BlobDataHandle();
211 224
212 private: 225 private:
226 BlobDataHandle();
213 BlobDataHandle(PassOwnPtr<BlobData>, long long size); 227 BlobDataHandle(PassOwnPtr<BlobData>, long long size);
214 KURL m_internalURL; 228 BlobDataHandle(const String& uuid, const String& type, long long size);
229
230 const String m_uuid;
231 const String m_type;
232 const long long m_size;
215 }; 233 };
216 234
217 } // namespace WebCore 235 } // namespace WebCore
218 236
219 #endif // BlobData_h 237 #endif // BlobData_h
OLDNEW
« no previous file with comments | « Source/core/platform/chromium/support/WebHTTPBody.cpp ('k') | Source/core/platform/network/BlobData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698