summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/Network
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-10-22 15:40:17 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-10-22 15:40:17 +0200
commit43a42f108af6bcbd91f2672731c3047c26213af1 (patch)
tree7fa092e5f5d873c72f2486a70e26be26f7a38bec /Source/WebKit2/UIProcess/Network
parentd9cf437c840c6eb7417bdd97e6c40979255d3158 (diff)
downloadqtwebkit-43a42f108af6bcbd91f2672731c3047c26213af1.tar.gz
Imported WebKit commit 302e7806bff028bd1167a1ec7c86a1ee00ecfb49 (http://svn.webkit.org/repository/webkit/trunk@132067)
New snapshot that fixes build without QtWidgets
Diffstat (limited to 'Source/WebKit2/UIProcess/Network')
-rw-r--r--Source/WebKit2/UIProcess/Network/NetworkProcessManager.cpp70
-rw-r--r--Source/WebKit2/UIProcess/Network/NetworkProcessManager.h59
-rw-r--r--Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp67
-rw-r--r--Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h19
-rw-r--r--Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in29
5 files changed, 237 insertions, 7 deletions
diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessManager.cpp b/Source/WebKit2/UIProcess/Network/NetworkProcessManager.cpp
new file mode 100644
index 000000000..00f16f457
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Network/NetworkProcessManager.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010, 2011, 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.
+ */
+
+#include "config.h"
+#include "NetworkProcessManager.h"
+
+#include "NetworkProcessProxy.h"
+
+namespace WebKit {
+
+NetworkProcessManager& NetworkProcessManager::shared()
+{
+ DEFINE_STATIC_LOCAL(NetworkProcessManager, networkProcessManager, ());
+ return networkProcessManager;
+}
+
+NetworkProcessManager::NetworkProcessManager()
+{
+}
+
+void NetworkProcessManager::getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply)
+{
+ ASSERT(reply);
+
+ ensureNetworkProcess();
+ ASSERT(m_networkProcess);
+
+ m_networkProcess->getNetworkProcessConnection(reply);
+}
+
+void NetworkProcessManager::ensureNetworkProcess()
+{
+ if (m_networkProcess)
+ return;
+
+ m_networkProcess = NetworkProcessProxy::create(this);
+}
+
+void NetworkProcessManager::removeNetworkProcessProxy(NetworkProcessProxy* networkProcessProxy)
+{
+ ASSERT(m_networkProcess);
+ ASSERT(networkProcessProxy == m_networkProcess.get());
+
+ m_networkProcess = 0;
+}
+
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessManager.h b/Source/WebKit2/UIProcess/Network/NetworkProcessManager.h
new file mode 100644
index 000000000..08d422b25
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Network/NetworkProcessManager.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010, 2011, 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 NetworkProcessManager_h
+#define NetworkProcessManager_h
+
+#include "Connection.h"
+#include "WebProcessProxyMessages.h"
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class NetworkProcessConnection;
+class NetworkProcessProxy;
+class WebProcessProxy;
+
+class NetworkProcessManager {
+ WTF_MAKE_NONCOPYABLE(NetworkProcessManager);
+public:
+ static NetworkProcessManager& shared();
+
+ void ensureNetworkProcess();
+
+ void getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>);
+
+ void removeNetworkProcessProxy(NetworkProcessProxy*);
+
+private:
+ NetworkProcessManager();
+
+ RefPtr<NetworkProcessProxy> m_networkProcess;
+};
+
+} // namespace WebKit
+
+#endif // NetworkProcessManager_h
diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
index fe528351a..d1a0135f5 100644
--- a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
+++ b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
@@ -27,7 +27,10 @@
#include "NetworkProcessProxy.h"
#include "NetworkProcessCreationParameters.h"
+#include "NetworkProcessManager.h"
#include "NetworkProcessMessages.h"
+#include "WebContext.h"
+#include "WebProcessMessages.h"
#include <WebCore/RunLoop.h>
#if ENABLE(NETWORK_PROCESS)
@@ -36,12 +39,14 @@ using namespace WebCore;
namespace WebKit {
-PassRefPtr<NetworkProcessProxy> NetworkProcessProxy::create()
+PassRefPtr<NetworkProcessProxy> NetworkProcessProxy::create(NetworkProcessManager* manager)
{
- return adoptRef(new NetworkProcessProxy);
+ return adoptRef(new NetworkProcessProxy(manager));
}
-NetworkProcessProxy::NetworkProcessProxy()
+NetworkProcessProxy::NetworkProcessProxy(NetworkProcessManager* manager)
+ : m_networkProcessManager(manager)
+ , m_numPendingConnectionRequests(0)
{
ProcessLauncher::LaunchOptions launchOptions;
launchOptions.processType = ProcessLauncher::NetworkProcess;
@@ -62,14 +67,49 @@ NetworkProcessProxy::~NetworkProcessProxy()
}
-void NetworkProcessProxy::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*)
+void NetworkProcessProxy::getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply)
{
+ m_pendingConnectionReplies.append(reply);
+ if (m_processLauncher->isLaunching()) {
+ m_numPendingConnectionRequests++;
+ return;
+ }
+
+ m_connection->send(Messages::NetworkProcess::CreateNetworkConnectionToWebProcess(), 0, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+}
+
+void NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch()
+{
+ // The network process must have crashed or exited, send any pending sync replies we might have.
+ while (!m_pendingConnectionReplies.isEmpty()) {
+ RefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst();
+
+#if PLATFORM(MAC)
+ reply->send(CoreIPC::Attachment(0, MACH_MSG_TYPE_MOVE_SEND));
+#else
+ notImplemented();
+#endif
+ }
+
+ // Tell the network process manager to forget about this network process proxy. This may cause us to be deleted.
+ m_networkProcessManager->removeNetworkProcessProxy(this);
+}
+
+void NetworkProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
+{
+ didReceiveNetworkProcessProxyMessage(connection, messageID, decoder);
}
void NetworkProcessProxy::didClose(CoreIPC::Connection*)
{
+ // Notify all WebProcesses that the NetworkProcess crashed.
+ const Vector<WebContext*>& contexts = WebContext::allContexts();
+ for (size_t i = 0; i < contexts.size(); ++i)
+ contexts[i]->sendToAllProcesses(Messages::WebProcess::NetworkProcessCrashed());
+ // This may cause us to be deleted.
+ networkProcessCrashedOrFailedToLaunch();
}
void NetworkProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID)
@@ -82,6 +122,20 @@ void NetworkProcessProxy::syncMessageSendTimedOut(CoreIPC::Connection*)
}
+void NetworkProcessProxy::didCreateNetworkConnectionToWebProcess(const CoreIPC::Attachment& connectionIdentifier)
+{
+ ASSERT(!m_pendingConnectionReplies.isEmpty());
+
+ // Grab the first pending connection reply.
+ RefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst();
+
+#if PLATFORM(MAC)
+ reply->send(CoreIPC::Attachment(connectionIdentifier.port(), MACH_MSG_TYPE_MOVE_SEND));
+#else
+ notImplemented();
+#endif
+}
+
void NetworkProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier)
{
ASSERT(!m_connection);
@@ -103,6 +157,11 @@ void NetworkProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connecti
// Initialize the network host process.
m_connection->send(Messages::NetworkProcess::InitializeNetworkProcess(parameters), 0);
+
+ for (unsigned i = 0; i < m_numPendingConnectionRequests; ++i)
+ m_connection->send(Messages::NetworkProcess::CreateNetworkConnectionToWebProcess(), 0);
+
+ m_numPendingConnectionRequests = 0;
}
} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h
index 57e37e653..1840a8e91 100644
--- a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h
+++ b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h
@@ -35,24 +35,33 @@
namespace WebKit {
+class NetworkProcessManager;
struct NetworkProcessCreationParameters;
class NetworkProcessProxy : public RefCounted<NetworkProcessProxy>, CoreIPC::Connection::Client, ProcessLauncher::Client {
public:
- static PassRefPtr<NetworkProcessProxy> create();
+ static PassRefPtr<NetworkProcessProxy> create(NetworkProcessManager*);
~NetworkProcessProxy();
+ void getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>);
+
private:
- NetworkProcessProxy();
+ NetworkProcessProxy(NetworkProcessManager*);
void platformInitializeNetworkProcess(NetworkProcessCreationParameters&);
+ void networkProcessCrashedOrFailedToLaunch();
+
// CoreIPC::Connection::Client
- virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
virtual void didClose(CoreIPC::Connection*);
virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
virtual void syncMessageSendTimedOut(CoreIPC::Connection*);
+ // Message handlers
+ void didReceiveNetworkProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
+ void didCreateNetworkConnectionToWebProcess(const CoreIPC::Attachment&);
+
// ProcessLauncher::Client
virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier);
@@ -62,6 +71,10 @@ private:
// The process launcher for the network process.
RefPtr<ProcessLauncher> m_processLauncher;
+ NetworkProcessManager* m_networkProcessManager;
+
+ unsigned m_numPendingConnectionRequests;
+ Deque<RefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> > m_pendingConnectionReplies;
};
} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in
new file mode 100644
index 000000000..379b10864
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in
@@ -0,0 +1,29 @@
+# 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.
+
+#if ENABLE(NETWORK_PROCESS)
+
+messages -> NetworkProcessProxy {
+ DidCreateNetworkConnectionToWebProcess(CoreIPC::Attachment connectionIdentifier)
+}
+
+#endif // ENABLE(NETWORK_PROCESS)