Diff
Modified: trunk/Source/WebKit2/ChangeLog (116795 => 116796)
--- trunk/Source/WebKit2/ChangeLog 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/ChangeLog 2012-05-11 19:49:28 UTC (rev 116796)
@@ -1,3 +1,78 @@
+2012-05-11 Andreas Kling <kl...@webkit.org>
+
+ WK2/Plugins: Move enumeration of plugins to a secondary UIProcess thread.
+ <http://webkit.org/b/86143>
+ <rdar://problem/10777218>
+
+ Reviewed by Anders Carlsson.
+
+ To avoid spins beneath PluginInfoStore::getPluginInfo(), do this work on a secondary
+ thread in the UIProcess.
+
+ * Shared/APIObject.h:
+
+ Made APIObject a ThreadSafeRefCounted. In the context of this patch, this is to
+ be able to dispatch bound Functions on WebContext.
+
+ * WebProcess/mac/KeychainItemShimMethods.mm:
+ (WebKit::responseMap):
+ * WebProcess/mac/SecItemShimMethods.mm:
+ (WebKit::responseMap):
+ * WebKit2.xcodeproj/project.pbxproj:
+ * Shared/BlockingResponseMap.h:
+ (BlockingResponseMap):
+ (BlockingResponseMap::waitForResponse):
+ (BlockingResponseMap::didReceiveResponse):
+
+ Renamed from Source/WebKit2/WebProcess/mac/KeychainShimResponseMap.h.
+ Generalize this somewhat since it's useful in more than just the keychain scenario.
+ This can/should be generalized further, but that's a topic for another patch.
+
+ * UIProcess/Plugins/PluginInfoStore.h:
+ * UIProcess/Plugins/PluginInfoStore.cpp:
+ (WebKit::PluginInfoStore::plugins):
+ (WebKit::PluginInfoStore::findPluginForMIMEType):
+ (WebKit::PluginInfoStore::findPluginForExtension):
+ (WebKit::PluginInfoStore::findPlugin):
+ (WebKit::PluginInfoStore::infoForPluginWithPath):
+
+ Slap a mutex on the PluginInfoStore since it can now be called from both the
+ main thread (via WKFrameCanShowMIMEType) and the GetPlugin work queue.
+
+ * UIProcess/WebContext.messages.in:
+ * UIProcess/WebContext.h:
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::WebContext):
+ (WebKit::WebContext::~WebContext):
+ (WebKit::WebContext::processDidFinishLaunching):
+ (WebKit::WebContext::sendDidGetPlugins):
+ (WebKit::WebContext::handleGetPlugins):
+ (WebKit::WebContext::getPlugins):
+ (WebKit::WebContext::didReceiveMessageOnConnectionWorkQueue):
+
+ Make GetPlugins a DispatchOnConnectionQueue message and execute it on a new
+ plug-in work queue. This effectively makes the GetPlugin call asynchronous.
+ On Mac, the built-in PDF reader is still registered on the main thread as that
+ ends up calling into localizedString().
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::didGetPlugins):
+ * WebProcess/WebProcess.h:
+ * WebProcess/WebProcess.messages.in:
+
+ Add a DidGetPlugins message to WebProcess. This is passed directly to the handler
+ in WebPlatformStrategies.cpp.
+
+ * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+ * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+ (WebKit::responseMap):
+ (WebKit::handleDidGetPlugins):
+ (WebKit::generateRequestID):
+ (WebKit::WebPlatformStrategies::populatePluginCache):
+
+ Use a BlockingResponseMap to block the WebProcess main thread until the UIProcess
+ responds with DidGetPlugins.
+
2012-05-11 Gustavo Noronha Silva <g...@gnome.org>
REGRESSION(r116205): [GTK]: build no longer supports thin archives
Modified: trunk/Source/WebKit2/Shared/APIObject.h (116795 => 116796)
--- trunk/Source/WebKit2/Shared/APIObject.h 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/Shared/APIObject.h 2012-05-11 19:49:28 UTC (rev 116796)
@@ -30,7 +30,7 @@
namespace WebKit {
-class APIObject : public RefCounted<APIObject> {
+class APIObject : public ThreadSafeRefCounted<APIObject> {
public:
enum Type {
// Base types
Copied: trunk/Source/WebKit2/Shared/BlockingResponseMap.h (from rev 116795, trunk/Source/WebKit2/WebProcess/mac/KeychainShimResponseMap.h) (0 => 116796)
--- trunk/Source/WebKit2/Shared/BlockingResponseMap.h (rev 0)
+++ trunk/Source/WebKit2/Shared/BlockingResponseMap.h 2012-05-11 19:49:28 UTC (rev 116796)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BlockingResponseMap_h
+#define BlockingResponseMap_h
+
+#include <wtf/HashMap.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/ThreadingPrimitives.h>
+
+template<typename T>
+class BlockingResponseMap {
+public:
+ PassOwnPtr<T> waitForResponse(uint64_t requestID)
+ {
+ while (true) {
+ MutexLocker locker(m_mutex);
+
+ if (OwnPtr<T> response = m_responses.take(requestID))
+ return response.release();
+
+ m_condition.wait(m_mutex);
+ }
+
+ return nullptr;
+ }
+
+ void didReceiveResponse(uint64_t requestID, PassOwnPtr<T> response)
+ {
+ MutexLocker locker(m_mutex);
+ ASSERT(!m_responses.contains(requestID));
+
+ m_responses.set(requestID, response);
+ m_condition.signal();
+ }
+
+private:
+ Mutex m_mutex;
+ ThreadCondition m_condition;
+
+ HashMap<uint64_t, OwnPtr<T> > m_responses;
+};
+
+#endif // BlockingResponseMap_h
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp (116795 => 116796)
--- trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp 2012-05-11 19:49:28 UTC (rev 116796)
@@ -113,15 +113,15 @@
Vector<PluginModuleInfo> PluginInfoStore::plugins()
{
+ MutexLocker locker(m_pluginsLock);
loadPluginsIfNecessary();
-
- Vector<PluginModuleInfo> plugins(m_plugins);
-
- return plugins;
+ return m_plugins;
}
PluginModuleInfo PluginInfoStore::findPluginForMIMEType(const String& mimeType) const
{
+ MutexLocker locker(m_pluginsLock);
+
ASSERT(!mimeType.isNull());
for (size_t i = 0; i < m_plugins.size(); ++i) {
@@ -139,6 +139,8 @@
PluginModuleInfo PluginInfoStore::findPluginForExtension(const String& extension, String& mimeType) const
{
+ MutexLocker locker(m_pluginsLock);
+
ASSERT(!extension.isNull());
for (size_t i = 0; i < m_plugins.size(); ++i) {
@@ -187,7 +189,10 @@
PluginModuleInfo PluginInfoStore::findPlugin(String& mimeType, const KURL& url)
{
- loadPluginsIfNecessary();
+ {
+ MutexLocker locker(m_pluginsLock);
+ loadPluginsIfNecessary();
+ }
// First, check if we can get the plug-in based on its MIME type.
if (!mimeType.isNull()) {
@@ -219,6 +224,8 @@
PluginModuleInfo PluginInfoStore::infoForPluginWithPath(const String& pluginPath) const
{
+ MutexLocker locker(m_pluginsLock);
+
for (size_t i = 0; i < m_plugins.size(); ++i) {
if (m_plugins[i].path == pluginPath)
return m_plugins[i];
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h (116795 => 116796)
--- trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h 2012-05-11 19:49:28 UTC (rev 116796)
@@ -27,6 +27,7 @@
#define PluginInfoStore_h
#include "PluginModuleInfo.h"
+#include <wtf/ThreadingPrimitives.h>
namespace WebCore {
class KURL;
@@ -87,6 +88,8 @@
Vector<String> m_additionalPluginsDirectories;
Vector<PluginModuleInfo> m_plugins;
bool m_pluginListIsUpToDate;
+
+ mutable Mutex m_pluginsLock;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (116795 => 116796)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2012-05-11 19:49:28 UTC (rev 116796)
@@ -147,6 +147,7 @@
, m_initialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyAlways)
#endif
, m_processTerminationEnabled(true)
+ , m_pluginWorkQueue("com.apple.CoreIPC.PluginQueue")
{
#if !LOG_DISABLED
WebKit::initializeLogChannelsIfNecessary();
@@ -165,6 +166,9 @@
WebContext::~WebContext()
{
+ if (m_process && m_process->isValid())
+ m_process->connection()->removeQueueClient(this);
+
ASSERT(contexts().find(this) != notFound);
contexts().remove(contexts().find(this));
@@ -354,6 +358,8 @@
ASSERT_UNUSED(process, process == m_process);
m_visitedLinkProvider.processDidFinishLaunching();
+
+ m_process->connection()->addQueueClient(this);
// Sometimes the memorySampler gets initialized after process initialization has happened but before the process has finished launching
// so check if it needs to be started here
@@ -604,22 +610,41 @@
m_visitedLinkProvider.addVisitedLink(linkHash);
}
-void WebContext::getPlugins(bool refresh, Vector<PluginInfo>& pluginInfos)
+void WebContext::sendDidGetPlugins(uint64_t requestID, const Vector<PluginInfo>& pluginInfos)
{
+ ASSERT(isMainThread());
+
+ Vector<PluginInfo> plugins(pluginInfos);
+
+#if PLATFORM(MAC)
+ // Add built-in PDF last, so that it's not used when a real plug-in is installed.
+ // NOTE: This has to be done on the main thread as it calls localizedString().
+ if (!omitPDFSupport())
+ plugins.append(BuiltInPDFView::pluginInfo());
+#endif
+
+ process()->send(Messages::WebProcess::DidGetPlugins(requestID, plugins), 0);
+}
+
+void WebContext::handleGetPlugins(uint64_t requestID, bool refresh)
+{
if (refresh)
m_pluginInfoStore.refresh();
+ Vector<PluginInfo> pluginInfos;
+
Vector<PluginModuleInfo> plugins = m_pluginInfoStore.plugins();
for (size_t i = 0; i < plugins.size(); ++i)
pluginInfos.append(plugins[i].info);
-#if PLATFORM(MAC)
- // Add built-in PDF last, so that it's not used when a real plug-in is installed.
- if (!omitPDFSupport())
- pluginInfos.append(BuiltInPDFView::pluginInfo());
-#endif
+ RunLoop::main()->dispatch(bind(&WebContext::sendDidGetPlugins, this, requestID, pluginInfos));
}
+void WebContext::getPlugins(CoreIPC::Connection*, uint64_t requestID, bool refresh)
+{
+ m_pluginWorkQueue.dispatch(bind(&WebContext::handleGetPlugins, this, requestID, refresh));
+}
+
void WebContext::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, bool& blocked)
{
MESSAGE_CHECK_URL(urlString);
@@ -929,4 +954,12 @@
sendToAllProcesses(Messages::WebProcess::GarbageCollectJavaScriptObjects());
}
+void WebContext::didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, bool& didHandleMessage)
+{
+ if (messageID.is<CoreIPC::MessageClassWebContext>()) {
+ didReceiveWebContextMessageOnConnectionWorkQueue(connection, messageID, arguments, didHandleMessage);
+ return;
+ }
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (116795 => 116796)
--- trunk/Source/WebKit2/UIProcess/WebContext.h 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h 2012-05-11 19:49:28 UTC (rev 116796)
@@ -66,7 +66,7 @@
typedef GenericCallback<WKDictionaryRef> DictionaryCallback;
-class WebContext : public APIObject {
+class WebContext : public APIObject, private CoreIPC::Connection::QueueClient {
public:
static const Type APIType = TypeContext;
@@ -216,7 +216,7 @@
void didUpdateHistoryTitle(uint64_t pageID, const String& title, const String& url, uint64_t frameID);
// Plugins
- void getPlugins(bool refresh, Vector<WebCore::PluginInfo>&);
+ void getPlugins(CoreIPC::Connection*, uint64_t requestID, bool refresh);
void getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, bool& blocked);
#if !ENABLE(PLUGIN_PROCESS)
void didGetSitesWithPluginData(const Vector<String>& sites, uint64_t callbackID);
@@ -245,7 +245,10 @@
// Implemented in generated WebContextMessageReceiver.cpp
void didReceiveWebContextMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
void didReceiveSyncWebContextMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+ void didReceiveWebContextMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, bool& didHandleMessage);
+ virtual void didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, bool& didHandleMessage) OVERRIDE;
+
static void languageChanged(void* context);
void languageChanged();
@@ -257,6 +260,9 @@
String localStorageDirectory() const;
String platformDefaultLocalStorageDirectory() const;
+ void handleGetPlugins(uint64_t requestID, bool refresh);
+ void sendDidGetPlugins(uint64_t requestID, const Vector<WebCore::PluginInfo>&);
+
ProcessModel m_processModel;
// FIXME: In the future, this should be one or more WebProcessProxies.
@@ -322,6 +328,8 @@
bool m_processTerminationEnabled;
HashMap<uint64_t, RefPtr<DictionaryCallback> > m_dictionaryCallbacks;
+
+ WorkQueue m_pluginWorkQueue;
};
template<typename U> inline bool WebContext::sendToAllProcesses(const U& message)
Modified: trunk/Source/WebKit2/UIProcess/WebContext.messages.in (116795 => 116796)
--- trunk/Source/WebKit2/UIProcess/WebContext.messages.in 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/UIProcess/WebContext.messages.in 2012-05-11 19:49:28 UTC (rev 116796)
@@ -32,7 +32,7 @@
AddVisitedLinkHash(uint64_t linkHash)
# Plugin messages.
- GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins)
+ GetPlugins(uint64_t requestID, bool refresh) DispatchOnConnectionQueue
GetPluginPath(WTF::String mimeType, WTF::String urlString) -> (WTF::String pluginPath, bool blocked)
#if !ENABLE(PLUGIN_PROCESS)
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (116795 => 116796)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2012-05-11 19:49:28 UTC (rev 116796)
@@ -203,7 +203,6 @@
1AAF0C4B12B16334008E49E2 /* ArgumentCodersCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF0C4912B16334008E49E2 /* ArgumentCodersCF.cpp */; };
1AAF263814687C39004A1E8A /* TiledCoreAnimationDrawingArea.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF263614687C39004A1E8A /* TiledCoreAnimationDrawingArea.mm */; };
1AAF263914687C39004A1E8A /* TiledCoreAnimationDrawingArea.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF263714687C39004A1E8A /* TiledCoreAnimationDrawingArea.h */; };
- 1AB42E8714BBBBB2004272F7 /* KeychainShimResponseMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB42E8614BBBBB2004272F7 /* KeychainShimResponseMap.h */; };
1AB7D4CA1288AAA700CFD08C /* DownloadProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB7D4C81288AAA700CFD08C /* DownloadProxy.h */; };
1AB7D4CB1288AAA700CFD08C /* DownloadProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AB7D4C91288AAA700CFD08C /* DownloadProxy.cpp */; };
1AB7D6191288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AB7D6171288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp */; };
@@ -327,6 +326,7 @@
37C4E9F6131C6E7E0029BD5A /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = B396EA5512E0ED2D00F4FEB7 /* config.h */; };
37F623B812A57B6200E3FDF6 /* WKFindOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 37F623B712A57B6200E3FDF6 /* WKFindOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
37F90DE31376560E0051CF68 /* HTTPCookieAcceptPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F638954F133BEF38008941D5 /* HTTPCookieAcceptPolicy.h */; };
+ 4F601432155C5AA2001FBDE0 /* BlockingResponseMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F601430155C5A32001FBDE0 /* BlockingResponseMap.h */; };
51021E9C12B16788005C033C /* WebContextMenuClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */; };
510FBB9A1288C95E00AFFDF4 /* WebContextMenuItemData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510FBB981288C95E00AFFDF4 /* WebContextMenuItemData.cpp */; };
510FBB9B1288C95E00AFFDF4 /* WebContextMenuItemData.h in Headers */ = {isa = PBXBuildFile; fileRef = 510FBB991288C95E00AFFDF4 /* WebContextMenuItemData.h */; };
@@ -1212,7 +1212,6 @@
1AAF0C4912B16334008E49E2 /* ArgumentCodersCF.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = ArgumentCodersCF.cpp; sourceTree = "<group>"; };
1AAF263614687C39004A1E8A /* TiledCoreAnimationDrawingArea.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TiledCoreAnimationDrawingArea.mm; sourceTree = "<group>"; };
1AAF263714687C39004A1E8A /* TiledCoreAnimationDrawingArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiledCoreAnimationDrawingArea.h; sourceTree = "<group>"; };
- 1AB42E8614BBBBB2004272F7 /* KeychainShimResponseMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeychainShimResponseMap.h; sourceTree = "<group>"; };
1AB7D4C81288AAA700CFD08C /* DownloadProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadProxy.h; sourceTree = "<group>"; };
1AB7D4C91288AAA700CFD08C /* DownloadProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadProxy.cpp; sourceTree = "<group>"; };
1AB7D5E91288B8C000CFD08C /* DownloadProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DownloadProxy.messages.in; sourceTree = "<group>"; };
@@ -1349,6 +1348,7 @@
37948406150C4B9600E52CE9 /* WKRenderLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKRenderLayer.cpp; sourceTree = "<group>"; };
37948407150C4B9600E52CE9 /* WKRenderLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRenderLayer.h; sourceTree = "<group>"; };
37F623B712A57B6200E3FDF6 /* WKFindOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFindOptions.h; sourceTree = "<group>"; };
+ 4F601430155C5A32001FBDE0 /* BlockingResponseMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockingResponseMap.h; sourceTree = "<group>"; };
510031F61379CACB00C8DFE4 /* WebProcessShim.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = WebProcessShim.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContextMenuClientMac.mm; sourceTree = "<group>"; };
510FBB981288C95E00AFFDF4 /* WebContextMenuItemData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextMenuItemData.cpp; sourceTree = "<group>"; };
@@ -2228,7 +2228,6 @@
children = (
512DF6D6138C181A00A22FC6 /* KeychainItemShimMethods.h */,
512DF6D7138C181A00A22FC6 /* KeychainItemShimMethods.mm */,
- 1AB42E8614BBBBB2004272F7 /* KeychainShimResponseMap.h */,
511F8A7D138B46FE00A95F44 /* SecItemShimMethods.h */,
511F8A7E138B46FE00A95F44 /* SecItemShimMethods.mm */,
BC3065C312592F8900E71278 /* WebProcessMac.mm */,
@@ -2344,6 +2343,7 @@
5D51845413BCF9CC00C7FF4A /* APIClientTraits.h */,
B63403F814910D57001070B5 /* APIObject.cpp */,
BCF04C8C11FF9B7D00F86A58 /* APIObject.h */,
+ 4F601430155C5A32001FBDE0 /* BlockingResponseMap.h */,
BC3065F91259344E00E71278 /* CacheModel.h */,
1A2D956E12848564001EB962 /* ChildProcess.cpp */,
1A2D956D12848564001EB962 /* ChildProcess.h */,
@@ -3889,6 +3889,7 @@
1AEFCC1211D01F96008219D3 /* PluginInfoStore.h in Headers */,
1A3D610213A7CC2A00F95D4E /* PluginModuleInfo.h in Headers */,
1A043976124D034800FFBFB5 /* PluginProcess.h in Headers */,
+ 4F601432155C5AA2001FBDE0 /* BlockingResponseMap.h in Headers */,
1A0EC906124C0AB8007EF4A5 /* PluginProcessConnection.h in Headers */,
1A0EC90F124C0AF5007EF4A5 /* PluginProcessConnectionManager.h in Headers */,
1A2BB6D114117B4D000F35D4 /* PluginProcessConnectionMessages.h in Headers */,
@@ -4193,7 +4194,6 @@
BC8699B7116AADAA002A925B /* WKViewInternal.h in Headers */,
BFA6179F12F0B99D0033E0CA /* WKViewPrivate.h in Headers */,
BC2E6E8E1141971500A63B1E /* WorkQueue.h in Headers */,
- 1AB42E8714BBBBB2004272F7 /* KeychainShimResponseMap.h in Headers */,
E17BF99614D0A73E00A5A069 /* NetscapeSandboxFunctions.h in Headers */,
BCE0937814FB128C001138D9 /* LayerHostingContext.h in Headers */,
296BD85D15019BC30071F424 /* StringUtilities.h in Headers */,
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (116795 => 116796)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp 2012-05-11 19:49:28 UTC (rev 116796)
@@ -28,6 +28,7 @@
#if USE(PLATFORM_STRATEGIES)
+#include "BlockingResponseMap.h"
#include "PluginInfoStore.h"
#include "WebContextMessages.h"
#include "WebCookieManager.h"
@@ -37,6 +38,7 @@
#include <WebCore/KURL.h>
#include <WebCore/Page.h>
#include <WebCore/PlatformPasteboard.h>
+#include <wtf/Atomics.h>
#if USE(CF)
#include <wtf/RetainPtr.h>
@@ -102,6 +104,23 @@
plugins = m_cachedPlugins;
}
+static BlockingResponseMap<Vector<WebCore::PluginInfo> >& responseMap()
+{
+ AtomicallyInitializedStatic(BlockingResponseMap<Vector<WebCore::PluginInfo> >&, responseMap = *new BlockingResponseMap<Vector<WebCore::PluginInfo> >);
+ return responseMap;
+}
+
+void handleDidGetPlugins(uint64_t requestID, const Vector<WebCore::PluginInfo>& plugins)
+{
+ responseMap().didReceiveResponse(requestID, adoptPtr(new Vector<WebCore::PluginInfo>(plugins)));
+}
+
+static uint64_t generateRequestID()
+{
+ static int uniqueID;
+ return atomicIncrement(&uniqueID);
+}
+
void WebPlatformStrategies::populatePluginCache()
{
if (m_pluginCacheIsPopulated)
@@ -109,13 +128,11 @@
ASSERT(m_cachedPlugins.isEmpty());
- Vector<PluginInfo> plugins;
-
// FIXME: Should we do something in case of error here?
- WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPlugins(m_shouldRefreshPlugins),
- Messages::WebContext::GetPlugins::Reply(plugins), 0);
+ uint64_t requestID = generateRequestID();
+ WebProcess::shared().connection()->send(Messages::WebContext::GetPlugins(requestID, m_shouldRefreshPlugins), 0);
- m_cachedPlugins.swap(plugins);
+ m_cachedPlugins = *responseMap().waitForResponse(requestID);
m_shouldRefreshPlugins = false;
m_pluginCacheIsPopulated = true;
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h (116795 => 116796)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h 2012-05-11 19:49:28 UTC (rev 116796)
@@ -85,6 +85,8 @@
Vector<WebCore::PluginInfo> m_cachedPlugins;
};
+void handleDidGetPlugins(uint64_t requestID, const Vector<WebCore::PluginInfo>&);
+
} // namespace WebKit
#endif // USE(PLATFORM_STRATEGIES)
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (116795 => 116796)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2012-05-11 19:49:28 UTC (rev 116796)
@@ -1031,4 +1031,10 @@
}
}
+void WebProcess::didGetPlugins(CoreIPC::Connection*, uint64_t requestID, const Vector<WebCore::PluginInfo>& plugins)
+{
+ // Pass this to WebPlatformStrategies.cpp.
+ handleDidGetPlugins(requestID, plugins);
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (116795 => 116796)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2012-05-11 19:49:28 UTC (rev 116796)
@@ -30,6 +30,7 @@
#include "ChildProcess.h"
#include "DrawingArea.h"
#include "EventDispatcher.h"
+#include "PluginInfoStore.h"
#include "ResourceCachesToClear.h"
#include "SandboxExtension.h"
#include "SharedMemory.h"
@@ -243,6 +244,8 @@
void didReceiveWebProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
void didReceiveWebProcessMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, bool& didHandleMessage);
+ void didGetPlugins(CoreIPC::Connection*, uint64_t requestID, const Vector<WebCore::PluginInfo>&);
+
RefPtr<WebConnectionToUIProcess> m_connection;
HashMap<uint64_t, RefPtr<WebPage> > m_pageMap;
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (116795 => 116796)
--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2012-05-11 19:49:28 UTC (rev 116796)
@@ -54,6 +54,8 @@
ClearPluginSiteData(Vector<WTF::String> pluginPaths, Vector<WTF::String> sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
#endif
+ DidGetPlugins(uint64_t requestID, Vector<WebCore::PluginInfo> plugins) DispatchOnConnectionQueue
+
#if ENABLE(PLUGIN_PROCESS)
PluginProcessCrashed(String pluginProcess) DispatchOnConnectionQueue
#endif
Modified: trunk/Source/WebKit2/WebProcess/mac/KeychainItemShimMethods.mm (116795 => 116796)
--- trunk/Source/WebKit2/WebProcess/mac/KeychainItemShimMethods.mm 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/WebProcess/mac/KeychainItemShimMethods.mm 2012-05-11 19:49:28 UTC (rev 116796)
@@ -28,7 +28,7 @@
#if defined(BUILDING_ON_SNOW_LEOPARD)
-#import "KeychainShimResponseMap.h"
+#import "BlockingResponseMap.h"
#import "SecKeychainItemRequestData.h"
#import "SecKeychainItemResponseData.h"
#import "WebProcess.h"
@@ -141,9 +141,9 @@
return true;
}
-static KeychainShimResponseMap<SecKeychainItemResponseData>& responseMap()
+static BlockingResponseMap<SecKeychainItemResponseData>& responseMap()
{
- AtomicallyInitializedStatic(KeychainShimResponseMap<SecKeychainItemResponseData>&, responseMap = *new KeychainShimResponseMap<SecKeychainItemResponseData>);
+ AtomicallyInitializedStatic(BlockingResponseMap<SecKeychainItemResponseData>&, responseMap = *new BlockingResponseMap<SecKeychainItemResponseData>);
return responseMap;
}
Deleted: trunk/Source/WebKit2/WebProcess/mac/KeychainShimResponseMap.h (116795 => 116796)
--- trunk/Source/WebKit2/WebProcess/mac/KeychainShimResponseMap.h 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/WebProcess/mac/KeychainShimResponseMap.h 2012-05-11 19:49:28 UTC (rev 116796)
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KeychainShimResponseMap_h
-#define KeychainShimResponseMap_h
-
-#include <wtf/HashMap.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/ThreadingPrimitives.h>
-
-template<typename T>
-class KeychainShimResponseMap {
-public:
- PassOwnPtr<T> waitForResponse(uint64_t requestID)
- {
- while (true) {
- MutexLocker locker(m_mutex);
-
- if (OwnPtr<T> response = m_responses.take(requestID))
- return response.release();
-
- m_condition.wait(m_mutex);
- }
-
- return nullptr;
- }
-
- void didReceiveResponse(uint64_t requestID, PassOwnPtr<T> response)
- {
- MutexLocker locker(m_mutex);
- ASSERT(!m_responses.contains(requestID));
-
- m_responses.set(requestID, response);
- m_condition.signal();
- }
-
-private:
- Mutex m_mutex;
- ThreadCondition m_condition;
-
- HashMap<uint64_t, OwnPtr<T> > m_responses;
-};
-
-
-
-#endif // KeychainShimResponseMap_h
Modified: trunk/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm (116795 => 116796)
--- trunk/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm 2012-05-11 19:45:39 UTC (rev 116795)
+++ trunk/Source/WebKit2/WebProcess/mac/SecItemShimMethods.mm 2012-05-11 19:49:28 UTC (rev 116796)
@@ -28,7 +28,7 @@
#if !defined(BUILDING_ON_SNOW_LEOPARD)
-#import "KeychainShimResponseMap.h"
+#import "BlockingResponseMap.h"
#import "SecItemRequestData.h"
#import "SecItemResponseData.h"
#import "WebProcess.h"
@@ -39,9 +39,9 @@
namespace WebKit {
-static KeychainShimResponseMap<SecItemResponseData>& responseMap()
+static BlockingResponseMap<SecItemResponseData>& responseMap()
{
- AtomicallyInitializedStatic(KeychainShimResponseMap<SecItemResponseData>&, responseMap = *new KeychainShimResponseMap<SecItemResponseData>);
+ AtomicallyInitializedStatic(BlockingResponseMap<SecItemResponseData>&, responseMap = *new BlockingResponseMap<SecItemResponseData>);
return responseMap;
}