Title: [91013] trunk/Source/WebKit2
Revision
91013
Author
carlo...@webkit.org
Date
2011-07-14 10:44:29 -0700 (Thu, 14 Jul 2011)

Log Message

Reviewed by Anders Carlsson.

Implement plugin process for UNIX platform
https://bugs.webkit.org/show_bug.cgi?id=60629

* Platform/CoreIPC/Attachment.h:
* Platform/CoreIPC/unix/AttachmentUnix.cpp:
(CoreIPC::Attachment::Attachment): Add the ability to pass a
socket via Attachment.
* Platform/unix/SharedMemoryUnix.cpp:
(WebKit::SharedMemory::Handle::encode): Remove assertions that
check that the Handle is not null. In
PluginProxy::geometryDidChange we pass a null Handle if we do not
need to allocate a new backing store.
(WebKit::SharedMemory::Handle::releaseToAttachment): Ditto.
* PluginProcess/PluginProcess.cpp:
(WebKit::PluginProcess::createWebProcessConnection): Use
Attachment. Set up the connection with socketpair.
* UIProcess/Plugins/PluginProcessProxy.cpp:
(WebKit::PluginProcessProxy::pluginProcessCrashedOrFailedToLaunch):
(WebKit::PluginProcessProxy::didCreateWebProcessConnection):
* UIProcess/Plugins/PluginProcessProxy.h:
* UIProcess/Plugins/PluginProcessProxy.messages.in:
* UIProcess/WebProcessProxy.messages.in:
* WebProcess/Plugins/PluginProcessConnectionManager.cpp:
(WebKit::PluginProcessConnectionManager::getPluginProcessConnection):
Use Attachment to pass the connection.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (91012 => 91013)


--- trunk/Source/WebKit2/ChangeLog	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/ChangeLog	2011-07-14 17:44:29 UTC (rev 91013)
@@ -1,3 +1,33 @@
+2011-07-14  Balazs Kelemen  <kbal...@webkit.org> and Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Reviewed by Anders Carlsson.
+
+        Implement plugin process for UNIX platform
+        https://bugs.webkit.org/show_bug.cgi?id=60629
+
+        * Platform/CoreIPC/Attachment.h:
+        * Platform/CoreIPC/unix/AttachmentUnix.cpp:
+        (CoreIPC::Attachment::Attachment): Add the ability to pass a
+        socket via Attachment.
+        * Platform/unix/SharedMemoryUnix.cpp:
+        (WebKit::SharedMemory::Handle::encode): Remove assertions that
+        check that the Handle is not null. In
+        PluginProxy::geometryDidChange we pass a null Handle if we do not
+        need to allocate a new backing store.
+        (WebKit::SharedMemory::Handle::releaseToAttachment): Ditto.
+        * PluginProcess/PluginProcess.cpp:
+        (WebKit::PluginProcess::createWebProcessConnection): Use
+        Attachment. Set up the connection with socketpair.
+        * UIProcess/Plugins/PluginProcessProxy.cpp:
+        (WebKit::PluginProcessProxy::pluginProcessCrashedOrFailedToLaunch):
+        (WebKit::PluginProcessProxy::didCreateWebProcessConnection):
+        * UIProcess/Plugins/PluginProcessProxy.h:
+        * UIProcess/Plugins/PluginProcessProxy.messages.in:
+        * UIProcess/WebProcessProxy.messages.in:
+        * WebProcess/Plugins/PluginProcessConnectionManager.cpp:
+        (WebKit::PluginProcessConnectionManager::getPluginProcessConnection):
+        Use Attachment to pass the connection.
+
 2011-07-14  Ada Chan  <adac...@apple.com>
 
         Implement support to center selection on a page for WebKit2.

Modified: trunk/Source/WebKit2/Platform/CoreIPC/Attachment.h (91012 => 91013)


--- trunk/Source/WebKit2/Platform/CoreIPC/Attachment.h	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Attachment.h	2011-07-14 17:44:29 UTC (rev 91013)
@@ -41,7 +41,8 @@
         MachPortType,
         MachOOLMemoryType,
 #elif USE(UNIX_DOMAIN_SOCKETS)
-        MappedMemory
+        SocketType,
+        MappedMemoryType
 #endif
     };
 
@@ -50,6 +51,7 @@
     Attachment(void* address, mach_msg_size_t size, mach_msg_copy_options_t copyOptions, bool deallocate);
 #elif USE(UNIX_DOMAIN_SOCKETS)
     Attachment(int fileDescriptor, size_t);
+    Attachment(int fileDescriptor);
 #endif
 
     Type type() const { return m_type; }

Modified: trunk/Source/WebKit2/Platform/CoreIPC/unix/AttachmentUnix.cpp (91012 => 91013)


