OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 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 | 20 |
21 #ifndef FormDataList_h | 21 #ifndef FormDataList_h |
22 #define FormDataList_h | 22 #define FormDataList_h |
23 | 23 |
24 #include "core/fileapi/Blob.h" | 24 #include "core/fileapi/Blob.h" |
25 #include "core/fileapi/File.h" | |
25 #include "platform/heap/Handle.h" | 26 #include "platform/heap/Handle.h" |
26 #include "platform/network/FormData.h" | 27 #include "platform/network/FormData.h" |
27 #include "wtf/Forward.h" | 28 #include "wtf/Forward.h" |
28 #include "wtf/text/CString.h" | 29 #include "wtf/text/CString.h" |
29 #include "wtf/text/TextEncoding.h" | 30 #include "wtf/text/TextEncoding.h" |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 class FormDataList { | 34 class FormDataList { |
34 public: | 35 public: |
36 class EntryValue { | |
sof
2014/09/12 15:21:26
Add FINAL
sof
2014/09/12 15:21:26
Add ALLOW_ONLY_INLINE_ALLOCATION();
jsbell
2014/09/12 16:30:09
Done.
jsbell
2014/09/12 16:30:10
Done.
| |
37 public: | |
38 enum Type { None, StringType, FileType }; | |
39 | |
40 EntryValue() : m_type(None) { } | |
41 EntryValue(const String& string) : m_type(StringType), m_string(string) { } | |
42 EntryValue(PassRefPtrWillBeRawPtr<File> file) : m_type(FileType), m_file (file) { } | |
43 | |
44 bool isNone() const { return m_type == None; } | |
45 bool isString() const { return m_type == StringType; } | |
46 bool isFile() const { return m_type == FileType; } | |
47 | |
48 const String& string() const { ASSERT(m_type == StringType); return m_st ring; } | |
49 PassRefPtrWillBeRawPtr<File> file() const { ASSERT(m_type == FileType); return m_file; } | |
50 | |
sof
2014/09/12 15:21:26
Add
void trace(Visitor*);
and define it as
jsbell
2014/09/12 16:30:09
Done.
| |
51 private: | |
52 Type m_type; | |
53 String m_string; | |
54 RefPtrWillBeMember<File> m_file; | |
55 }; | |
56 | |
35 class Item { | 57 class Item { |
36 ALLOW_ONLY_INLINE_ALLOCATION(); | 58 ALLOW_ONLY_INLINE_ALLOCATION(); |
37 public: | 59 public: |
38 Item() { } | 60 Item() { } |
39 Item(const WTF::CString& data) : m_data(data) { } | 61 Item(const WTF::CString& data) : m_data(data) { } |
40 Item(PassRefPtrWillBeRawPtr<Blob> blob, const String& filename) : m_blob (blob), m_filename(filename) { } | 62 Item(PassRefPtrWillBeRawPtr<Blob> blob, const String& filename) : m_blob (blob), m_filename(filename) { } |
41 | 63 |
42 const WTF::CString& data() const { return m_data; } | 64 const WTF::CString& data() const { return m_data; } |
43 Blob* blob() const { return m_blob.get(); } | 65 Blob* blob() const { return m_blob.get(); } |
44 const String& filename() const { return m_filename; } | 66 const String& filename() const { return m_filename; } |
(...skipping 22 matching lines...) Expand all Loading... | |
67 { | 89 { |
68 appendString(key); | 90 appendString(key); |
69 appendString(String::number(value)); | 91 appendString(String::number(value)); |
70 } | 92 } |
71 void appendBlob(const String& key, PassRefPtrWillBeRawPtr<Blob> blob, const String& filename = String()) | 93 void appendBlob(const String& key, PassRefPtrWillBeRawPtr<Blob> blob, const String& filename = String()) |
72 { | 94 { |
73 appendString(key); | 95 appendString(key); |
74 appendBlob(blob, filename); | 96 appendBlob(blob, filename); |
75 } | 97 } |
76 | 98 |
99 void deleteItem(const String& key); | |
100 EntryValue getItem(const String& key) const; | |
101 Vector<EntryValue> getAll(const String& key) const; | |
sof
2014/09/12 15:21:26
Vector => WillBeHeapVector
jsbell
2014/09/12 16:30:10
Done.
| |
102 bool hasItem(const String& key) const; | |
103 void setBlob(const String& key, PassRefPtrWillBeRawPtr<Blob>, const String& filename); | |
104 void setData(const String& key, const String& value); | |
105 | |
77 const WillBeHeapVector<Item>& items() const { return m_items; } | 106 const WillBeHeapVector<Item>& items() const { return m_items; } |
78 const WTF::TextEncoding& encoding() const { return m_encoding; } | 107 const WTF::TextEncoding& encoding() const { return m_encoding; } |
79 | 108 |
80 PassRefPtr<FormData> createFormData(FormData::EncodingType = FormData::FormU RLEncoded); | 109 PassRefPtr<FormData> createFormData(FormData::EncodingType = FormData::FormU RLEncoded); |
81 PassRefPtr<FormData> createMultiPartFormData(); | 110 PassRefPtr<FormData> createMultiPartFormData(); |
82 | 111 |
83 void trace(Visitor*); | 112 void trace(Visitor*); |
84 | 113 |
85 private: | 114 private: |
86 void appendKeyValuePairItemsTo(FormData*, const WTF::TextEncoding&, bool isM ultiPartForm, FormData::EncodingType = FormData::FormURLEncoded); | 115 void appendKeyValuePairItemsTo(FormData*, const WTF::TextEncoding&, bool isM ultiPartForm, FormData::EncodingType = FormData::FormURLEncoded); |
87 | 116 |
88 void appendString(const CString&); | 117 void appendString(const CString&); |
89 void appendString(const String&); | 118 void appendString(const String&); |
90 void appendBlob(PassRefPtrWillBeRawPtr<Blob>, const String& filename); | 119 void appendBlob(PassRefPtrWillBeRawPtr<Blob>, const String& filename); |
120 void setItem(const String& key, const Item&); | |
121 EntryValue itemToEntryValue(const Item&) const; | |
122 CString encodeAndNormalize(const String& key) const; | |
91 | 123 |
92 WTF::TextEncoding m_encoding; | 124 WTF::TextEncoding m_encoding; |
93 WillBeHeapVector<Item> m_items; | 125 WillBeHeapVector<Item> m_items; |
94 }; | 126 }; |
95 | 127 |
96 } // namespace blink | 128 } // namespace blink |
97 | 129 |
98 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Item); | 130 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Item); |
99 | 131 |
100 #endif // FormDataList_h | 132 #endif // FormDataList_h |
OLD | NEW |