Commit fd0384db authored by tkent@chromium.org's avatar tkent@chromium.org

Move FormDataList::deleteEntry() and hasEntry() to DOMFormData.

- Move FormDataList::deleteEntry() to DOMFormData
- Fold FormDataList::hasEntry() into DOMFormData::has().

This CL has no behavior changes.

BUG=528840

Review URL: https://codereview.chromium.org/1308183006

git-svn-id: svn://svn.chromium.org/blink/trunk@201951 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent febb09a0
......@@ -120,6 +120,19 @@ void DOMFormData::append(ExecutionContext* context, const String& name, Blob* bl
appendBlob(name, blob, filename);
}
void DOMFormData::deleteEntry(const String& name)
{
const CString keyData = encodeAndNormalize(name);
size_t i = 0;
while (i < m_items.size()) {
if (m_items[i].key() == keyData) {
m_items.remove(i);
} else {
++i;
}
}
}
void DOMFormData::get(const String& name, FormDataEntryValue& result)
{
if (m_opaque)
......@@ -160,7 +173,12 @@ bool DOMFormData::has(const String& name)
{
if (m_opaque)
return false;
return hasEntry(name);
const CString keyData = encodeAndNormalize(name);
for (const Item& item : items()) {
if (item.key() == keyData)
return true;
}
return false;
}
void DOMFormData::set(const String& name, const String& value)
......
......@@ -68,6 +68,7 @@ public:
// FormData interface.
void append(const String& name, const String& value);
void append(ExecutionContext*, const String& name, Blob*, const String& filename = String());
void deleteEntry(const String& name);
void get(const String& name, FormDataEntryValue& result);
HeapVector<FormDataEntryValue> getAll(const String& name);
bool has(const String& name);
......
......@@ -63,15 +63,15 @@ TEST(DOMFormDataTest, opacityHas)
fd->append("name1", "value1");
EXPECT_TRUE(fd->has("name1"));
EXPECT_TRUE(fd->hasEntry("name1"));
EXPECT_EQ(1u, fd->size());
fd->makeOpaque();
// Web-exposed interface should be opaque.
EXPECT_FALSE(fd->has("name1"));
// Internal interface should be uneffected.
EXPECT_TRUE(fd->hasEntry("name1"));
// Internal collection should be uneffected.
EXPECT_EQ(1u, fd->size());
}
} // namespace blink
......@@ -38,20 +38,6 @@ void FormDataList::appendItem(const FormDataList::Item& item)
m_items.append(item);
}
void FormDataList::deleteEntry(const String& key)
{
const CString keyData = encodeAndNormalize(key);
size_t i = 0;
while (i < m_items.size()) {
if (m_items[i].key() == keyData) {
m_items.remove(i);
} else {
++i;
}
}
return;
}
FormDataList::Entry FormDataList::getEntry(const String& key) const
{
const CString keyData = encodeAndNormalize(key);
......@@ -111,16 +97,6 @@ FormDataList::Entry FormDataList::itemsToEntry(const FormDataList::Item& item) c
return Entry(name, File::create(filename, currentTimeMS(), item.blob()->blobDataHandle()));
}
bool FormDataList::hasEntry(const String& key) const
{
const CString keyData = encodeAndNormalize(key);
for (const Item& item : items()) {
if (item.key() == keyData)
return true;
}
return false;
}
PassRefPtr<FormData> FormDataList::createFormData(FormData::EncodingType encodingType)
{
RefPtr<FormData> result = FormData::create();
......
......@@ -102,11 +102,9 @@ public:
appendItem(Item(encodeAndNormalize(key), blob, filename));
}
void deleteEntry(const String& key);
Entry getEntry(const String& key) const;
Entry getEntry(size_t index) const;
HeapVector<Entry> getAll(const String& key) const;
bool hasEntry(const String& key) const;
size_t size() const { return m_items.size(); }
const FormDataListItems& items() const { return m_items; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment