[GLIB] Remove support for GSocket main loop sources from GMainLoopSource
https://bugs.webkit.org/show_bug.cgi?id=150772

Reviewed by Žan Doberšek.

Source/WebKit2:

Add GSocketMonitor class to be used by Connection to monitor the
availability of the socket file descriptor instead of using a
GMainLoopSource.

* Platform/IPC/Connection.h:
* Platform/IPC/glib/GSocketMonitor.cpp: Added.
(IPC::GSocketMonitor::~GSocketMonitor):
(IPC::GSocketMonitor::socketSourceCallback):
(IPC::GSocketMonitor::start):
(IPC::GSocketMonitor::stop):
* Platform/IPC/glib/GSocketMonitor.h: Added.
* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::platformInvalidate):
(IPC::Connection::open):
* PlatformGTK.cmake:

Source/WTF:

It complicated the code just to make generic what is only used in
one place.

* wtf/glib/GMainLoopSource.cpp:
(WTF::GMainLoopSource::cancel): Deleted.
(WTF::GMainLoopSource::schedule): Deleted.
(WTF::GMainLoopSource::scheduleTimeoutSource): Deleted.
(WTF::GMainLoopSource::scheduleAfterDelay): Deleted.
(WTF::GMainLoopSource::finishVoidCallback): Deleted.
(WTF::GMainLoopSource::voidCallback): Deleted.
(WTF::GMainLoopSource::prepareBoolCallback): Deleted.
* wtf/glib/GMainLoopSource.h:
(WTF::GMainLoopSource::Context::operator=): Deleted.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@191881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index c8645d3..ca9d335 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,5 +1,26 @@
 2015-11-02  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GLIB] Remove support for GSocket main loop sources from GMainLoopSource
+        https://bugs.webkit.org/show_bug.cgi?id=150772
+
+        Reviewed by Žan Doberšek.
+
+        It complicated the code just to make generic what is only used in
+        one place.
+
+        * wtf/glib/GMainLoopSource.cpp:
+        (WTF::GMainLoopSource::cancel): Deleted.
+        (WTF::GMainLoopSource::schedule): Deleted.
+        (WTF::GMainLoopSource::scheduleTimeoutSource): Deleted.
+        (WTF::GMainLoopSource::scheduleAfterDelay): Deleted.
+        (WTF::GMainLoopSource::finishVoidCallback): Deleted.
+        (WTF::GMainLoopSource::voidCallback): Deleted.
+        (WTF::GMainLoopSource::prepareBoolCallback): Deleted.
+        * wtf/glib/GMainLoopSource.h:
+        (WTF::GMainLoopSource::Context::operator=): Deleted.
+
+2015-11-02  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [GLIB] Remove delete on destroy GMainLoopSources
         https://bugs.webkit.org/show_bug.cgi?id=150771
 
diff --git a/Source/WTF/wtf/glib/GMainLoopSource.cpp b/Source/WTF/wtf/glib/GMainLoopSource.cpp
index 50608b7..b4793205 100644
--- a/Source/WTF/wtf/glib/GMainLoopSource.cpp
+++ b/Source/WTF/wtf/glib/GMainLoopSource.cpp
@@ -54,8 +54,6 @@
 
     m_status = Ready;
 
-    g_cancellable_cancel(m_context.socketCancellable.get());
-
     if (!m_context.source)
         return;
 
@@ -84,10 +82,8 @@
     m_context = {
         adoptGRef(g_idle_source_new()),
         nullptr, // cancellable
-        nullptr, // socketCancellable
         WTF::move(function),
         nullptr, // boolCallback
-        nullptr, // socketCallback
         WTF::move(destroyFunction)
     };
     scheduleIdleSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context);
@@ -101,38 +97,13 @@
     m_context = {
         adoptGRef(g_idle_source_new()),
         nullptr, // cancellable
-        nullptr, // socketCancellable
         nullptr, // voidCallback
         WTF::move(function),
-        nullptr, // socketCallback
         WTF::move(destroyFunction)
     };
     scheduleIdleSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context);
 }
 
