Chromium Code Reviews| 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 "heap/Handle.h" | |
| 25 #include "platform/network/FormData.h" | 26 #include "platform/network/FormData.h" |
| 26 #include "wtf/Forward.h" | 27 #include "wtf/Forward.h" |
| 27 #include "wtf/text/CString.h" | 28 #include "wtf/text/CString.h" |
| 28 #include "wtf/text/TextEncoding.h" | 29 #include "wtf/text/TextEncoding.h" |
| 29 | 30 |
| 30 namespace WebCore { | 31 namespace WebCore { |
| 31 | 32 |
| 32 class FormDataList { | 33 class FormDataList { |
| 33 public: | 34 public: |
| 34 class Item { | 35 class Item { |
|
haraken
2014/02/24 13:49:14
Shall we add ALLOW_ONLY_INLINE_ALLOCATION?
sof
2014/02/24 17:09:09
Thanks, good idea. Done + added a comment on why.
haraken
2014/02/25 01:37:47
I'd prefer to rename ALLOW_ONLY_INLINE_ALLOCATION
| |
| 35 public: | 36 public: |
| 36 Item() { } | 37 Item() { } |
| 37 Item(const WTF::CString& data) : m_data(data) { } | 38 Item(const WTF::CString& data) : m_data(data) { } |
| 38 Item(PassRefPtr<Blob> blob, const String& filename) : m_blob(blob), m_fi lename(filename) { } | 39 Item(PassRefPtrWillBeRawPtr<Blob> blob, const String& filename) : m_blob (blob), m_filename(filename) { } |
| 39 | 40 |
| 40 const WTF::CString& data() const { return m_data; } | 41 const WTF::CString& data() const { return m_data; } |
| 41 Blob* blob() const { return m_blob.get(); } | 42 Blob* blob() const { return m_blob.get(); } |
| 42 const String& filename() const { return m_filename; } | 43 const String& filename() const { return m_filename; } |
| 43 | 44 |
| 45 void trace(Visitor*); | |
| 46 | |
| 44 private: | 47 private: |
| 45 WTF::CString m_data; | 48 WTF::CString m_data; |
| 46 RefPtr<Blob> m_blob; | 49 RefPtrWillBeMember<Blob> m_blob; |
| 47 String m_filename; | 50 String m_filename; |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 FormDataList(const WTF::TextEncoding&); | 53 FormDataList(const WTF::TextEncoding&); |
| 51 | 54 |
| 52 void appendData(const String& key, const String& value) | 55 void appendData(const String& key, const String& value) |
| 53 { | 56 { |
| 54 appendString(key); | 57 appendString(key); |
| 55 appendString(value); | 58 appendString(value); |
| 56 } | 59 } |
| 57 void appendData(const String& key, const CString& value) | 60 void appendData(const String& key, const CString& value) |
| 58 { | 61 { |
| 59 appendString(key); | 62 appendString(key); |
| 60 appendString(value); | 63 appendString(value); |
| 61 } | 64 } |
| 62 void appendData(const String& key, int value) | 65 void appendData(const String& key, int value) |
| 63 { | 66 { |
| 64 appendString(key); | 67 appendString(key); |
| 65 appendString(String::number(value)); | 68 appendString(String::number(value)); |
| 66 } | 69 } |
| 67 void appendBlob(const String& key, PassRefPtr<Blob> blob, const String& file name = String()) | 70 void appendBlob(const String& key, PassRefPtrWillBeRawPtr<Blob> blob, const String& filename = String()) |
| 68 { | 71 { |
| 69 appendString(key); | 72 appendString(key); |
| 70 appendBlob(blob, filename); | 73 appendBlob(blob, filename); |
| 71 } | 74 } |
| 72 | 75 |
| 73 const Vector<Item>& items() const { return m_items; } | 76 const WillBeHeapVector<Item>& items() const { return m_items; } |
| 74 const WTF::TextEncoding& encoding() const { return m_encoding; } | 77 const WTF::TextEncoding& encoding() const { return m_encoding; } |
| 75 | 78 |
| 76 PassRefPtr<FormData> createFormData(const WTF::TextEncoding&, FormData::Enco dingType = FormData::FormURLEncoded); | 79 PassRefPtr<FormData> createFormData(const WTF::TextEncoding&, FormData::Enco dingType = FormData::FormURLEncoded); |
| 77 PassRefPtr<FormData> createMultiPartFormData(const WTF::TextEncoding&); | 80 PassRefPtr<FormData> createMultiPartFormData(const WTF::TextEncoding&); |
| 78 | 81 |
| 82 void trace(Visitor*); | |
| 83 | |
| 79 private: | 84 private: |
| 80 void appendKeyValuePairItemsTo(FormData*, const WTF::TextEncoding&, bool isM ultiPartForm, FormData::EncodingType = FormData::FormURLEncoded); | 85 void appendKeyValuePairItemsTo(FormData*, const WTF::TextEncoding&, bool isM ultiPartForm, FormData::EncodingType = FormData::FormURLEncoded); |
| 81 | 86 |
| 82 void appendString(const CString&); | 87 void appendString(const CString&); |
| 83 void appendString(const String&); | 88 void appendString(const String&); |
| 84 void appendBlob(PassRefPtr<Blob>, const String& filename); | 89 void appendBlob(PassRefPtrWillBeRawPtr<Blob>, const String& filename); |
| 85 | 90 |
| 86 WTF::TextEncoding m_encoding; | 91 WTF::TextEncoding m_encoding; |
| 87 Vector<Item> m_items; | 92 WillBeHeapVector<Item> m_items; |
| 88 }; | 93 }; |
| 89 | 94 |
| 90 } // namespace WebCore | 95 } // namespace WebCore |
| 91 | 96 |
| 92 #endif // FormDataList_h | 97 #endif // FormDataList_h |
| OLD | NEW |