diff options
Diffstat (limited to 'Source/WebKit2/PluginProcess/WebProcessConnection.cpp')
-rw-r--r-- | Source/WebKit2/PluginProcess/WebProcessConnection.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/Source/WebKit2/PluginProcess/WebProcessConnection.cpp b/Source/WebKit2/PluginProcess/WebProcessConnection.cpp index 5011089d6..54a8ee65e 100644 --- a/Source/WebKit2/PluginProcess/WebProcessConnection.cpp +++ b/Source/WebKit2/PluginProcess/WebProcessConnection.cpp @@ -30,7 +30,6 @@ #include "ActivityAssertion.h" #include "ArgumentCoders.h" -#include "ConnectionStack.h" #include "NPObjectMessageReceiverMessages.h" #include "NPRemoteObjectMap.h" #include "PluginControllerProxy.h" @@ -40,15 +39,17 @@ #include "PluginProxyMessages.h" #include "WebProcessConnectionMessages.h" #include <unistd.h> -#include <wtf/RunLoop.h> +#include <wtf/SetForScope.h> using namespace WebCore; namespace WebKit { -PassRefPtr<WebProcessConnection> WebProcessConnection::create(IPC::Connection::Identifier connectionIdentifier) +static IPC::Connection* currentConnection; + +RefPtr<WebProcessConnection> WebProcessConnection::create(IPC::Connection::Identifier connectionIdentifier) { - return adoptRef(new WebProcessConnection(connectionIdentifier)); + return adoptRef(*new WebProcessConnection(connectionIdentifier)); } WebProcessConnection::~WebProcessConnection() @@ -60,7 +61,7 @@ WebProcessConnection::~WebProcessConnection() WebProcessConnection::WebProcessConnection(IPC::Connection::Identifier connectionIdentifier) { - m_connection = IPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main()); + m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this); m_npRemoteObjectMap = NPRemoteObjectMap::create(m_connection.get()); m_connection->setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(true); @@ -72,7 +73,7 @@ void WebProcessConnection::addPluginControllerProxy(std::unique_ptr<PluginContro uint64_t pluginInstanceID = pluginController->pluginInstanceID(); ASSERT(!m_pluginControllers.contains(pluginInstanceID)); - m_pluginControllers.set(pluginInstanceID, std::move(pluginController)); + m_pluginControllers.set(pluginInstanceID, WTFMove(pluginController)); } void WebProcessConnection::destroyPluginControllerProxy(PluginControllerProxy* pluginController) @@ -84,10 +85,11 @@ void WebProcessConnection::destroyPluginControllerProxy(PluginControllerProxy* p void WebProcessConnection::removePluginControllerProxy(PluginControllerProxy* pluginController, Plugin* plugin) { + unsigned pluginInstanceID = pluginController->pluginInstanceID(); { - ASSERT(m_pluginControllers.contains(pluginController->pluginInstanceID())); + ASSERT(m_pluginControllers.contains(pluginInstanceID)); - std::unique_ptr<PluginControllerProxy> pluginControllerUniquePtr = m_pluginControllers.take(pluginController->pluginInstanceID()); + std::unique_ptr<PluginControllerProxy> pluginControllerUniquePtr = m_pluginControllers.take(pluginInstanceID); ASSERT(pluginControllerUniquePtr.get() == pluginController); } @@ -105,21 +107,20 @@ void WebProcessConnection::removePluginControllerProxy(PluginControllerProxy* pl m_connection = nullptr; // This will cause us to be deleted. - PluginProcess::shared().removeWebProcessConnection(this); + PluginProcess::singleton().removeWebProcessConnection(this); } void WebProcessConnection::setGlobalException(const String& exceptionString) { - IPC::Connection* connection = ConnectionStack::shared().current(); - if (!connection) + if (!currentConnection) return; - connection->sendSync(Messages::PluginProcessConnection::SetException(exceptionString), Messages::PluginProcessConnection::SetException::Reply(), 0); + currentConnection->sendSync(Messages::PluginProcessConnection::SetException(exceptionString), Messages::PluginProcessConnection::SetException::Reply(), 0); } -void WebProcessConnection::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder) +void WebProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder) { - ConnectionStack::CurrentConnectionPusher currentConnection(ConnectionStack::shared(), connection); + SetForScope<IPC::Connection*> currentConnectionChange(currentConnection, &connection); if (decoder.messageReceiverName() == Messages::WebProcessConnection::messageReceiverName()) { didReceiveWebProcessConnectionMessage(connection, decoder); @@ -139,12 +140,9 @@ void WebProcessConnection::didReceiveMessage(IPC::Connection* connection, IPC::M pluginControllerProxy->didReceivePluginControllerProxyMessage(connection, decoder); } -void WebProcessConnection::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) +void WebProcessConnection::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) { - // Force all timers to run at full speed when processing a synchronous message - ActivityAssertion activityAssertion(PluginProcess::shared()); - - ConnectionStack::CurrentConnectionPusher currentConnection(ConnectionStack::shared(), connection); + SetForScope<IPC::Connection*> currentConnectionChange(currentConnection, &connection); uint64_t destinationID = decoder.destinationID(); @@ -166,7 +164,7 @@ void WebProcessConnection::didReceiveSyncMessage(IPC::Connection* connection, IP pluginControllerProxy->didReceiveSyncPluginControllerProxyMessage(connection, decoder, replyEncoder); } -void WebProcessConnection::didClose(IPC::Connection*) +void WebProcessConnection::didClose(IPC::Connection&) { // The web process crashed. Destroy all the plug-in controllers. Destroying the last plug-in controller // will cause the web process connection itself to be destroyed. @@ -178,10 +176,14 @@ void WebProcessConnection::didClose(IPC::Connection*) destroyPluginControllerProxy(pluginControllers[i]); } -void WebProcessConnection::destroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete) +void WebProcessConnection::destroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete, PassRefPtr<Messages::WebProcessConnection::DestroyPlugin::DelayedReply> reply) { + // We return immediately from this synchronous IPC. We want to make sure the plugin destruction is just about to start so audio playback + // will finish soon after returning. However we don't want to wait for destruction to complete fully as that may take a while. + reply->send(); + // Ensure we don't clamp any timers during destruction - ActivityAssertion activityAssertion(PluginProcess::shared()); + ActivityAssertion activityAssertion(PluginProcess::singleton().connectionActivity()); PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(pluginInstanceID); @@ -198,7 +200,7 @@ void WebProcessConnection::destroyPlugin(uint64_t pluginInstanceID, bool asynchr destroyPluginControllerProxy(pluginControllerProxy); } -void WebProcessConnection::didReceiveInvalidMessage(IPC::Connection*, IPC::StringReference, IPC::StringReference) +void WebProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference) { // FIXME: Implement. } @@ -211,7 +213,7 @@ void WebProcessConnection::createPluginInternal(const PluginCreationParameters& // Make sure to add the proxy to the map before initializing it, since the plug-in might call out to the web process from // its NPP_New function. This will hand over ownership of the proxy to the web process connection. - addPluginControllerProxy(std::move(pluginControllerProxy)); + addPluginControllerProxy(WTFMove(pluginControllerProxy)); // Now try to initialize the plug-in. result = pluginControllerProxyPtr->initialize(creationParameters); @@ -220,7 +222,7 @@ void WebProcessConnection::createPluginInternal(const PluginCreationParameters& return; wantsWheelEvents = pluginControllerProxyPtr->wantsWheelEvents(); -#if PLATFORM(MAC) +#if PLATFORM(COCOA) remoteLayerClientID = pluginControllerProxyPtr->remoteLayerClientID(); #else UNUSED_PARAM(remoteLayerClientID); @@ -230,7 +232,7 @@ void WebProcessConnection::createPluginInternal(const PluginCreationParameters& void WebProcessConnection::createPlugin(const PluginCreationParameters& creationParameters, PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> reply) { // Ensure we don't clamp any timers during initialization - ActivityAssertion activityAssertion(PluginProcess::shared()); + ActivityAssertion activityAssertion(PluginProcess::singleton().connectionActivity()); PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(creationParameters.pluginInstanceID); @@ -243,7 +245,7 @@ void WebProcessConnection::createPlugin(const PluginCreationParameters& creation } // If its initialization is complete then we need to respond to this message with the correct information about its creation. -#if PLATFORM(MAC) +#if PLATFORM(COCOA) reply->send(true, pluginControllerProxy->wantsWheelEvents(), pluginControllerProxy->remoteLayerClientID()); #else reply->send(true, pluginControllerProxy->wantsWheelEvents(), 0); @@ -319,7 +321,7 @@ void WebProcessConnection::createPluginAsynchronously(const PluginCreationParame m_connection->sendSync(Messages::PluginProxy::DidCreatePlugin(wantsWheelEvents, remoteLayerClientID), Messages::PluginProxy::DidCreatePlugin::Reply(), creationParameters.pluginInstanceID); } - + } // namespace WebKit #endif // ENABLE(NETSCAPE_PLUGIN_API) |