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

Unified Diff: Source/core/dom/DOMStringList.cpp

Issue 966843002: Mark DOMStringList.contains() as deprecated, add console warning. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add more detailed use counters Created 5 years, 6 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/dom/DOMStringList.cpp
diff --git a/Source/core/dom/DOMStringList.cpp b/Source/core/dom/DOMStringList.cpp
index 7370f1aa8503a445b48952f43dbc5aa36266bae1..81cd2773d26dc34943412d96a84e7f9485d98821 100644
--- a/Source/core/dom/DOMStringList.cpp
+++ b/Source/core/dom/DOMStringList.cpp
@@ -25,19 +25,49 @@
#include "config.h"
#include "core/dom/DOMStringList.h"
+#include "core/dom/ExecutionContext.h"
+#include "core/frame/UseCounter.h"
#include <algorithm>
namespace blink {
-String DOMStringList::item(unsigned index) const
+String DOMStringList::anonymousIndexedGetter(unsigned index) const
{
if (index >= m_strings.size())
return String();
return m_strings[index];
}
-bool DOMStringList::contains(const String& string) const
+
+String DOMStringList::item(ExecutionContext* context, unsigned index) const
+{
+ switch (m_source) {
+ case DOMStringList::IndexedDB:
+ UseCounter::count(context, UseCounter::DOMStringList_Item_AttributeGetter_IndexedDB);
+ break;
+ case DOMStringList::Location:
+ UseCounter::count(context, UseCounter::DOMStringList_Item_AttributeGetter_Location);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ return anonymousIndexedGetter(index);
+}
+
+bool DOMStringList::contains(ExecutionContext* context, const String& string) const
{
+ switch (m_source) {
+ case DOMStringList::IndexedDB:
+ UseCounter::count(context, UseCounter::DOMStringList_Contains_Method_IndexedDB);
+ break;
+ case DOMStringList::Location:
+ UseCounter::count(context, UseCounter::DOMStringList_Contains_Method_Location);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
// FIXME: Currently, all consumers of DOMStringList store fairly small lists and thus an O(n)
// algorithm is OK. But this may need to be optimized if larger amounts of data are
// stored in m_strings.

Powered by Google App Engine
This is Rietveld 408576698