-void GMainLoopSource::schedule(const char* name, std::function<bool (GIOCondition)>&& function, GSocket* socket, GIOCondition condition, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    cancel();
-
-    ASSERT(!m_context.source);
-    GCancellable* socketCancellable = g_cancellable_new();
-    m_context = {
-        adoptGRef(g_socket_create_source(socket, condition, socketCancellable)),
-        nullptr, // cancellable
-        adoptGRef(socketCancellable),
-        nullptr, // voidCallback
-        nullptr, // boolCallback
-        WTF::move(function),
-        WTF::move(destroyFunction)
-    };
-
-    ASSERT(m_status == Ready);
-    m_status = Scheduled;
-    g_source_set_name(m_context.source.get(), name);
-    g_source_set_callback(m_context.source.get(), reinterpret_cast<GSourceFunc>(socketSourceCallback), this, nullptr);
-    g_source_attach(m_context.source.get(), context);
-}
-
 void GMainLoopSource::scheduleTimeoutSource(const char* name, GSourceFunc sourceFunction, int priority, GMainContext* context)
 {
     ASSERT(m_status == Ready);
@@ -153,10 +124,8 @@
     m_context = {
         adoptGRef(g_timeout_source_new(delay.count())),
         nullptr, // cancellable
-        nullptr, // socketCancellable
         WTF::move(function),
         nullptr, // boolCallback
-        nullptr, // socketCallback
         WTF::move(destroyFunction)
     };
     scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context);
@@ -170,10 +139,8 @@
     m_context = {
         adoptGRef(g_timeout_source_new(delay.count())),
         nullptr, // cancellable
-        nullptr, // socketCancellable
         nullptr, // voidCallback
         WTF::move(function),
-        nullptr, // socketCallback
         WTF::move(destroyFunction)
     };
     scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context);
@@ -187,10 +154,8 @@
     m_context = {
         adoptGRef(g_timeout_source_new_seconds(delay.count())),
         nullptr, // cancellable
-        nullptr, // socketCancellable
         WTF::move(function),
         nullptr, // boolCallback
-        nullptr, // socketCallback
         WTF::move(destroyFunction)
     };
     scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context);
@@ -204,10 +169,8 @@
     m_context = {
         adoptGRef(g_timeout_source_new_seconds(delay.count())),
         nullptr, // cancellable
-        nullptr, // socketCancellable
         nullptr, // voidCallback
         WTF::move(function),
-        nullptr, // socketCallback
         WTF::move(destroyFunction)
     };
     scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context);
@@ -250,10 +213,8 @@
     m_context = {
         adoptGRef(createMicrosecondsTimeoutSource(delay.count())),
         nullptr, // cancellable
-        nullptr, // socketCancellable
         WTF::move(function),
         nullptr, // boolCallback
-        nullptr, // socketCallback
         WTF::move(destroyFunction)
     };
     scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context);
@@ -267,10 +228,8 @@
     m_context = {
         adoptGRef(createMicrosecondsTimeoutSource(delay.count())),
         nullptr, // cancellable
-        nullptr, // socketCancellable
         nullptr, // voidCallback
         WTF::move(function),
-        nullptr, // socketCallback
         WTF::move(destroyFunction)
     };
     scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context);
@@ -351,40 +310,6 @@
     return retval;
 }
 
-bool GMainLoopSource::socketCallback(GIOCondition condition)
-{
-    if (!m_context.source)
-        return Stop;
-
-    Context context;
-    context = WTF::move(m_context);
-
-    ASSERT(context.socketCallback);
-    ASSERT(m_status == Scheduled || m_status == Dispatching);
-    m_status = Dispatching;
-
-    if (g_cancellable_is_cancelled(context.socketCancellable.get())) {
-        context.destroySource();
-        return Stop;
-    }
-
-    bool retval = context.socketCallback(condition);
-
-    if (m_status != Ready && !m_context.source) {
-        // m_status should reflect whether the GMainLoopSource has been rescheduled during dispatch.
-        ASSERT((!m_context.source && m_status == Dispatching) || m_status == Scheduled);
-        if (retval && !m_context.source)
-            m_context = WTF::move(context);
-        else if (!retval)
-            m_status = Ready;
-    }
-
-    if (context.source)
-        context.destroySource();
-
-    return retval;
-}
-
 gboolean GMainLoopSource::voidSourceCallback(GMainLoopSource* source)
 {
     source->voidCallback();
@@ -396,11 +321,6 @@
     return source->boolCallback() == Continue;
 }
 
