[Qt][WebKit2][Mac] WebProcess should exit automatically when UIProcess dies.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 14:04:16 +0000 (14:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 14:04:16 +0000 (14:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68439

We use a dispatch queue and a dispatch source in the WebProcess
to receive a notification when the UI Process dies.
The WebProcess then commits suicide.

Patch by Zeno Albisser <zeno.albisser@nokia.com> on 2011-10-03
Reviewed by Andreas Kling.

* WebProcess/qt/WebProcessQt.cpp:
(WebKit::parentProcessDiedCallback):
(WebKit::WebProcess::platformInitializeWebProcess):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96494 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/qt/WebProcessQt.cpp

index 9d7ceab..9966c02 100644 (file)
@@ -1,3 +1,18 @@
+2011-10-03  Zeno Albisser  <zeno.albisser@nokia.com>
+
+        [Qt][WebKit2][Mac] WebProcess should exit automatically when UIProcess dies.
+        https://bugs.webkit.org/show_bug.cgi?id=68439
+
+        We use a dispatch queue and a dispatch source in the WebProcess
+        to receive a notification when the UI Process dies.
+        The WebProcess then commits suicide.
+
+        Reviewed by Andreas Kling.
+
+        * WebProcess/qt/WebProcessQt.cpp:
+        (WebKit::parentProcessDiedCallback):
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2011-10-02  Zeno Albisser  <zeno.albisser@nokia.com>
 
         [Qt][WK2][Mac] WebKit2 does not build on mac after merge of Qt5 refactor branch.
index 40fb702..05a0c64 100644 (file)
 #include "WebProcess.h"
 
 #include "WebProcessCreationParameters.h"
-#include <WebCore/RuntimeEnabledFeatures.h>
+
+#include <QCoreApplication>
 #include <QNetworkAccessManager>
 #include <QNetworkCookieJar>
 #include <WebCore/CookieJarQt.h>
+#include <WebCore/RuntimeEnabledFeatures.h>
+
+#if defined(Q_OS_MACX)
+#include <dispatch/dispatch.h>
+#endif
 
 namespace WebKit {
 
@@ -43,6 +49,13 @@ void WebProcess::platformClearResourceCaches(ResourceCachesToClear)
 {
 }
 
+#if defined(Q_OS_MACX)
+static void parentProcessDiedCallback(void*)
+{
+    QCoreApplication::quit();
+}
+#endif
+
 void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters& parameters, CoreIPC::ArgumentDecoder* arguments)
 {
     m_networkAccessManager = new QNetworkAccessManager;
@@ -52,6 +65,16 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
     // Do not let QNetworkAccessManager delete the jar.
     jar->setParent(0);
 
+#if defined(Q_OS_MACX)
+    pid_t ppid = getppid();
+    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+    dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, ppid, DISPATCH_PROC_EXIT, queue);
+    if (source) {
+        dispatch_source_set_event_handler_f(source, parentProcessDiedCallback);
+        dispatch_resume(source);
+    }
+#endif
+
     // Disable runtime enabled features that have no WebKit2 implementation yet.
 #if ENABLE(DEVICE_ORIENTATION)
     WebCore::RuntimeEnabledFeatures::setDeviceMotionEnabled(false);