diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp index 86ba91c08..dbf12ccf0 100644 --- a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp +++ b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp @@ -40,8 +40,8 @@ PassRefPtr<WebConnectionToWebProcess> WebConnectionToWebProcess::create(WebProce } WebConnectionToWebProcess::WebConnectionToWebProcess(WebProcessProxy* process, CoreIPC::Connection::Identifier connectionIdentifier, RunLoop* runLoop) - : WebConnection(CoreIPC::Connection::createServerConnection(connectionIdentifier, this, runLoop)) - , m_process(process) + : m_process(process) + , m_connection(CoreIPC::Connection::createServerConnection(connectionIdentifier, this, runLoop)) { #if OS(DARWIN) m_connection->setShouldCloseConnectionOnMachExceptions(); @@ -50,27 +50,42 @@ WebConnectionToWebProcess::WebConnectionToWebProcess(WebProcessProxy* process, C #endif } -// WebConnection - -void WebConnectionToWebProcess::encodeMessageBody(CoreIPC::ArgumentEncoder* argumentEncoder, APIObject* messageBody) +void WebConnectionToWebProcess::invalidate() { - argumentEncoder->encode(WebContextUserMessageEncoder(messageBody)); + m_connection->invalidate(); + m_connection = nullptr; + m_process = 0; } -bool WebConnectionToWebProcess::decodeMessageBody(CoreIPC::ArgumentDecoder* argumentDecoder, RefPtr<APIObject>& messageBody) +// WebConnection + +void WebConnectionToWebProcess::postMessage(const String& messageName, APIObject* messageBody) { - if (!argumentDecoder->decode(WebContextUserMessageDecoder(messageBody, m_process))) - return false; + // We need to check if we have an underlying process here since a user of the API can hold + // onto us and call postMessage even after the process has been invalidated. + if (!m_process) + return; - return true; + m_process->deprecatedSend(WebConnectionLegacyMessage::PostMessage, 0, CoreIPC::In(messageName, WebContextUserMessageEncoder(messageBody))); } // CoreIPC::Connection::Client void WebConnectionToWebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) { - if (messageID.is<CoreIPC::MessageClassWebConnection>()) { - didReceiveWebConnectionMessage(connection, messageID, arguments); + if (messageID.is<CoreIPC::MessageClassWebConnectionLegacy>()) { + switch (messageID.get<WebConnectionLegacyMessage::Kind>()) { + case WebConnectionLegacyMessage::PostMessage: { + String messageName; + RefPtr<APIObject> messageBody; + WebContextUserMessageDecoder messageDecoder(messageBody, m_process); + if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder))) + return; + + forwardDidReceiveMessageToClient(messageName, messageBody.get()); + return; + } + } return; } @@ -109,6 +124,11 @@ void WebConnectionToWebProcess::didReceiveInvalidMessage(CoreIPC::Connection* co m_client.didClose(this); } +void WebConnectionToWebProcess::syncMessageSendTimedOut(CoreIPC::Connection* connection) +{ + m_process->syncMessageSendTimedOut(connection); +} + #if PLATFORM(WIN) Vector<HWND> WebConnectionToWebProcess::windowsToReceiveSentMessagesWhileWaitingForSyncReply() { |