Make PluginInfoStore properly thread-safe.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 18:48:29 +0000 (18:48 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 18:48:29 +0000 (18:48 +0000)
<http://webkit.org/b/86648>
<rdar://problem/11451178>

Reviewed by Darin Adler.

Source/WebCore:

* plugins/PluginData.h:
(WebCore::MimeClassInfo::isolatedCopy):
(WebCore::PluginInfo::isolatedCopy):

Source/WebKit2:

Deep copy the internal storage of PluginInfoStore after constructing it, as we can
be doing this from a secondary thread.

* Shared/Plugins/PluginModuleInfo.h:
(WebKit::PluginModuleInfo::isolatedCopy):
* UIProcess/Plugins/PluginInfoStore.cpp:
(WebKit::deepIsolatedCopyPluginInfoVector):
(WebKit::PluginInfoStore::loadPluginsIfNecessary):
(WebKit::PluginInfoStore::plugins):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117471 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/plugins/PluginData.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Plugins/PluginModuleInfo.h
Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp

index 4165893..d2eaf8b 100644 (file)
@@ -1,3 +1,15 @@
+2012-05-16  Andreas Kling  <kling@webkit.org>
+
+        Make PluginInfoStore properly thread-safe.
+        <http://webkit.org/b/86648>
+        <rdar://problem/11451178>
+
+        Reviewed by Darin Adler.
+
+        * plugins/PluginData.h:
+        (WebCore::MimeClassInfo::isolatedCopy):
+        (WebCore::PluginInfo::isolatedCopy):
+
 2012-05-17  Hironori Bono  <hbono@chromium.org>
 
         [Refactoring] Move platform-specific code in Editor::respondToChangedSelection to the WebKit layer
index 9b26a56..1502739 100644 (file)
@@ -34,7 +34,7 @@ struct MimeClassInfo {
     String desc;
     Vector<String> extensions;
 
-    MimeClassInfo isolatedCopy()
+    MimeClassInfo isolatedCopy() const
     {
         MimeClassInfo clone;
         clone.type = type.isolatedCopy();
@@ -56,7 +56,7 @@ struct PluginInfo {
     String desc;
     Vector<MimeClassInfo> mimes;
 
-    PluginInfo isolatedCopy()
+    PluginInfo isolatedCopy() const
     {
         PluginInfo clone;
         clone.name = name.isolatedCopy();
index f7606f5..eb0099d 100644 (file)
@@ -1,3 +1,21 @@
+2012-05-16  Andreas Kling  <kling@webkit.org>
+
+        Make PluginInfoStore properly thread-safe.
+        <http://webkit.org/b/86648>
+        <rdar://problem/11451178>
+
+        Reviewed by Darin Adler.
+
+        Deep copy the internal storage of PluginInfoStore after constructing it, as we can
+        be doing this from a secondary thread.
+
+        * Shared/Plugins/PluginModuleInfo.h:
+        (WebKit::PluginModuleInfo::isolatedCopy):
+        * UIProcess/Plugins/PluginInfoStore.cpp:
+        (WebKit::deepIsolatedCopyPluginInfoVector):
+        (WebKit::PluginInfoStore::loadPluginsIfNecessary):
+        (WebKit::PluginInfoStore::plugins):
+
 2012-05-17  Hironori Bono  <hbono@chromium.org>
 
         [Refactoring] Move platform-specific code in Editor::respondToChangedSelection to the WebKit layer
index 77524c0..1b0d6c0 100644 (file)
@@ -42,7 +42,7 @@ struct PluginModuleInfo {
     uint64_t fileVersion;
 #endif
 
-    PluginModuleInfo isolatedCopy()
+    PluginModuleInfo isolatedCopy() const
     {
         PluginModuleInfo clone;
         clone.path = path.isolatedCopy();
index 49ccb98..37ff060 100644 (file)
@@ -69,6 +69,16 @@ typedef ListHashSet<String, 32, CaseFoldingHash> PathHashSet;
 typedef ListHashSet<String, 32> PathHashSet;
 #endif
 
+static inline Vector<PluginModuleInfo> deepIsolatedCopyPluginInfoVector(const Vector<PluginModuleInfo>& vector)
+{
+    // Let the copy begin!
+    Vector<PluginModuleInfo> copy;
+    copy.reserveCapacity(vector.size());
+    for (unsigned i = 0; i < vector.size(); ++i)
+        copy.append(vector[i].isolatedCopy());
+    return copy;
+}
+
 void PluginInfoStore::loadPluginsIfNecessary()
 {
     if (m_pluginListIsUpToDate)
@@ -94,7 +104,8 @@ void PluginInfoStore::loadPluginsIfNecessary()
     for (PathHashSet::const_iterator it = uniquePluginPaths.begin(); it != end; ++it)
         loadPlugin(plugins, *it);
 
-    m_plugins.swap(plugins);
+    m_plugins = deepIsolatedCopyPluginInfoVector(plugins);
+
     m_pluginListIsUpToDate = true;
 }
 
@@ -115,13 +126,7 @@ Vector<PluginModuleInfo> PluginInfoStore::plugins()
 {
     MutexLocker locker(m_pluginsLock);
     loadPluginsIfNecessary();
-
-    // Let the copy begin!
-    Vector<PluginModuleInfo> infos;
-    for (unsigned i = 0; i < m_plugins.size(); ++i)
-        infos.append(m_plugins[i].isolatedCopy());
-
-    return infos;
+    return deepIsolatedCopyPluginInfoVector(m_plugins);
 }
 
 PluginModuleInfo PluginInfoStore::findPluginForMIMEType(const String& mimeType) const