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

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

Issue 564963002: New FormData methods: get, getAll, has, set, delete and iterable (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Implement getAll(), fix get() with no matches Created 6 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
Index: Source/core/html/FormDataList.h
diff --git a/Source/core/html/FormDataList.h b/Source/core/html/FormDataList.h
index a02fb79621c924b9ead709a69ee7bf7a0d2a75dd..2d4914e33f422917fe5e92b03682bdf6b19c34e8 100644
--- a/Source/core/html/FormDataList.h
+++ b/Source/core/html/FormDataList.h
@@ -22,6 +22,7 @@
#define FormDataList_h
#include "core/fileapi/Blob.h"
+#include "core/fileapi/File.h"
#include "platform/heap/Handle.h"
#include "platform/network/FormData.h"
#include "wtf/Forward.h"
@@ -32,6 +33,27 @@ namespace blink {
class FormDataList {
public:
+ 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.
+ public:
+ enum Type { None, StringType, FileType };
+
+ EntryValue() : m_type(None) { }
+ EntryValue(const String& string) : m_type(StringType), m_string(string) { }
+ EntryValue(PassRefPtrWillBeRawPtr<File> file) : m_type(FileType), m_file(file) { }
+
+ bool isNone() const { return m_type == None; }
+ bool isString() const { return m_type == StringType; }
+ bool isFile() const { return m_type == FileType; }
+
+ const String& string() const { ASSERT(m_type == StringType); return m_string; }
+ PassRefPtrWillBeRawPtr<File> file() const { ASSERT(m_type == FileType); return m_file; }
+
sof 2014/09/12 15:21:26 Add void trace(Visitor*); and define it as
jsbell 2014/09/12 16:30:09 Done.
+ private:
+ Type m_type;
+ String m_string;
+ RefPtrWillBeMember<File> m_file;
+ };
+
class Item {
ALLOW_ONLY_INLINE_ALLOCATION();
public:
@@ -74,6 +96,13 @@ public:
appendBlob(blob, filename);
}
+ void deleteItem(const String& key);
+ EntryValue getItem(const String& key) const;
+ Vector<EntryValue> getAll(const String& key) const;
sof 2014/09/12 15:21:26 Vector => WillBeHeapVector
jsbell 2014/09/12 16:30:10 Done.
+ bool hasItem(const String& key) const;
+ void setBlob(const String& key, PassRefPtrWillBeRawPtr<Blob>, const String& filename);
+ void setData(const String& key, const String& value);
+
const WillBeHeapVector<Item>& items() const { return m_items; }
const WTF::TextEncoding& encoding() const { return m_encoding; }
@@ -88,6 +117,9 @@ private:
void appendString(const CString&);
void appendString(const String&);
void appendBlob(PassRefPtrWillBeRawPtr<Blob>, const String& filename);
+ void setItem(const String& key, const Item&);
+ EntryValue itemToEntryValue(const Item&) const;
+ CString encodeAndNormalize(const String& key) const;
WTF::TextEncoding m_encoding;
WillBeHeapVector<Item> m_items;

Powered by Google App Engine
This is Rietveld 408576698