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 14 matching lines...) Expand all Loading... |
25 #include "core/fileapi/Blob.h" | 25 #include "core/fileapi/Blob.h" |
26 #include "core/fileapi/File.h" | 26 #include "core/fileapi/File.h" |
27 #include "platform/heap/Handle.h" | 27 #include "platform/heap/Handle.h" |
28 #include "platform/network/FormData.h" | 28 #include "platform/network/FormData.h" |
29 #include "wtf/Forward.h" | 29 #include "wtf/Forward.h" |
30 #include "wtf/text/CString.h" | 30 #include "wtf/text/CString.h" |
31 #include "wtf/text/TextEncoding.h" | 31 #include "wtf/text/TextEncoding.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 class CORE_EXPORT FormDataList : public RefCountedWillBeGarbageCollected<FormDat
aList> { | 35 class CORE_EXPORT FormDataList : public GarbageCollected<FormDataList> { |
36 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(FormDataList); | |
37 public: | 36 public: |
38 class Entry final { | 37 class Entry final { |
39 ALLOW_ONLY_INLINE_ALLOCATION(); | 38 ALLOW_ONLY_INLINE_ALLOCATION(); |
40 public: | 39 public: |
41 enum Type { None, StringType, FileType }; | 40 enum Type { None, StringType, FileType }; |
42 | 41 |
43 Entry() : m_type(None) { } | 42 Entry() : m_type(None) { } |
44 Entry(const String& name, const String& value) : m_type(StringType), m_n
ame(name), m_string(value) { } | 43 Entry(const String& name, const String& value) : m_type(StringType), m_n
ame(name), m_string(value) { } |
45 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) { } |
46 | 45 |
(...skipping 26 matching lines...) Expand all Loading... |
73 const String& filename() const { return m_filename; } | 72 const String& filename() const { return m_filename; } |
74 | 73 |
75 DECLARE_TRACE(); | 74 DECLARE_TRACE(); |
76 | 75 |
77 private: | 76 private: |
78 WTF::CString m_data; | 77 WTF::CString m_data; |
79 Member<Blob> m_blob; | 78 Member<Blob> m_blob; |
80 String m_filename; | 79 String m_filename; |
81 }; | 80 }; |
82 | 81 |
83 static PassRefPtrWillBeRawPtr<FormDataList> create(const WTF::TextEncoding&
encoding) | 82 static FormDataList* create(const WTF::TextEncoding& encoding) |
84 { | 83 { |
85 return adoptRefWillBeNoop(new FormDataList(encoding)); | 84 return new FormDataList(encoding); |
86 } | 85 } |
87 | 86 |
88 typedef PersistentHeapVectorWillBeHeapVector<FormDataList::Item> FormDataLis
tItems; | 87 using FormDataListItems = HeapVector<FormDataList::Item>; |
89 | 88 |
90 void appendData(const String& key, const String& value) | 89 void appendData(const String& key, const String& value) |
91 { | 90 { |
92 appendString(key); | 91 appendString(key); |
93 appendString(value); | 92 appendString(value); |
94 } | 93 } |
95 void appendData(const String& key, const CString& value) | 94 void appendData(const String& key, const CString& value) |
96 { | 95 { |
97 appendString(key); | 96 appendString(key); |
98 appendString(value); | 97 appendString(value); |
99 } | 98 } |
100 void appendData(const String& key, int value) | 99 void appendData(const String& key, int value) |
101 { | 100 { |
102 appendString(key); | 101 appendString(key); |
103 appendString(String::number(value)); | 102 appendString(String::number(value)); |
104 } | 103 } |
105 void appendBlob(const String& key, Blob* blob, const String& filename = Stri
ng()) | 104 void appendBlob(const String& key, Blob* blob, const String& filename = Stri
ng()) |
106 { | 105 { |
107 appendString(key); | 106 appendString(key); |
108 appendBlob(blob, filename); | 107 appendBlob(blob, filename); |
109 } | 108 } |
110 | 109 |
111 void deleteEntry(const String& key); | 110 void deleteEntry(const String& key); |
112 Entry getEntry(const String& key) const; | 111 Entry getEntry(const String& key) const; |
113 Entry getEntry(size_t index) const; | 112 Entry getEntry(size_t index) const; |
114 WillBeHeapVector<Entry> getAll(const String& key) const; | 113 HeapVector<Entry> getAll(const String& key) const; |
115 bool hasEntry(const String& key) const; | 114 bool hasEntry(const String& key) const; |
116 void setBlob(const String& key, Blob*, const String& filename); | 115 void setBlob(const String& key, Blob*, const String& filename); |
117 void setData(const String& key, const String& value); | 116 void setData(const String& key, const String& value); |
118 size_t size() const { return m_items.size() / 2; } | 117 size_t size() const { return m_items.size() / 2; } |
119 | 118 |
120 const FormDataListItems& items() const { return m_items; } | 119 const FormDataListItems& items() const { return m_items; } |
121 const WTF::TextEncoding& encoding() const { return m_encoding; } | 120 const WTF::TextEncoding& encoding() const { return m_encoding; } |
122 | 121 |
123 PassRefPtr<FormData> createFormData(FormData::EncodingType = FormData::FormU
RLEncoded); | 122 PassRefPtr<FormData> createFormData(FormData::EncodingType = FormData::FormU
RLEncoded); |
124 PassRefPtr<FormData> createMultiPartFormData(); | 123 PassRefPtr<FormData> createMultiPartFormData(); |
(...skipping 16 matching lines...) Expand all Loading... |
141 WTF::TextEncoding m_encoding; | 140 WTF::TextEncoding m_encoding; |
142 FormDataListItems m_items; | 141 FormDataListItems m_items; |
143 }; | 142 }; |
144 | 143 |
145 } // namespace blink | 144 } // namespace blink |
146 | 145 |
147 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Entry); | 146 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Entry); |
148 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Item); | 147 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Item); |
149 | 148 |
150 #endif // FormDataList_h | 149 #endif // FormDataList_h |
OLD | NEW |