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

Unified Diff: third_party/WebKit/Source/modules/plugins/DOMMimeTypeArray.cpp

Issue 2157883002: Cache the mimeTypes and plugins DOM objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated after dry run. Created 4 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: third_party/WebKit/Source/modules/plugins/DOMMimeTypeArray.cpp
diff --git a/third_party/WebKit/Source/modules/plugins/DOMMimeTypeArray.cpp b/third_party/WebKit/Source/modules/plugins/DOMMimeTypeArray.cpp
index 95b464dd1f1bb865ac19059edadf29da666724f2..2e4eab3565bb9a664d3f084e2e14c7d1162f14f1 100644
--- a/third_party/WebKit/Source/modules/plugins/DOMMimeTypeArray.cpp
+++ b/third_party/WebKit/Source/modules/plugins/DOMMimeTypeArray.cpp
@@ -29,12 +29,14 @@ namespace blink {
DOMMimeTypeArray::DOMMimeTypeArray(LocalFrame* frame)
: DOMWindowProperty(frame)
+ , m_modified(0)
{
}
DEFINE_TRACE(DOMMimeTypeArray)
{
DOMWindowProperty::trace(visitor);
+ visitor->trace(m_mimeTypes);
}
unsigned DOMMimeTypeArray::length() const
@@ -45,6 +47,20 @@ unsigned DOMMimeTypeArray::length() const
return data->mimes().size();
}
+DOMMimeType* DOMMimeTypeArray::getMimeType(unsigned index)
+{
+ PluginData* data = getPluginData();
+ if (!data)
+ return nullptr;
+ if (data->modified() != m_modified) {
+ m_mimeTypes.clear();
+ m_modified = data->modified();
+ }
+ if (m_mimeTypes.find(index) == m_mimeTypes.end())
+ m_mimeTypes.add(index, DOMMimeType::create(data, m_frame, index));
+ return m_mimeTypes.get(index);
+}
+
DOMMimeType* DOMMimeTypeArray::item(unsigned index)
{
PluginData* data = getPluginData();
@@ -53,7 +69,7 @@ DOMMimeType* DOMMimeTypeArray::item(unsigned index)
const Vector<MimeClassInfo>& mimes = data->mimes();
if (index >= mimes.size())
return nullptr;
- return DOMMimeType::create(data, m_frame, index);
+ return getMimeType(index);
}
DOMMimeType* DOMMimeTypeArray::namedItem(const AtomicString& propertyName)
@@ -64,7 +80,7 @@ DOMMimeType* DOMMimeTypeArray::namedItem(const AtomicString& propertyName)
const Vector<MimeClassInfo>& mimes = data->mimes();
for (unsigned i = 0; i < mimes.size(); ++i) {
if (mimes[i].type == propertyName)
- return DOMMimeType::create(data, m_frame, i);
+ return getMimeType(i);
}
return nullptr;
}
« no previous file with comments | « third_party/WebKit/Source/modules/plugins/DOMMimeTypeArray.h ('k') | third_party/WebKit/Source/modules/plugins/DOMPlugin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698