summaryrefslogtreecommitdiff
path: root/Source/WebKit2/NetworkProcess
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/NetworkProcess
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/NetworkProcess')
-rw-r--r--Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp94
-rw-r--r--Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h64
-rw-r--r--Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in29
-rw-r--r--Source/WebKit2/NetworkProcess/NetworkProcess.cpp39
-rw-r--r--Source/WebKit2/NetworkProcess/NetworkProcess.h14
-rw-r--r--Source/WebKit2/NetworkProcess/NetworkProcess.messages.in3
6 files changed, 234 insertions, 9 deletions
diff --git a/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp b/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
new file mode 100644
index 000000000..1fdce180b
--- /dev/null
+++ b/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "NetworkConnectionToWebProcess.h"
+
+#include "ConnectionStack.h"
+#include "NetworkProcess.h"
+#include <WebCore/RunLoop.h>
+
+#if ENABLE(NETWORK_PROCESS)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<NetworkConnectionToWebProcess> NetworkConnectionToWebProcess::create(CoreIPC::Connection::Identifier connectionIdentifier)
+{
+ return adoptRef(new NetworkConnectionToWebProcess(connectionIdentifier));
+}
+
+NetworkConnectionToWebProcess::NetworkConnectionToWebProcess(CoreIPC::Connection::Identifier connectionIdentifier)
+{
+ m_connection = CoreIPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main());
+ m_connection->setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(true);
+ m_connection->open();
+}
+
+NetworkConnectionToWebProcess::~NetworkConnectionToWebProcess()
+{
+ ASSERT(!m_connection);
+}
+
+void NetworkConnectionToWebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
+{
+ ConnectionStack::CurrentConnectionPusher currentConnection(ConnectionStack::shared(), connection);
+
+ if (messageID.is<CoreIPC::MessageClassNetworkConnectionToWebProcess>()) {
+ didReceiveNetworkConnectionToWebProcessMessage(connection, messageID, decoder);
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
+}
+
+void NetworkConnectionToWebProcess::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& arguments, OwnPtr<CoreIPC::MessageEncoder>& reply)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void NetworkConnectionToWebProcess::didClose(CoreIPC::Connection*)
+{
+ // Protect ourself as we might be otherwise be deleted during this function
+ RefPtr<NetworkConnectionToWebProcess> protector(this);
+
+ NetworkProcess::shared().removeNetworkConnectionToWebProcess(this);
+
+ m_connection = 0;
+}
+
+void NetworkConnectionToWebProcess::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID)
+{
+}
+
+void NetworkConnectionToWebProcess::didReceiveNetworkConnectionToWebProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&)
+{
+ // Empty for now - There are no messages to handle.
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(NETWORK_PROCESS)
diff --git a/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h b/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h
new file mode 100644
index 000000000..635136094
--- /dev/null
+++ b/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h
@@ -0,0 +1,64 @@
+/*
+ * 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 NetworkConnectionToWebProcess_h
+#define NetworkConnectionToWebProcess_h
+
+#if ENABLE(NETWORK_PROCESS)
+
+#include "Connection.h"
+#include "NetworkConnectionToWebProcessMessages.h"
+#include <wtf/HashSet.h>
+#include <wtf/RefCounted.h>
+
+namespace WebKit {
+
+class NetworkConnectionToWebProcess : public RefCounted<NetworkConnectionToWebProcess>, CoreIPC::Connection::Client {
+public:
+ static PassRefPtr<NetworkConnectionToWebProcess> create(CoreIPC::Connection::Identifier);
+ virtual ~NetworkConnectionToWebProcess();
+
+ CoreIPC::Connection* connection() const { return m_connection.get(); }
+
+private:
+ NetworkConnectionToWebProcess(CoreIPC::Connection::Identifier);
+
+ // CoreIPC::Connection::Client
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
+ virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
+ virtual void didClose(CoreIPC::Connection*);
+ virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
+
+ // Message handlers.
+ void didReceiveNetworkConnectionToWebProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
+
+ RefPtr<CoreIPC::Connection> m_connection;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(NETWORK_PROCESS)
+
+#endif // NetworkConnectionToWebProcess_h
diff --git a/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in b/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in
new file mode 100644
index 000000000..a1047c83a
--- /dev/null
+++ b/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.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 -> NetworkConnectionToWebProcess {
+
+}
+
+#endif // ENABLE(NETWORK_PROCESS)
diff --git a/Source/WebKit2/NetworkProcess/NetworkProcess.cpp b/Source/WebKit2/NetworkProcess/NetworkProcess.cpp
index b2289b07b..5be2e9b21 100644
--- a/Source/WebKit2/NetworkProcess/NetworkProcess.cpp
+++ b/Source/WebKit2/NetworkProcess/NetworkProcess.cpp
@@ -30,7 +30,11 @@
#include "ArgumentCoders.h"
#include "Attachment.h"
+#include "NetworkConnectionToWebProcess.h"
+#include "NetworkProcessProxyMessages.h"
+#include <WebCore/ResourceRequest.h>
#include <WebCore/RunLoop.h>
+#include <wtf/text/CString.h>
using namespace WebCore;
@@ -59,22 +63,27 @@ void NetworkProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier
m_uiConnection->open();
}
+void NetworkProcess::removeNetworkConnectionToWebProcess(NetworkConnectionToWebProcess* connection)
+{
+ size_t vectorIndex = m_webProcessConnections.find(connection);
+ ASSERT(vectorIndex != notFound);
+
+ m_webProcessConnections.remove(vectorIndex);
+}
+
bool NetworkProcess::shouldTerminate()
{
return true;
}
-void NetworkProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+void NetworkProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
{
- didReceiveNetworkProcessMessage(connection, messageID, arguments);
+ didReceiveNetworkProcessMessage(connection, messageID, decoder);
}
void NetworkProcess::didClose(CoreIPC::Connection*)
{
- // Either the connection to the UIProcess or a connection to a WebProcess has gone away.
- // In the future we'll do appropriate cleanup and decide whether or not we want to keep
- // the NetworkProcess open.
- // For now we'll always close it.
+ // The UIProcess just crashed.
RunLoop::current()->stop();
}
@@ -92,6 +101,24 @@ void NetworkProcess::initializeNetworkProcess(const NetworkProcessCreationParame
platformInitialize(parameters);
}
+void NetworkProcess::createNetworkConnectionToWebProcess()
+{
+#if PLATFORM(MAC)
+ // Create the listening port.
+ mach_port_t listeningPort;
+ mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+
+ // Create a listening connection.
+ RefPtr<NetworkConnectionToWebProcess> connection = NetworkConnectionToWebProcess::create(CoreIPC::Connection::Identifier(listeningPort));
+ m_webProcessConnections.append(connection.release());
+
+ CoreIPC::Attachment clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
+ m_uiConnection->send(Messages::NetworkProcessProxy::DidCreateNetworkConnectionToWebProcess(clientPort), 0);
+#else
+ notImplemented();
+#endif
+}
+
} // namespace WebKit
#endif // ENABLE(NETWORK_PROCESS)
diff --git a/Source/WebKit2/NetworkProcess/NetworkProcess.h b/Source/WebKit2/NetworkProcess/NetworkProcess.h
index f72a8f9ab..5828e1f5e 100644
--- a/Source/WebKit2/NetworkProcess/NetworkProcess.h
+++ b/Source/WebKit2/NetworkProcess/NetworkProcess.h
@@ -36,7 +36,8 @@ namespace WebCore {
}
namespace WebKit {
-
+
+class NetworkConnectionToWebProcess;
struct NetworkProcessCreationParameters;
class NetworkProcess : ChildProcess {
@@ -46,6 +47,8 @@ public:
void initialize(CoreIPC::Connection::Identifier, WebCore::RunLoop*);
+ void removeNetworkConnectionToWebProcess(NetworkConnectionToWebProcess*);
+
private:
NetworkProcess();
~NetworkProcess();
@@ -56,17 +59,22 @@ private:
virtual bool shouldTerminate();
// 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 didReceiveNetworkProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveNetworkProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
void initializeNetworkProcess(const NetworkProcessCreationParameters&);
+ void createNetworkConnectionToWebProcess();
// The connection to the UI process.
RefPtr<CoreIPC::Connection> m_uiConnection;
+
+ // Connections to WebProcesses.
+ Vector<RefPtr<NetworkConnectionToWebProcess> > m_webProcessConnections;
+
};
} // namespace WebKit
diff --git a/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in b/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
index 5e46a8efb..029536a34 100644
--- a/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
+++ b/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
@@ -25,6 +25,9 @@
messages -> NetworkProcess {
# Initializes the network process.
InitializeNetworkProcess(WebKit::NetworkProcessCreationParameters processCreationParameters)
+
+ # Creates a connection for communication with a WebProcess
+ CreateNetworkConnectionToWebProcess()
}
#endif // ENABLE(NETWORK_PROCESS)