OLD | NEW |
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 enum Type { | 52 enum Type { |
51 data, | 53 data, |
52 encodedFile | 54 encodedFile |
53 #if ENABLE(BLOB) | 55 #if ENABLE(BLOB) |
54 , encodedBlob | 56 , encodedBlob |
55 #endif | 57 #endif |
56 #if ENABLE(FILE_SYSTEM) | 58 #if ENABLE(FILE_SYSTEM) |
57 , encodedURL | 59 , encodedFileSystemURL |
58 #endif | 60 #endif |
59 } m_type; | 61 } m_type; |
60 Vector<char> m_data; | 62 Vector<char> m_data; |
61 String m_filename; | 63 String m_filename; |
62 #if ENABLE(BLOB) | 64 #if ENABLE(BLOB) |
63 KURL m_url; // For Blob or URL. | 65 String m_blobUUID; |
| 66 RefPtr<BlobDataHandle> m_optionalBlobDataHandle; |
| 67 KURL m_fileSystemURL; |
64 long long m_fileStart; | 68 long long m_fileStart; |
65 long long m_fileLength; | 69 long long m_fileLength; |
66 double m_expectedFileModificationTime; | 70 double m_expectedFileModificationTime; |
67 #endif | 71 #endif |
68 String m_generatedFilename; | 72 String m_generatedFilename; |
69 bool m_shouldGenerateFile; | 73 bool m_shouldGenerateFile; |
70 }; | 74 }; |
71 | 75 |
72 inline bool operator==(const FormDataElement& a, const FormDataElement& b) | 76 inline bool operator==(const FormDataElement& a, const FormDataElement& b) |
73 { | 77 { |
74 if (&a == &b) | 78 if (&a == &b) |
75 return true; | 79 return true; |
76 | 80 |
77 if (a.m_type != b.m_type) | 81 if (a.m_type != b.m_type) |
78 return false; | 82 return false; |
79 if (a.m_type == FormDataElement::data) | 83 if (a.m_type == FormDataElement::data) |
80 return a.m_data == b.m_data; | 84 return a.m_data == b.m_data; |
81 if (a.m_type == FormDataElement::encodedFile) | 85 if (a.m_type == FormDataElement::encodedFile) |
82 #if ENABLE(BLOB) | 86 #if ENABLE(BLOB) |
83 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; | 87 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; |
84 if (a.m_type == FormDataElement::encodedBlob) | 88 if (a.m_type == FormDataElement::encodedBlob) |
85 return a.m_url == b.m_url; | 89 return a.m_blobUUID == b.m_blobUUID; |
86 #else | 90 #else |
87 return a.m_filename == b.m_filename; | 91 return a.m_filename == b.m_filename; |
88 #endif | 92 #endif |
89 #if ENABLE(FILE_SYSTEM) | 93 #if ENABLE(FILE_SYSTEM) |
90 if (a.m_type == FormDataElement::encodedURL) | 94 if (a.m_type == FormDataElement::encodedFileSystemURL) |
91 return a.m_url == b.m_url; | 95 return a.m_fileSystemURL == b.m_fileSystemURL; |
92 #endif | 96 #endif |
93 | 97 |
94 return true; | 98 return true; |
95 } | 99 } |
96 | 100 |
97 inline bool operator!=(const FormDataElement& a, const FormDataElement& b) | 101 inline bool operator!=(const FormDataElement& a, const FormDataElement& b) |
98 { | 102 { |
99 return !(a == b); | 103 return !(a == b); |
100 } | 104 } |
101 | 105 |
(...skipping 15 matching lines...) Expand all Loading... |
117 PassRefPtr<FormData> deepCopy() const; | 121 PassRefPtr<FormData> deepCopy() const; |
118 ~FormData(); | 122 ~FormData(); |
119 | 123 |
120 void encodeForBackForward(Encoder&) const; | 124 void encodeForBackForward(Encoder&) const; |
121 static PassRefPtr<FormData> decodeForBackForward(Decoder&); | 125 static PassRefPtr<FormData> decodeForBackForward(Decoder&); |
122 | 126 |
123 void appendData(const void* data, size_t); | 127 void appendData(const void* data, size_t); |
124 void appendFile(const String& filePath, bool shouldGenerateFile = false); | 128 void appendFile(const String& filePath, bool shouldGenerateFile = false); |
125 #if ENABLE(BLOB) | 129 #if ENABLE(BLOB) |
126 void appendFileRange(const String& filename, long long start, long long leng
th, double expectedModificationTime, bool shouldGenerateFile = false); | 130 void appendFileRange(const String& filename, long long start, long long leng
th, double expectedModificationTime, bool shouldGenerateFile = false); |
127 void appendBlob(const KURL& blobURL); | 131 void appendBlob(const String& blobUUID, PassRefPtr<BlobDataHandle> optionalB
lobDataHandle); |
128 #endif | 132 #endif |
129 #if ENABLE(FILE_SYSTEM) | 133 #if ENABLE(FILE_SYSTEM) |
130 void appendURL(const KURL&); | 134 void appendURL(const KURL&); |
131 void appendURLRange(const KURL&, long long start, long long length, double e
xpectedModificationTime); | 135 void appendURLRange(const KURL&, long long start, long long length, double e
xpectedModificationTime); |
132 #endif | 136 #endif |
133 | 137 |
134 void flatten(Vector<char>&) const; // omits files | 138 void flatten(Vector<char>&) const; // omits files |
135 String flattenToString() const; // omits files | 139 String flattenToString() const; // omits files |
136 | 140 |
137 #if ENABLE(BLOB) | 141 #if ENABLE(BLOB) |
| 142 #if PLATFORM(CHROMIUM) |
| 143 // Chromium doesn't store blob data in renderer processes. |
| 144 #else |
138 // Resolve all blob references so we only have file and data. | 145 // Resolve all blob references so we only have file and data. |
139 // If the FormData has no blob references to resolve, this is returned. | 146 // If the FormData has no blob references to resolve, this is returned. |
140 PassRefPtr<FormData> resolveBlobReferences(); | 147 PassRefPtr<FormData> resolveBlobReferences(); |
141 #endif | 148 #endif |
| 149 #endif |
142 | 150 |
143 bool isEmpty() const { return m_elements.isEmpty(); } | 151 bool isEmpty() const { return m_elements.isEmpty(); } |
144 const Vector<FormDataElement>& elements() const { return m_elements; } | 152 const Vector<FormDataElement>& elements() const { return m_elements; } |
145 const Vector<char>& boundary() const { return m_boundary; } | 153 const Vector<char>& boundary() const { return m_boundary; } |
146 | 154 |
147 void generateFiles(Document*); | 155 void generateFiles(Document*); |
148 void removeGeneratedFilesIfNeeded(); | 156 void removeGeneratedFilesIfNeeded(); |
149 | 157 |
150 bool alwaysStream() const { return m_alwaysStream; } | 158 bool alwaysStream() const { return m_alwaysStream; } |
151 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; } | 159 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 198 } |
191 | 199 |
192 inline bool operator!=(const FormData& a, const FormData& b) | 200 inline bool operator!=(const FormData& a, const FormData& b) |
193 { | 201 { |
194 return !(a == b); | 202 return !(a == b); |
195 } | 203 } |
196 | 204 |
197 } // namespace WebCore | 205 } // namespace WebCore |
198 | 206 |
199 #endif | 207 #endif |
OLD | NEW |