+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.
#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 {
{
}
+#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;
// 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);