-gboolean GMainLoopSource::socketSourceCallback(GSocket*, GIOCondition condition, GMainLoopSource* source)
-{
-    return source->socketCallback(condition) == Continue;
-}
-
 void GMainLoopSource::Context::destroySource()
 {
     g_source_destroy(source.get());
diff --git a/Source/WTF/wtf/glib/GMainLoopSource.h b/Source/WTF/wtf/glib/GMainLoopSource.h
index 99642ee..d34b6e8 100644
--- a/Source/WTF/wtf/glib/GMainLoopSource.h
+++ b/Source/WTF/wtf/glib/GMainLoopSource.h
@@ -33,8 +33,6 @@
 #include <wtf/Noncopyable.h>
 #include <wtf/glib/GRefPtr.h>
 
-typedef struct _GSocket GSocket;
-
 namespace WTF {
 
 class GMainLoopSource {
@@ -60,8 +58,6 @@
     WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<bool()>&&, std::chrono::microseconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);
     WTF_EXPORT_PRIVATE virtual void cancel();
 
-    WTF_EXPORT_PRIVATE void schedule(const char* name, std::function<bool(GIOCondition)>&&, GSocket*, GIOCondition, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);
-
 protected:
     enum Status { Ready, Scheduled, Dispatching };
 
@@ -71,10 +67,8 @@
         {
             source = WTF::move(c.source);
             cancellable = WTF::move(c.cancellable);
-            socketCancellable = WTF::move(c.socketCancellable);
             voidCallback = WTF::move(c.voidCallback);
             boolCallback = WTF::move(c.boolCallback);
-            socketCallback = WTF::move(c.socketCallback);
             destroyCallback = WTF::move(c.destroyCallback);
             return *this;
         }
@@ -83,10 +77,8 @@
 
         GRefPtr<GSource> source;
         GRefPtr<GCancellable> cancellable;
-        GRefPtr<GCancellable> socketCancellable;
         std::function<void ()> voidCallback;
         std::function<bool ()> boolCallback;
-        std::function<bool (GIOCondition)> socketCallback;
         std::function<void ()> destroyCallback;
     };
 
@@ -101,11 +93,9 @@
 private:
     void scheduleIdleSource(const char* name, GSourceFunc, int priority, GMainContext*);
     void scheduleTimeoutSource(const char* name, GSourceFunc, int priority, GMainContext*);
-    bool socketCallback(GIOCondition);
 
     static gboolean voidSourceCallback(GMainLoopSource*);
     static gboolean boolSourceCallback(GMainLoopSource*);
-    static gboolean socketSourceCallback(GSocket*, GIOCondition, GMainLoopSource*);
 
 protected:
     Context m_context;
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 5914e3a..8ba5ebc 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,26 @@
+2015-11-02  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GLIB] Remove support for GSocket main loop sources from GMainLoopSource
+        https://bugs.webkit.org/show_bug.cgi?id=150772
+
+        Reviewed by Žan Doberšek.
+
+        Add GSocketMonitor class to be used by Connection to monitor the
+        availability of the socket file descriptor instead of using a
+        GMainLoopSource.
+
+        * Platform/IPC/Connection.h:
+        * Platform/IPC/glib/GSocketMonitor.cpp: Added.
+        (IPC::GSocketMonitor::~GSocketMonitor):
+        (IPC::GSocketMonitor::socketSourceCallback):
+        (IPC::GSocketMonitor::start):
+        (IPC::GSocketMonitor::stop):
+        * Platform/IPC/glib/GSocketMonitor.h: Added.
+        * Platform/IPC/unix/ConnectionUnix.cpp:
+        (IPC::Connection::platformInvalidate):
+        (IPC::Connection::open):
+        * PlatformGTK.cmake:
+
 2015-11-01  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Use RunLoop in WorkQueue implementation
