diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-21 10:57:44 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-21 10:57:44 +0200 |
commit | 5ef7c8a6a70875d4430752d146bdcb069605d71d (patch) | |
tree | f6256640b6c46d7da221435803cae65326817ba2 /Source/WebKit2/PluginProcess | |
parent | decad929f578d8db641febc8740649ca6c574638 (diff) | |
download | qtwebkit-5ef7c8a6a70875d4430752d146bdcb069605d71d.tar.gz |
Imported WebKit commit 356d83016b090995d08ad568f2d2c243aa55e831 (http://svn.webkit.org/repository/webkit/trunk@126147)
New snapshot including various build fixes for newer Qt 5
Diffstat (limited to 'Source/WebKit2/PluginProcess')
5 files changed, 62 insertions, 9 deletions
diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp index ab60f941c..2ad41daa5 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp @@ -43,6 +43,7 @@ #include <WebCore/GraphicsContext.h> #include <WebCore/IdentifierRep.h> #include <WebCore/NotImplemented.h> +#include <wtf/TemporaryChange.h> #include <wtf/text/WTFString.h> #if PLATFORM(MAC) @@ -66,6 +67,7 @@ PluginControllerProxy::PluginControllerProxy(WebProcessConnection* connection, c #if USE(ACCELERATED_COMPOSITING) , m_isAcceleratedCompositingEnabled(creationParameters.isAcceleratedCompositingEnabled) #endif + , m_isInitializing(false) , m_paintTimer(RunLoop::main(), this, &PluginControllerProxy::paint) , m_pluginDestructionProtectCount(0) , m_pluginDestroyTimer(RunLoop::main(), this, &PluginControllerProxy::destroy) @@ -91,9 +93,22 @@ PluginControllerProxy::~PluginControllerProxy() releaseNPObject(m_pluginElementNPObject); } +void PluginControllerProxy::setInitializationReply(PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> reply) +{ + ASSERT(!m_initializationReply); + m_initializationReply = reply; +} + +PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> PluginControllerProxy::takeInitializationReply() +{ + return m_initializationReply.release(); +} + bool PluginControllerProxy::initialize(const PluginCreationParameters& creationParameters) { ASSERT(!m_plugin); + + TemporaryChange<bool> initializing(m_isInitializing, true); m_plugin = NetscapePlugin::create(PluginProcess::shared().netscapePluginModule()); if (!m_plugin) { diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.h b/Source/WebKit2/PluginProcess/PluginControllerProxy.h index 46da1a4bf..a9d35a663 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.h +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.h @@ -33,6 +33,7 @@ #include "PluginController.h" #include "PluginControllerProxyMessages.h" #include "ShareableBitmap.h" +#include "WebProcessConnectionMessages.h" #include <WebCore/RunLoop.h> #include <wtf/Noncopyable.h> @@ -70,6 +71,11 @@ public: PluginController* asPluginController() { return this; } + bool isInitializing() const { return m_isInitializing; } + + void setInitializationReply(PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply>); + PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> takeInitializationReply(); + private: PluginControllerProxy(WebProcessConnection*, const PluginCreationParameters&); @@ -159,6 +165,9 @@ private: String m_userAgent; bool m_isPrivateBrowsingEnabled; bool m_isAcceleratedCompositingEnabled; + bool m_isInitializing; + + RefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> m_initializationReply; RefPtr<Plugin> m_plugin; diff --git a/Source/WebKit2/PluginProcess/WebProcessConnection.cpp b/Source/WebKit2/PluginProcess/WebProcessConnection.cpp index 1621ca0c8..1d95df1ed 100644 --- a/Source/WebKit2/PluginProcess/WebProcessConnection.cpp +++ b/Source/WebKit2/PluginProcess/WebProcessConnection.cpp @@ -263,17 +263,23 @@ void WebProcessConnection::createPluginInternal(const PluginCreationParameters& #endif } -void WebProcessConnection::createPlugin(const PluginCreationParameters& creationParameters, bool& result, bool& wantsWheelEvents, uint32_t& remoteLayerClientID) +void WebProcessConnection::createPlugin(const PluginCreationParameters& creationParameters, PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> reply) { PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(creationParameters.pluginInstanceID); - // The plug-in we're being asked to create synchronously might already exist if we just finished creating it asynchronously. - // In that case we need to not create it again (but also need to return the correct information about its creation). + // The controller proxy for the plug-in we're being asked to create synchronously might already exist if it was requested asynchronously before. if (pluginControllerProxy) { - result = true; - wantsWheelEvents = pluginControllerProxy->wantsWheelEvents(); + // It might still be in the middle of initialization in which case we have to let that initialization complete and respond to this message later. + if (pluginControllerProxy->isInitializing()) { + pluginControllerProxy->setInitializationReply(reply); + return; + } + + // If its initialization is complete then we need to respond to this message with the correct information about its creation. #if PLATFORM(MAC) - remoteLayerClientID = pluginControllerProxy->remoteLayerClientID(); + reply->send(true, pluginControllerProxy->wantsWheelEvents(), pluginControllerProxy->remoteLayerClientID()); +#else + reply->send(true, pluginControllerProxy->wantsWheelEvents(), 0); #endif return; } @@ -283,7 +289,12 @@ void WebProcessConnection::createPlugin(const PluginCreationParameters& creation if (creationParameters.asynchronousCreationIncomplete) m_asynchronousInstanceIDsToIgnore.add(creationParameters.pluginInstanceID); + bool result = false; + bool wantsWheelEvents = false; + uint32_t remoteLayerClientID = 0; createPluginInternal(creationParameters, result, wantsWheelEvents, remoteLayerClientID); + + reply->send(result, wantsWheelEvents, remoteLayerClientID); } void WebProcessConnection::createPluginAsynchronously(const PluginCreationParameters& creationParameters) @@ -297,16 +308,33 @@ void WebProcessConnection::createPluginAsynchronously(const PluginCreationParame // This version of CreatePlugin is only used by plug-ins that are known to behave when started asynchronously. bool result = false; - uint32_t remoteLayerClientID = 0; bool wantsWheelEvents = false; + uint32_t remoteLayerClientID = 0; if (creationParameters.artificialPluginInitializationDelayEnabled) { unsigned artificialPluginInitializationDelay = 5; sleep(artificialPluginInitializationDelay); } + // Since plug-in creation can often message to the WebProcess synchronously (with NPP_Evaluate for example) + // we need to make sure that the web process will handle the plug-in process's synchronous messages, + // even if the web process is waiting on a synchronous reply itself. + // Normally the plug-in process doesn't give its synchronous messages the special flag to allow for that. + // We can force it to do so by incrementing the "DispatchMessageMarkedDispatchWhenWaitingForSyncReply" count. + m_connection->incrementDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount(); createPluginInternal(creationParameters, result, wantsWheelEvents, remoteLayerClientID); + m_connection->decrementDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount(); + + // If someone asked for this plug-in synchronously while it was in the middle of being created then we need perform the + // synchronous reply instead of sending the asynchronous reply. + PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(creationParameters.pluginInstanceID); + ASSERT(pluginControllerProxy); + if (RefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> delayedSyncReply = pluginControllerProxy->takeInitializationReply()) { + delayedSyncReply->send(result, wantsWheelEvents, remoteLayerClientID); + return; + } + // Otherwise, send the asynchronous results now. if (!result) { m_connection->sendSync(Messages::PluginProxy::DidFailToCreatePlugin(), Messages::PluginProxy::DidFailToCreatePlugin::Reply(), creationParameters.pluginInstanceID); return; diff --git a/Source/WebKit2/PluginProcess/WebProcessConnection.h b/Source/WebKit2/PluginProcess/WebProcessConnection.h index 53ca1e40e..ce98e1036 100644 --- a/Source/WebKit2/PluginProcess/WebProcessConnection.h +++ b/Source/WebKit2/PluginProcess/WebProcessConnection.h @@ -30,6 +30,7 @@ #include "Connection.h" #include "Plugin.h" +#include "WebProcessConnectionMessages.h" #include <wtf/HashSet.h> #include <wtf/RefCounted.h> @@ -70,7 +71,7 @@ private: // Message handlers. void didReceiveWebProcessConnectionMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); void didReceiveSyncWebProcessConnectionMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); - void createPlugin(const PluginCreationParameters&, bool& result, bool& wantsWheelEvents, uint32_t& remoteLayerClientID); + void createPlugin(const PluginCreationParameters&, PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply>); void createPluginAsynchronously(const PluginCreationParameters&); void destroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete); diff --git a/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in b/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in index f1a83594f..effb97966 100644 --- a/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in +++ b/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in @@ -24,7 +24,7 @@ messages -> WebProcessConnection { # Creates a plug-in instance using the given creation parameters. - CreatePlugin(WebKit::PluginCreationParameters pluginCreationParameters) -> (bool result, bool wantsWheelEvents, uint32_t remoteLayerClientID) + CreatePlugin(WebKit::PluginCreationParameters pluginCreationParameters) -> (bool creationResult, bool wantsWheelEvents, uint32_t remoteLayerClientID) Delayed # Creates a plug-in instance asynchronously using the given creation parameters. CreatePluginAsynchronously(WebKit::PluginCreationParameters pluginCreationParameters) |