--- trunk/Source/WebKit2/Platform/CoreIPC/unix/AttachmentUnix.cpp	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/Platform/CoreIPC/unix/AttachmentUnix.cpp	2011-07-14 17:44:29 UTC (rev 91013)
@@ -33,14 +33,19 @@
 namespace CoreIPC {
 
 Attachment::Attachment(int fileDescriptor, size_t size)
-    : m_type(MappedMemory)
+    : m_type(MappedMemoryType)
     , m_fileDescriptor(fileDescriptor)
     , m_size(size)
 {
-    ASSERT(m_fileDescriptor);
-    ASSERT(m_size);
 }
 
+Attachment::Attachment(int fileDescriptor)
+    : m_type(SocketType)
+    , m_fileDescriptor(fileDescriptor)
+    , m_size(0)
+{
+}
+
 void Attachment::dispose()
 {
     if (m_fileDescriptor != -1)

Modified: trunk/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp (91012 => 91013)


--- trunk/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp	2011-07-14 17:44:29 UTC (rev 91013)
@@ -70,8 +70,6 @@
 
 void SharedMemory::Handle::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
-    ASSERT(!isNull());
-
     encoder->encode(releaseToAttachment());
 }
 
@@ -90,8 +88,6 @@
 
 CoreIPC::Attachment SharedMemory::Handle::releaseToAttachment() const
 {
-    ASSERT(!isNull());
-
     int temp = m_fileDescriptor;
     m_fileDescriptor = -1;
     return CoreIPC::Attachment(temp, m_size);

Modified: trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp (91012 => 91013)


--- trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp	2011-07-14 17:44:29 UTC (rev 91013)
@@ -29,14 +29,26 @@
 #if ENABLE(PLUGIN_PROCESS)
 
 #include "ArgumentCoders.h"
+#include "Attachment.h"
 #include "NetscapePluginModule.h"
 #include "PluginProcessProxyMessages.h"
 #include "PluginProcessCreationParameters.h"
 #include "WebProcessConnection.h"
+#include <WebCore/NotImplemented.h>
 
-#if PLATFORM(MAC)
-#include "MachPort.h"
+#if USE(UNIX_DOMAIN_SOCKETS)
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/resource.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#if PLATFORM(GTK)
+#define SOCKET_TYPE SOCK_STREAM
+#else
+#define SOCKET_TYPE SOCK_DGRAM
 #endif
+#endif
 
 namespace WebKit {
 
@@ -150,11 +162,42 @@
     RefPtr<WebProcessConnection> connection = WebProcessConnection::create(listeningPort);
     m_webProcessConnections.append(connection.release());
 
-    CoreIPC::MachPort clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
+    CoreIPC::Attachment clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
     m_connection->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientPort), 0);
+#elif USE(UNIX_DOMAIN_SOCKETS)
+    int sockets[2];
+    if (socketpair(AF_UNIX, SOCKET_TYPE, 0, sockets) == -1) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+
+    // Don't expose the plugin process socket to the web process.
+    while (fcntl(sockets[1], F_SETFD, FD_CLOEXEC)  == -1) {
+        if (errno != EINTR) {
+            ASSERT_NOT_REACHED();
+            while (close(sockets[0]) == -1 && errno == EINTR) { }
+            while (close(sockets[1]) == -1 && errno == EINTR) { }
+            return;
+        }
+    }
+
+    // Don't expose the web process socket to possible future web processes.
+    while (fcntl(sockets[0], F_SETFD, FD_CLOEXEC) == -1) {
+        if (errno != EINTR) {
+            ASSERT_NOT_REACHED();
+            while (close(sockets[0]) == -1 && errno == EINTR) { }
+            while (close(sockets[1]) == -1 && errno == EINTR) { }
+            return;
+        }
+    }
+
+    RefPtr<WebProcessConnection> connection = WebProcessConnection::create(sockets[1]);
+    m_webProcessConnections.append(connection.release());
+
+    CoreIPC::Attachment clientSocket(sockets[0]);
+    m_connection->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientSocket), 0);
 #else
-    // FIXME: Implement.
-    ASSERT_NOT_REACHED();
+    notImplemented();
 #endif
 
     if (NetscapePluginModule* module = netscapePluginModule()) {

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp (91012 => 91013)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp	2011-07-14 17:44:29 UTC (rev 91013)
@@ -37,6 +37,7 @@
 #include "WebPluginSiteDataManager.h"
 #include "WebProcessMessages.h"
 #include "WebProcessProxy.h"
+#include <WebCore/NotImplemented.h>
 
 #if PLATFORM(MAC)
 #include "MachPort.h"
@@ -134,10 +135,11 @@
         RefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst();
 
 #if PLATFORM(MAC)
-        reply->send(CoreIPC::MachPort(0, MACH_MSG_TYPE_MOVE_SEND));
+        reply->send(CoreIPC::Attachment(0, MACH_MSG_TYPE_MOVE_SEND));
+#elif USE(UNIX_DOMAIN_SOCKETS)
+        reply->send(CoreIPC::Attachment());
 #else
-        // FIXME: Implement.
-        ASSERT_NOT_REACHED();
+        notImplemented();
 #endif
     }
 
