Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Unified Diff: Source/core/html/FormDataList.h

Issue 1314013007: Merge odd items and even items of FormDataList::m_items. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/html/FormDataList.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/FormDataList.h
diff --git a/Source/core/html/FormDataList.h b/Source/core/html/FormDataList.h
index 2cf78773690adbb62727e19181a16388af812ffc..555d26be0318142a71e7305aeced665366c16b43 100644
--- a/Source/core/html/FormDataList.h
+++ b/Source/core/html/FormDataList.h
@@ -34,6 +34,7 @@ namespace blink {
class CORE_EXPORT FormDataList : public GarbageCollected<FormDataList> {
public:
+ // TODO(tkent): Merge Entry and Item.
class Entry final {
ALLOW_ONLY_INLINE_ALLOCATION();
public:
@@ -63,10 +64,11 @@ public:
class Item {
ALLOW_ONLY_INLINE_ALLOCATION();
public:
- Item() { }
- Item(const WTF::CString& data) : m_data(data) { }
- Item(Blob* blob, const String& filename) : m_blob(blob), m_filename(filename) { }
+ Item(const CString& key) : m_key(key) { }
+ Item(const CString& key, const CString& data) : m_key(key), m_data(data) { }
+ Item(const CString& key, Blob* blob, const String& filename) : m_key(key), m_blob(blob), m_filename(filename) { }
+ const CString& key() const { return m_key; }
const WTF::CString& data() const { return m_data; }
Blob* blob() const { return m_blob.get(); }
const String& filename() const { return m_filename; }
@@ -74,6 +76,7 @@ public:
DECLARE_TRACE();
private:
+ CString m_key;
WTF::CString m_data;
Member<Blob> m_blob;
String m_filename;
@@ -88,23 +91,19 @@ public:
void appendData(const String& key, const String& value)
{
- appendString(key);
- appendString(value);
+ appendItem(Item(encodeAndNormalize(key), encodeAndNormalize(value)));
}
void appendData(const String& key, const CString& value)
{
- appendString(key);
- appendString(value);
+ appendItem(Item(encodeAndNormalize(key), value));
}
void appendData(const String& key, int value)
{
- appendString(key);
- appendString(String::number(value));
+ appendItem(Item(encodeAndNormalize(key), encodeAndNormalize(String::number(value))));
}
void appendBlob(const String& key, Blob* blob, const String& filename = String())
{
- appendString(key);
- appendBlob(blob, filename);
+ appendItem(Item(encodeAndNormalize(key), blob, filename));
}
void deleteEntry(const String& key);
@@ -114,7 +113,7 @@ public:
bool hasEntry(const String& key) const;
void setBlob(const String& key, Blob*, const String& filename);
void setData(const String& key, const String& value);
- size_t size() const { return m_items.size() / 2; }
+ size_t size() const { return m_items.size(); }
const FormDataListItems& items() const { return m_items; }
const WTF::TextEncoding& encoding() const { return m_encoding; }
@@ -130,11 +129,9 @@ protected:
private:
void appendKeyValuePairItemsTo(FormData*, const WTF::TextEncoding&, bool isMultiPartForm, FormData::EncodingType = FormData::FormURLEncoded);
- void appendString(const CString&);
- void appendString(const String&);
- void appendBlob(Blob*, const String& filename);
- void setEntry(const String& key, const Item&);
- Entry itemsToEntry(const Item& key, const Item& value) const;
+ void appendItem(const Item&);
+ void setEntry(const Item&);
+ Entry itemsToEntry(const Item&) const;
CString encodeAndNormalize(const String& key) const;
WTF::TextEncoding m_encoding;
« no previous file with comments | « no previous file | Source/core/html/FormDataList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698