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 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 Entry(const String& name, File* value) : m_type(FileType), m_name(name),
m_file(value) { } | 44 Entry(const String& name, File* value) : m_type(FileType), m_name(name),
m_file(value) { } |
45 | 45 |
46 bool isNone() const { return m_type == None; } | 46 bool isNone() const { return m_type == None; } |
47 bool isString() const { return m_type == StringType; } | 47 bool isString() const { return m_type == StringType; } |
48 bool isFile() const { return m_type == FileType; } | 48 bool isFile() const { return m_type == FileType; } |
49 | 49 |
50 const String& name() const { ASSERT(m_type != None); return m_name; } | 50 const String& name() const { ASSERT(m_type != None); return m_name; } |
51 const String& string() const { ASSERT(m_type == StringType); return m_st
ring; } | 51 const String& string() const { ASSERT(m_type == StringType); return m_st
ring; } |
52 File* file() const { ASSERT(m_type == FileType); return m_file; } | 52 File* file() const { ASSERT(m_type == FileType); return m_file; } |
53 | 53 |
54 void trace(Visitor*); | 54 DECLARE_TRACE(); |
55 | 55 |
56 private: | 56 private: |
57 const Type m_type; | 57 const Type m_type; |
58 const String m_name; | 58 const String m_name; |
59 const String m_string; | 59 const String m_string; |
60 const Member<File> m_file; | 60 const Member<File> m_file; |
61 }; | 61 }; |
62 | 62 |
63 class Item { | 63 class Item { |
64 ALLOW_ONLY_INLINE_ALLOCATION(); | 64 ALLOW_ONLY_INLINE_ALLOCATION(); |
65 public: | 65 public: |
66 Item() { } | 66 Item() { } |
67 Item(const WTF::CString& data) : m_data(data) { } | 67 Item(const WTF::CString& data) : m_data(data) { } |
68 Item(Blob* blob, const String& filename) : m_blob(blob), m_filename(file
name) { } | 68 Item(Blob* blob, const String& filename) : m_blob(blob), m_filename(file
name) { } |
69 | 69 |
70 const WTF::CString& data() const { return m_data; } | 70 const WTF::CString& data() const { return m_data; } |
71 Blob* blob() const { return m_blob.get(); } | 71 Blob* blob() const { return m_blob.get(); } |
72 const String& filename() const { return m_filename; } | 72 const String& filename() const { return m_filename; } |
73 | 73 |
74 void trace(Visitor*); | 74 DECLARE_TRACE(); |
75 | 75 |
76 private: | 76 private: |
77 WTF::CString m_data; | 77 WTF::CString m_data; |
78 Member<Blob> m_blob; | 78 Member<Blob> m_blob; |
79 String m_filename; | 79 String m_filename; |
80 }; | 80 }; |
81 | 81 |
82 static PassRefPtrWillBeRawPtr<FormDataList> create(const WTF::TextEncoding&
encoding) | 82 static PassRefPtrWillBeRawPtr<FormDataList> create(const WTF::TextEncoding&
encoding) |
83 { | 83 { |
84 return adoptRefWillBeNoop(new FormDataList(encoding)); | 84 return adoptRefWillBeNoop(new FormDataList(encoding)); |
(...skipping 30 matching lines...) Expand all Loading... |
115 void setBlob(const String& key, Blob*, const String& filename); | 115 void setBlob(const String& key, Blob*, const String& filename); |
116 void setData(const String& key, const String& value); | 116 void setData(const String& key, const String& value); |
117 size_t size() const { return m_items.size() / 2; } | 117 size_t size() const { return m_items.size() / 2; } |
118 | 118 |
119 const FormDataListItems& items() const { return m_items; } | 119 const FormDataListItems& items() const { return m_items; } |
120 const WTF::TextEncoding& encoding() const { return m_encoding; } | 120 const WTF::TextEncoding& encoding() const { return m_encoding; } |
121 | 121 |
122 PassRefPtr<FormData> createFormData(FormData::EncodingType = FormData::FormU
RLEncoded); | 122 PassRefPtr<FormData> createFormData(FormData::EncodingType = FormData::FormU
RLEncoded); |
123 PassRefPtr<FormData> createMultiPartFormData(); | 123 PassRefPtr<FormData> createMultiPartFormData(); |
124 | 124 |
125 virtual void trace(Visitor*); | 125 DECLARE_VIRTUAL_TRACE(); |
126 | 126 |
127 protected: | 127 protected: |
128 explicit FormDataList(const WTF::TextEncoding&); | 128 explicit FormDataList(const WTF::TextEncoding&); |
129 | 129 |
130 private: | 130 private: |
131 void appendKeyValuePairItemsTo(FormData*, const WTF::TextEncoding&, bool isM
ultiPartForm, FormData::EncodingType = FormData::FormURLEncoded); | 131 void appendKeyValuePairItemsTo(FormData*, const WTF::TextEncoding&, bool isM
ultiPartForm, FormData::EncodingType = FormData::FormURLEncoded); |
132 | 132 |
133 void appendString(const CString&); | 133 void appendString(const CString&); |
134 void appendString(const String&); | 134 void appendString(const String&); |
135 void appendBlob(Blob*, const String& filename); | 135 void appendBlob(Blob*, const String& filename); |
136 void setEntry(const String& key, const Item&); | 136 void setEntry(const String& key, const Item&); |
137 Entry itemsToEntry(const Item& key, const Item& value) const; | 137 Entry itemsToEntry(const Item& key, const Item& value) const; |
138 CString encodeAndNormalize(const String& key) const; | 138 CString encodeAndNormalize(const String& key) const; |
139 | 139 |
140 WTF::TextEncoding m_encoding; | 140 WTF::TextEncoding m_encoding; |
141 FormDataListItems m_items; | 141 FormDataListItems m_items; |
142 }; | 142 }; |
143 | 143 |
144 } // namespace blink | 144 } // namespace blink |
145 | 145 |
146 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Entry); | 146 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Entry); |
147 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Item); | 147 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Item); |
148 | 148 |
149 #endif // FormDataList_h | 149 #endif // FormDataList_h |
OLD | NEW |