diff --git a/Source/WebKit2/Platform/IPC/Connection.h b/Source/WebKit2/Platform/IPC/Connection.h
index 8c9cc91..10f27b3 100644
--- a/Source/WebKit2/Platform/IPC/Connection.h
+++ b/Source/WebKit2/Platform/IPC/Connection.h
@@ -53,7 +53,7 @@
 #endif
 
 #if PLATFORM(GTK)
-#include <wtf/glib/GMainLoopSource.h>
+#include "GSocketMonitor.h"
 #endif
 
 namespace IPC {
@@ -337,7 +337,7 @@
     size_t m_fileDescriptorsSize;
     int m_socketDescriptor;
 #if PLATFORM(GTK)
-    GMainLoopSource m_socketEventSource;
+    GSocketMonitor m_socketMonitor;
 #endif
 #elif OS(DARWIN)
     // Called on the connection queue.
diff --git a/Source/WebKit2/Platform/IPC/glib/GSocketMonitor.cpp b/Source/WebKit2/Platform/IPC/glib/GSocketMonitor.cpp
new file mode 100644
index 0000000..2229058
--- /dev/null
+++ b/Source/WebKit2/Platform/IPC/glib/GSocketMonitor.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * 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 "GSocketMonitor.h"
+
+#include <gio/gio.h>
+
+namespace IPC {
+
+GSocketMonitor::~GSocketMonitor()
+{
+    stop();
+}
+
+gboolean GSocketMonitor::socketSourceCallback(GSocket*, GIOCondition condition, GSocketMonitor* monitor)
+{
+    if (g_cancellable_is_cancelled(monitor->m_cancellable.get()))
+        return G_SOURCE_REMOVE;
+    return monitor->m_callback(condition);
+}
+
+void GSocketMonitor::start(GSocket* socket, GIOCondition condition, RunLoop& runLoop, std::function<gboolean (GIOCondition)>&& callback)
+{
+    stop();
+
+    m_cancellable = adoptGRef(g_cancellable_new());
+    m_source = adoptGRef(g_socket_create_source(socket, condition, m_cancellable.get()));
+    g_source_set_name(m_source.get(), "[WebKit] Socket monitor");
+    m_callback = WTF::move(callback);
+    g_source_set_callback(m_source.get(), reinterpret_cast<GSourceFunc>(socketSourceCallback), this, nullptr);
+    g_source_attach(m_source.get(), runLoop.mainContext());
+}
+
+void GSocketMonitor::stop()
+{
+    if (!m_source)
+        return;
+
+    g_cancellable_cancel(m_cancellable.get());
+    m_cancellable = nullptr;
+    g_source_destroy(m_source.get());
+    m_source = nullptr;
+    m_callback = nullptr;
+}
+
+} // namespace IPC
diff --git a/Source/WebKit2/Platform/IPC/glib/GSocketMonitor.h b/Source/WebKit2/Platform/IPC/glib/GSocketMonitor.h
new file mode 100644
index 0000000..11e528a
--- /dev/null
+++ b/Source/WebKit2/Platform/IPC/glib/GSocketMonitor.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * 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 GSocketMonitor_h
+#define GSocketMonitor_h
+
+#include <functional>
+#include <glib.h>
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RunLoop.h>
+#include <wtf/glib/GRefPtr.h>
+
+typedef struct _GSocket GSocket;
+
+namespace IPC {
+
+class GSocketMonitor {
+    WTF_MAKE_NONCOPYABLE(GSocketMonitor);
+public:
+    GSocketMonitor() = default;
+    ~GSocketMonitor();
+
+    void start(GSocket*, GIOCondition, RunLoop&, std::function<gboolean (GIOCondition)>&&);
+    void stop();
+
+private:
+    static gboolean socketSourceCallback(GSocket*, GIOCondition, GSocketMonitor*);
+
+    GRefPtr<GSource> m_source;
+    GRefPtr<GCancellable> m_cancellable;
+    std::function<gboolean (GIOCondition)> m_callback;
+};
+
+} // namespace IPC
+
+#endif // GSocketMonitor_h
diff --git a/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp b/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
index 12ba1ff..fbc9def 100644
--- a/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
+++ b/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
@@ -148,7 +148,7 @@
         return;
 
 #if PLATFORM(GTK)
-    m_socketEventSource.cancel();
+    m_socketMonitor.stop();
 #elif PLATFORM(EFL)
     m_connectionQueue->unregisterSocketEventHandler(m_socketDescriptor);
 #endif
@@ -377,20 +377,20 @@
     m_isConnected = true;
 #if PLATFORM(GTK)
     GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(m_socketDescriptor, nullptr));