@@ -225,17 +227,21 @@
     m_numPendingConnectionRequests = 0;
 }
 
-#if PLATFORM(MAC)
-void PluginProcessProxy::didCreateWebProcessConnection(const CoreIPC::MachPort& machPort)
+void PluginProcessProxy::didCreateWebProcessConnection(const CoreIPC::Attachment& connectionIdentifier)
 {
     ASSERT(!m_pendingConnectionReplies.isEmpty());
 
     // Grab the first pending connection reply.
     RefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst();
 
-    reply->send(CoreIPC::MachPort(machPort.port(), MACH_MSG_TYPE_MOVE_SEND));
+#if PLATFORM(MAC)
+    reply->send(CoreIPC::Attachment(connectionIdentifier.port(), MACH_MSG_TYPE_MOVE_SEND));
+#elif USE(UNIX_DOMAIN_SOCKETS)
+    reply->send(connectionIdentifier);
+#else
+    notImplemented();
+#endif
 }
-#endif
 
 void PluginProcessProxy::didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID)
 {

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h (91012 => 91013)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h	2011-07-14 17:44:29 UTC (rev 91013)
@@ -96,9 +96,7 @@
 
     // Message handlers
     void didReceivePluginProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
-#if PLATFORM(MAC)
-    void didCreateWebProcessConnection(const CoreIPC::MachPort&);
-#endif
+    void didCreateWebProcessConnection(const CoreIPC::Attachment&);
     void didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID);
     void didClearSiteData(uint64_t callbackID);
 

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in (91012 => 91013)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in	2011-07-14 17:44:29 UTC (rev 91013)
@@ -23,9 +23,7 @@
 #if ENABLE(PLUGIN_PROCESS)
 
 messages -> PluginProcessProxy {
-#if PLATFORM(MAC)
-    DidCreateWebProcessConnection(CoreIPC::MachPort connectionIdentifier)
-#endif
+    DidCreateWebProcessConnection(CoreIPC::Attachment connectionIdentifier)
 
     DidGetSitesWithData(Vector<WTF::String> sites, uint64_t callbackID)
     DidClearSiteData(uint64_t callbackID)

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in (91012 => 91013)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in	2011-07-14 17:44:29 UTC (rev 91013)
@@ -28,7 +28,7 @@
     ShouldTerminate() -> (bool shouldTerminate)
 
 #if ENABLE(PLUGIN_PROCESS)
-    GetPluginProcessConnection(WTF::String pluginPath) -> (CoreIPC::MachPort connectionHandle) Delayed
+    GetPluginProcessConnection(WTF::String pluginPath) -> (CoreIPC::Attachment connectionHandle) Delayed
     PluginSyncMessageSendTimedOut(WTF::String pluginPath)
 #endif
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.cpp (91012 => 91013)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.cpp	2011-07-14 17:42:12 UTC (rev 91012)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.cpp	2011-07-14 17:44:29 UTC (rev 91013)
@@ -56,21 +56,20 @@
             return m_pluginProcessConnections[i].get();
     }
 
-    CoreIPC::Connection::Identifier connectionIdentifier;
-#if PLATFORM(MAC)
-    CoreIPC::MachPort connectionMachPort;
-
-    if (!WebProcess::shared().connection()->sendSync(Messages::WebProcessProxy::GetPluginProcessConnection(pluginPath), Messages::WebProcessProxy::GetPluginProcessConnection::Reply(connectionMachPort), 0))
+    CoreIPC::Attachment encodedConnectionIdentifier;
+    if (!WebProcess::shared().connection()->sendSync(Messages::WebProcessProxy::GetPluginProcessConnection(pluginPath),
+                                                     Messages::WebProcessProxy::GetPluginProcessConnection::Reply(encodedConnectionIdentifier), 0))
         return 0;
 
-    connectionIdentifier = connectionMachPort.port();
-#else
-    // FIXME: Implement.
-    connectionIdentifier = 0;
-    ASSERT_NOT_REACHED();
-#endif
+#if PLATFORM(MAC)
+    CoreIPC::Connection::Identifier connectionIdentifier = encodedConnectionIdentifier.port();
     if (!connectionIdentifier)
         return 0;
+#elif USE(UNIX_DOMAIN_SOCKETS)
+    CoreIPC::Connection::Identifier connectionIdentifier = encodedConnectionIdentifier.fileDescriptor();
+    if (connectionIdentifier == -1)
+        return 0;
+#endif
 
     RefPtr<PluginProcessConnection> pluginProcessConnection = PluginProcessConnection::create(this, pluginPath, connectionIdentifier);
     m_pluginProcessConnections.append(pluginProcessConnection);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to