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

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

Issue 11192017: ********** WebCore blob hacking (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 7 years, 11 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
« no previous file with comments | « WebCore/platform/network/BlobStorageData.h ('k') | WebCore/platform/network/FormData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #ifndef FormData_h 20 #ifndef FormData_h
21 #define FormData_h 21 #define FormData_h
22 22
23 #include "BlobData.h"
23 #include "KURL.h" 24 #include "KURL.h"
24 #include <wtf/Forward.h> 25 #include <wtf/Forward.h>
25 #include <wtf/RefCounted.h> 26 #include <wtf/RefCounted.h>
26 #include <wtf/Vector.h> 27 #include <wtf/Vector.h>
27 #include <wtf/text/WTFString.h> 28 #include <wtf/text/WTFString.h>
28 29
29 namespace WebCore { 30 namespace WebCore {
30 31
32 class BlobDataHandle;
31 class Document; 33 class Document;
32 class FormDataList; 34 class FormDataList;
33 class TextEncoding; 35 class TextEncoding;
34 36
35 class FormDataElement { 37 class FormDataElement {
36 public: 38 public:
37 FormDataElement() : m_type(data) { } 39 FormDataElement() : m_type(data) { }
38 explicit FormDataElement(const Vector<char>& array) : m_type(data), m_data(a rray) { } 40 explicit FormDataElement(const Vector<char>& array) : m_type(data), m_data(a rray) { }
39 41
40 #if ENABLE(BLOB) 42 #if ENABLE(BLOB)
41 FormDataElement(const String& filename, long long fileStart, long long fileL ength, double expectedFileModificationTime, bool shouldGenerateFile) : m_type(en codedFile), m_filename(filename), m_fileStart(fileStart), m_fileLength(fileLengt h), m_expectedFileModificationTime(expectedFileModificationTime), m_shouldGenera teFile(shouldGenerateFile) { } 43 FormDataElement(const String& filename, long long fileStart, long long fileL ength, double expectedFileModificationTime, bool shouldGenerateFile) : m_type(en codedFile), m_filename(filename), m_fileStart(fileStart), m_fileLength(fileLengt h), m_expectedFileModificationTime(expectedFileModificationTime), m_shouldGenera teFile(shouldGenerateFile) { }
42 explicit FormDataElement(const KURL& blobURL) : m_type(encodedBlob), m_url(b lobURL) { } 44 explicit FormDataElement( const String& blobUUID, PassRefPtr<BlobDataHandle> optionalblobDataHandle) : m_type(encodedBlob), m_optionalBlobDataHandle(optiona lblobDataHandle) { }
43 #else 45 #else
44 FormDataElement(const String& filename, bool shouldGenerateFile) : m_type(en codedFile), m_filename(filename), m_shouldGenerateFile(shouldGenerateFile) { } 46 FormDataElement(const String& filename, bool shouldGenerateFile) : m_type(en codedFile), m_filename(filename), m_shouldGenerateFile(shouldGenerateFile) { }
45 #endif 47 #endif
46 #if ENABLE(FILE_SYSTEM) 48 #if ENABLE(FILE_SYSTEM)
47 FormDataElement(const KURL& url, long long start, long long length, double e xpectedFileModificationTime) : m_type(encodedURL), m_url(url), m_fileStart(start ), m_fileLength(length), m_expectedFileModificationTime(expectedFileModification Time), m_shouldGenerateFile(false) { } 49 FormDataElement(const KURL& fileSystemURL, long long start, long long length , double expectedFileModificationTime) : m_type(encodedFileSystemURL), m_fileSys temURL(fileSystemURL), m_fileStart(start), m_fileLength(length), m_expectedFileM odificationTime(expectedFileModificationTime), m_shouldGenerateFile(false) { }
48 #endif 50 #endif
49 51
50 void reportMemoryUsage(MemoryObjectInfo*) const; 52 void reportMemoryUsage(MemoryObjectInfo*) const;
51 53
52 enum Type { 54 enum Type {
53 data, 55 data,
54 encodedFile 56 encodedFile
55 #if ENABLE(BLOB) 57 #if ENABLE(BLOB)
56 , encodedBlob 58 , encodedBlob
57 #endif 59 #endif
58 #if ENABLE(FILE_SYSTEM) 60 #if ENABLE(FILE_SYSTEM)
59 , encodedURL 61 , encodedFileSystemURL
60 #endif 62 #endif
61 } m_type; 63 } m_type;
62 Vector<char> m_data; 64 Vector<char> m_data;
63 String m_filename; 65 String m_filename;
64 #if ENABLE(BLOB) 66 #if ENABLE(BLOB)
65 KURL m_url; // For Blob or URL. 67 String m_blobUUID;
68 RefPtr<BlobDataHandle> m_optionalBlobDataHandle;
69 KURL m_fileSystemURL;
66 long long m_fileStart; 70 long long m_fileStart;
67 long long m_fileLength; 71 long long m_fileLength;
68 double m_expectedFileModificationTime; 72 double m_expectedFileModificationTime;
69 #endif 73 #endif
70 String m_generatedFilename; 74 String m_generatedFilename;
71 bool m_shouldGenerateFile; 75 bool m_shouldGenerateFile;
72 }; 76 };
73 77
74 inline bool operator==(const FormDataElement& a, const FormDataElement& b) 78 inline bool operator==(const FormDataElement& a, const FormDataElement& b)
75 { 79 {
76 if (&a == &b) 80 if (&a == &b)
77 return true; 81 return true;
78 82
79 if (a.m_type != b.m_type) 83 if (a.m_type != b.m_type)
80 return false; 84 return false;
81 if (a.m_type == FormDataElement::data) 85 if (a.m_type == FormDataElement::data)
82 return a.m_data == b.m_data; 86 return a.m_data == b.m_data;
83 if (a.m_type == FormDataElement::encodedFile) 87 if (a.m_type == FormDataElement::encodedFile)
84 #if ENABLE(BLOB) 88 #if ENABLE(BLOB)
85 return a.m_filename == b.m_filename && a.m_fileStart == b.m_fileStart && a.m_fileLength == b.m_fileLength && a.m_expectedFileModificationTime == b.m_exp ectedFileModificationTime; 89 return a.m_filename == b.m_filename && a.m_fileStart == b.m_fileStart && a.m_fileLength == b.m_fileLength && a.m_expectedFileModificationTime == b.m_exp ectedFileModificationTime;
86 if (a.m_type == FormDataElement::encodedBlob) 90 if (a.m_type == FormDataElement::encodedBlob)
87 return a.m_url == b.m_url; 91 return a.m_blobUUID == b.m_blobUUID;
88 #else 92 #else
89 return a.m_filename == b.m_filename; 93 return a.m_filename == b.m_filename;
90 #endif 94 #endif
91 #if ENABLE(FILE_SYSTEM) 95 #if ENABLE(FILE_SYSTEM)
92 if (a.m_type == FormDataElement::encodedURL) 96 if (a.m_type == FormDataElement::encodedFileSystemURL)
93 return a.m_url == b.m_url; 97 return a.m_fileSystemURL == b.m_fileSystemURL;
94 #endif 98 #endif
95 99
96 return true; 100 return true;
97 } 101 }
98 102
99 inline bool operator!=(const FormDataElement& a, const FormDataElement& b) 103 inline bool operator!=(const FormDataElement& a, const FormDataElement& b)
100 { 104 {
101 return !(a == b); 105 return !(a == b);
102 } 106 }
103 107
(...skipping 15 matching lines...) Expand all
119 PassRefPtr<FormData> deepCopy() const; 123 PassRefPtr<FormData> deepCopy() const;
120 ~FormData(); 124 ~FormData();
121 125
122 void encode(Encoder&) const; 126 void encode(Encoder&) const;
123 static PassRefPtr<FormData> decode(Decoder&); 127 static PassRefPtr<FormData> decode(Decoder&);
124 128
125 void appendData(const void* data, size_t); 129 void appendData(const void* data, size_t);
126 void appendFile(const String& filePath, bool shouldGenerateFile = false); 130 void appendFile(const String& filePath, bool shouldGenerateFile = false);
127 #if ENABLE(BLOB) 131 #if ENABLE(BLOB)
128 void appendFileRange(const String& filename, long long start, long long leng th, double expectedModificationTime, bool shouldGenerateFile = false); 132 void appendFileRange(const String& filename, long long start, long long leng th, double expectedModificationTime, bool shouldGenerateFile = false);
129 void appendBlob(const KURL& blobURL); 133 void appendBlob(const String& blobUUID, PassRefPtr<BlobDataHandle> optionalB lobDataHandle);
130 #endif 134 #endif
131 #if ENABLE(FILE_SYSTEM) 135 #if ENABLE(FILE_SYSTEM)
132 void appendURL(const KURL&); 136 void appendURL(const KURL&);
133 void appendURLRange(const KURL&, long long start, long long length, double e xpectedModificationTime); 137 void appendURLRange(const KURL&, long long start, long long length, double e xpectedModificationTime);
134 #endif 138 #endif
135 139
136 void flatten(Vector<char>&) const; // omits files 140 void flatten(Vector<char>&) const; // omits files
137 String flattenToString() const; // omits files 141 String flattenToString() const; // omits files
138 142
139 #if ENABLE(BLOB) 143 #if ENABLE(BLOB)
144 #if PLATFORM(CHROMIUM)
145 // Chromium doesn't store blob data in renderer processes.
146 #else
140 // Resolve all blob references so we only have file and data. 147 // Resolve all blob references so we only have file and data.
141 // If the FormData has no blob references to resolve, this is returned. 148 // If the FormData has no blob references to resolve, this is returned.
142 PassRefPtr<FormData> resolveBlobReferences(); 149 PassRefPtr<FormData> resolveBlobReferences();
143 #endif 150 #endif
151 #endif
144 152
145 bool isEmpty() const { return m_elements.isEmpty(); } 153 bool isEmpty() const { return m_elements.isEmpty(); }
146 const Vector<FormDataElement>& elements() const { return m_elements; } 154 const Vector<FormDataElement>& elements() const { return m_elements; }
147 const Vector<char>& boundary() const { return m_boundary; } 155 const Vector<char>& boundary() const { return m_boundary; }
148 156
149 void generateFiles(Document*); 157 void generateFiles(Document*);
150 void removeGeneratedFilesIfNeeded(); 158 void removeGeneratedFilesIfNeeded();
151 159
152 bool alwaysStream() const { return m_alwaysStream; } 160 bool alwaysStream() const { return m_alwaysStream; }
153 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; } 161 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 200 }
193 201
194 inline bool operator!=(const FormData& a, const FormData& b) 202 inline bool operator!=(const FormData& a, const FormData& b)
195 { 203 {
196 return !(a == b); 204 return !(a == b);
197 } 205 }
198 206
199 } // namespace WebCore 207 } // namespace WebCore
200 208
201 #endif 209 #endif
OLDNEW
« no previous file with comments | « WebCore/platform/network/BlobStorageData.h ('k') | WebCore/platform/network/FormData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698