-    m_socketEventSource.schedule("[WebKit] Connection::SocketEventHandler", [protectedThis] (GIOCondition condition) {
+    m_socketMonitor.start(socket.get(), G_IO_IN, m_connectionQueue->runLoop(), [protectedThis] (GIOCondition condition) -> gboolean {
         if (condition & G_IO_HUP || condition & G_IO_ERR || condition & G_IO_NVAL) {
             protectedThis->connectionDidClose();
-            return GMainLoopSource::Stop;
+            return G_SOURCE_REMOVE;
         }
 
         if (condition & G_IO_IN) {
             protectedThis->readyReadHandler();
-            return GMainLoopSource::Continue;
+            return G_SOURCE_CONTINUE;
         }
 
         ASSERT_NOT_REACHED();
-        return GMainLoopSource::Stop;
-    }, socket.get(), G_IO_IN, nullptr, m_connectionQueue->runLoop().mainContext());
+        return G_SOURCE_REMOVE;
+    });
 #elif PLATFORM(EFL)
     m_connectionQueue->registerSocketEventHandler(m_socketDescriptor,
         [protectedThis] {
diff --git a/Source/WebKit2/PlatformGTK.cmake b/Source/WebKit2/PlatformGTK.cmake
index 2201e88..d5f5ec9 100644
--- a/Source/WebKit2/PlatformGTK.cmake
+++ b/Source/WebKit2/PlatformGTK.cmake
@@ -35,6 +35,7 @@
     NetworkProcess/soup/NetworkProcessSoup.cpp
     NetworkProcess/soup/RemoteNetworkingContextSoup.cpp
 
+    Platform/IPC/glib/GSocketMonitor.cpp
     Platform/IPC/unix/AttachmentUnix.cpp
     Platform/IPC/unix/ConnectionUnix.cpp
 
@@ -492,6 +493,7 @@
     "${WEBKIT2_DIR}/DatabaseProcess/unix"
     "${WEBKIT2_DIR}/NetworkProcess/gtk"
     "${WEBKIT2_DIR}/NetworkProcess/unix"
+    "${WEBKIT2_DIR}/Platform/IPC/glib"
     "${WEBKIT2_DIR}/Shared/API/c/gtk"
     "${WEBKIT2_DIR}/Shared/Network/CustomProtocols/soup"
     "${WEBKIT2_DIR}/Shared/Downloads/soup"
@@ -710,6 +712,7 @@
         Platform/IPC/MessageSender.cpp
         Platform/IPC/StringReference.cpp
 
+        Platform/IPC/glib/GSocketMonitor.cpp
         Platform/IPC/unix/AttachmentUnix.cpp
         Platform/IPC/unix/ConnectionUnix.cpp
 
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
index 5dec26a..1194a97 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
@@ -65,6 +65,7 @@
 #include <glib/gi18n-lib.h>
 #include <memory>
 #include <wtf/HashMap.h>
+#include <wtf/glib/GMainLoopSource.h>
 #include <wtf/glib/GRefPtr.h>
 #include <wtf/text/CString.h>