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

Side by Side Diff: Source/core/html/FormDataList.cpp

Issue 1308183006: Move FormDataList::deleteEntry() and hasEntry() to DOMFormData. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
31 FormDataList::FormDataList(const WTF::TextEncoding& c) 31 FormDataList::FormDataList(const WTF::TextEncoding& c)
32 : m_encoding(c) 32 : m_encoding(c)
33 { 33 {
34 } 34 }
35 35
36 void FormDataList::appendItem(const FormDataList::Item& item) 36 void FormDataList::appendItem(const FormDataList::Item& item)
37 { 37 {
38 m_items.append(item); 38 m_items.append(item);
39 } 39 }
40 40
41 void FormDataList::deleteEntry(const String& key)
42 {
43 const CString keyData = encodeAndNormalize(key);
44 size_t i = 0;
45 while (i < m_items.size()) {
46 if (m_items[i].key() == keyData) {
47 m_items.remove(i);
48 } else {
49 ++i;
50 }
51 }
52 return;
53 }
54
55 FormDataList::Entry FormDataList::getEntry(const String& key) const 41 FormDataList::Entry FormDataList::getEntry(const String& key) const
56 { 42 {
57 const CString keyData = encodeAndNormalize(key); 43 const CString keyData = encodeAndNormalize(key);
58 for (const Item& item : items()) { 44 for (const Item& item : items()) {
59 if (item.key() == keyData) 45 if (item.key() == keyData)
60 return itemsToEntry(item); 46 return itemsToEntry(item);
61 } 47 }
62 return Entry(); 48 return Entry();
63 } 49 }
64 50
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return Entry(name, file); 90 return Entry(name, file);
105 return Entry(name, file->clone(item.filename())); 91 return Entry(name, file->clone(item.filename()));
106 } 92 }
107 93
108 String filename = item.filename(); 94 String filename = item.filename();
109 if (filename.isNull()) 95 if (filename.isNull())
110 filename = "blob"; 96 filename = "blob";
111 return Entry(name, File::create(filename, currentTimeMS(), item.blob()->blob DataHandle())); 97 return Entry(name, File::create(filename, currentTimeMS(), item.blob()->blob DataHandle()));
112 } 98 }
113 99
114 bool FormDataList::hasEntry(const String& key) const
115 {
116 const CString keyData = encodeAndNormalize(key);
117 for (const Item& item : items()) {
118 if (item.key() == keyData)
119 return true;
120 }
121 return false;
122 }
123
124 PassRefPtr<FormData> FormDataList::createFormData(FormData::EncodingType encodin gType) 100 PassRefPtr<FormData> FormDataList::createFormData(FormData::EncodingType encodin gType)
125 { 101 {
126 RefPtr<FormData> result = FormData::create(); 102 RefPtr<FormData> result = FormData::create();
127 appendKeyValuePairItemsTo(result.get(), m_encoding, false, encodingType); 103 appendKeyValuePairItemsTo(result.get(), m_encoding, false, encodingType);
128 return result.release(); 104 return result.release();
129 } 105 }
130 106
131 PassRefPtr<FormData> FormDataList::createMultiPartFormData() 107 PassRefPtr<FormData> FormDataList::createMultiPartFormData()
132 { 108 {
133 RefPtr<FormData> result = FormData::create(); 109 RefPtr<FormData> result = FormData::create();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 { 200 {
225 visitor->trace(m_file); 201 visitor->trace(m_file);
226 } 202 }
227 203
228 DEFINE_TRACE(FormDataList::Item) 204 DEFINE_TRACE(FormDataList::Item)
229 { 205 {
230 visitor->trace(m_blob); 206 visitor->trace(m_blob);
231 } 207 }
232 208
233 } // namespace blink 209 } // namespace blink
OLDNEW
« Source/core/html/DOMFormData.cpp ('K') | « Source/core/html/FormDataList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698