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 "core/platform/network/BlobData.h" |
23 #include "weborigin/KURL.h" | 24 #include "weborigin/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 WTF{ | 30 namespace WTF{ |
30 class TextEncoding; | 31 class TextEncoding; |
31 } | 32 } |
32 | 33 |
33 namespace WebCore { | 34 namespace WebCore { |
34 | 35 |
| 36 class BlobDataHandle; |
35 class Document; | 37 class Document; |
36 class FormDataList; | 38 class FormDataList; |
37 | 39 |
38 class FormDataElement { | 40 class FormDataElement { |
39 public: | 41 public: |
40 FormDataElement() : m_type(data) { } | 42 FormDataElement() : m_type(data) { } |
41 explicit FormDataElement(const Vector<char>& array) : m_type(data), m_data(a
rray) { } | 43 explicit FormDataElement(const Vector<char>& array) : m_type(data), m_data(a
rray) { } |
42 | 44 |
43 FormDataElement(const String& filename, long long fileStart, long long fileL
ength, double expectedFileModificationTime) : m_type(encodedFile), m_filename(fi
lename), m_fileStart(fileStart), m_fileLength(fileLength), m_expectedFileModific
ationTime(expectedFileModificationTime) { } | 45 FormDataElement(const String& filename, long long fileStart, long long fileL
ength, double expectedFileModificationTime) : m_type(encodedFile), m_filename(fi
lename), m_fileStart(fileStart), m_fileLength(fileLength), m_expectedFileModific
ationTime(expectedFileModificationTime) { } |
44 explicit FormDataElement(const KURL& blobURL) : m_type(encodedBlob), m_url(b
lobURL) { } | 46 explicit FormDataElement(const String& blobUUID, PassRefPtr<BlobDataHandle>
optionalHandle) : m_type(encodedBlob), m_blobUUID(blobUUID), m_optionalBlobDataH
andle(optionalHandle) { } |
45 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) { } | 47 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) { } |
46 | 48 |
47 enum Type { | 49 enum Type { |
48 data, | 50 data, |
49 encodedFile | 51 encodedFile, |
50 , encodedBlob | 52 encodedBlob, |
51 , encodedURL | 53 encodedFileSystemURL |
52 } m_type; | 54 } m_type; |
53 Vector<char> m_data; | 55 Vector<char> m_data; |
54 String m_filename; | 56 String m_filename; |
55 KURL m_url; // For Blob or URL. | 57 String m_blobUUID; |
| 58 RefPtr<BlobDataHandle> m_optionalBlobDataHandle; |
| 59 KURL m_fileSystemURL; |
56 long long m_fileStart; | 60 long long m_fileStart; |
57 long long m_fileLength; | 61 long long m_fileLength; |
58 double m_expectedFileModificationTime; | 62 double m_expectedFileModificationTime; |
59 }; | 63 }; |
60 | 64 |
61 inline bool operator==(const FormDataElement& a, const FormDataElement& b) | 65 inline bool operator==(const FormDataElement& a, const FormDataElement& b) |
62 { | 66 { |
63 if (&a == &b) | 67 if (&a == &b) |
64 return true; | 68 return true; |
65 | 69 |
66 if (a.m_type != b.m_type) | 70 if (a.m_type != b.m_type) |
67 return false; | 71 return false; |
68 if (a.m_type == FormDataElement::data) | 72 if (a.m_type == FormDataElement::data) |
69 return a.m_data == b.m_data; | 73 return a.m_data == b.m_data; |
70 if (a.m_type == FormDataElement::encodedFile) | 74 if (a.m_type == FormDataElement::encodedFile) |
71 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; | 75 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; |
72 if (a.m_type == FormDataElement::encodedBlob) | 76 if (a.m_type == FormDataElement::encodedBlob) |
73 return a.m_url == b.m_url; | 77 return a.m_blobUUID == b.m_blobUUID; |
74 if (a.m_type == FormDataElement::encodedURL) | 78 if (a.m_type == FormDataElement::encodedFileSystemURL) |
75 return a.m_url == b.m_url; | 79 return a.m_fileSystemURL == b.m_fileSystemURL; |
76 | 80 |
77 return true; | 81 return true; |
78 } | 82 } |
79 | 83 |
80 inline bool operator!=(const FormDataElement& a, const FormDataElement& b) | 84 inline bool operator!=(const FormDataElement& a, const FormDataElement& b) |
81 { | 85 { |
82 return !(a == b); | 86 return !(a == b); |
83 } | 87 } |
84 | 88 |
85 class FormData : public RefCounted<FormData> { | 89 class FormData : public RefCounted<FormData> { |
(...skipping 10 matching lines...) Expand all Loading... |
96 static PassRefPtr<FormData> create(const Vector<char>&); | 100 static PassRefPtr<FormData> create(const Vector<char>&); |
97 static PassRefPtr<FormData> create(const FormDataList&, const WTF::TextEncod
ing&, EncodingType = FormURLEncoded); | 101 static PassRefPtr<FormData> create(const FormDataList&, const WTF::TextEncod
ing&, EncodingType = FormURLEncoded); |
98 static PassRefPtr<FormData> createMultiPart(const FormDataList&, const WTF::
TextEncoding&, Document*); | 102 static PassRefPtr<FormData> createMultiPart(const FormDataList&, const WTF::
TextEncoding&, Document*); |
99 PassRefPtr<FormData> copy() const; | 103 PassRefPtr<FormData> copy() const; |
100 PassRefPtr<FormData> deepCopy() const; | 104 PassRefPtr<FormData> deepCopy() const; |
101 ~FormData(); | 105 ~FormData(); |
102 | 106 |
103 void appendData(const void* data, size_t); | 107 void appendData(const void* data, size_t); |
104 void appendFile(const String& filePath); | 108 void appendFile(const String& filePath); |
105 void appendFileRange(const String& filename, long long start, long long leng
th, double expectedModificationTime); | 109 void appendFileRange(const String& filename, long long start, long long leng
th, double expectedModificationTime); |
106 void appendBlob(const KURL& blobURL); | 110 void appendBlob(const String& blobUUID, PassRefPtr<BlobDataHandle> optionalH
andle); |
107 void appendURL(const KURL&); | 111 void appendFileSystemURL(const KURL&); |
108 void appendURLRange(const KURL&, long long start, long long length, double e
xpectedModificationTime); | 112 void appendFileSystemURLRange(const KURL&, long long start, long long length
, double expectedModificationTime); |
109 | 113 |
110 void flatten(Vector<char>&) const; // omits files | 114 void flatten(Vector<char>&) const; // omits files |
111 String flattenToString() const; // omits files | 115 String flattenToString() const; // omits files |
112 | 116 |
113 bool isEmpty() const { return m_elements.isEmpty(); } | 117 bool isEmpty() const { return m_elements.isEmpty(); } |
114 const Vector<FormDataElement>& elements() const { return m_elements; } | 118 const Vector<FormDataElement>& elements() const { return m_elements; } |
115 const Vector<char>& boundary() const { return m_boundary; } | 119 const Vector<char>& boundary() const { return m_boundary; } |
116 | 120 |
117 bool alwaysStream() const { return m_alwaysStream; } | 121 bool alwaysStream() const { return m_alwaysStream; } |
118 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; } | 122 void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 158 } |
155 | 159 |
156 inline bool operator!=(const FormData& a, const FormData& b) | 160 inline bool operator!=(const FormData& a, const FormData& b) |
157 { | 161 { |
158 return !(a == b); | 162 return !(a == b); |
159 } | 163 } |
160 | 164 |
161 } // namespace WebCore | 165 } // namespace WebCore |
162 | 166 |
163 #endif | 167 #endif |
OLD | NEW |