- Revision
- 191788
- Author
- [email protected]
- Date
- 2015-10-30 05:46:55 -0700 (Fri, 30 Oct 2015)
Log Message
[GTK] Move the socket polling off the WorkQueue
https://bugs.webkit.org/show_bug.cgi?id=150593
Reviewed by Anders Carlsson.
Source/WebKit2:
Create the socket poll source in Connection::open and attach it to
the connection work queue context.
* Platform/IPC/Connection.h:
* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::platformInvalidate):
(IPC::Connection::open):
Source/WTF:
It doesn't really belong to the WorkQueue, it's only used by the
WebKit2 connection, so it can be moved there.
* wtf/WorkQueue.h:
* wtf/glib/WorkQueueGLib.cpp:
(WTF::WorkQueue::registerSocketEventHandler): Deleted.
(WTF::WorkQueue::unregisterSocketEventHandler): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (191787 => 191788)
--- trunk/Source/WTF/ChangeLog 2015-10-30 12:12:09 UTC (rev 191787)
+++ trunk/Source/WTF/ChangeLog 2015-10-30 12:46:55 UTC (rev 191788)
@@ -1,3 +1,18 @@
+2015-10-30 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Move the socket polling off the WorkQueue
+ https://bugs.webkit.org/show_bug.cgi?id=150593
+
+ Reviewed by Anders Carlsson.
+
+ It doesn't really belong to the WorkQueue, it's only used by the
+ WebKit2 connection, so it can be moved there.
+
+ * wtf/WorkQueue.h:
+ * wtf/glib/WorkQueueGLib.cpp:
+ (WTF::WorkQueue::registerSocketEventHandler): Deleted.
+ (WTF::WorkQueue::unregisterSocketEventHandler): Deleted.
+
2015-10-29 Carlos Garcia Campos <[email protected]>
[GTK] Use a persistent main loop source in RunLoop glib implementation
Modified: trunk/Source/WTF/wtf/WorkQueue.h (191787 => 191788)
--- trunk/Source/WTF/wtf/WorkQueue.h 2015-10-30 12:12:09 UTC (rev 191787)
+++ trunk/Source/WTF/wtf/WorkQueue.h 2015-10-30 12:46:55 UTC (rev 191788)
@@ -76,8 +76,7 @@
#if OS(DARWIN)
dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; }
#elif PLATFORM(GTK)
- void registerSocketEventHandler(int, std::function<void ()>, std::function<void ()>);
- void unregisterSocketEventHandler(int);
+ GMainContext* mainContext() const { return m_eventContext.get(); }
#elif PLATFORM(EFL)
void registerSocketEventHandler(int, std::function<void ()>);
void unregisterSocketEventHandler(int);
@@ -109,7 +108,6 @@
ThreadIdentifier m_workQueueThread;
GRefPtr<GMainContext> m_eventContext;
GRefPtr<GMainLoop> m_eventLoop;
- GMainLoopSource m_socketEventSource;
#elif PLATFORM(EFL)
RefPtr<DispatchQueue> m_dispatchQueue;
#elif OS(WINDOWS)
Modified: trunk/Source/WTF/wtf/glib/WorkQueueGLib.cpp (191787 => 191788)
--- trunk/Source/WTF/wtf/glib/WorkQueueGLib.cpp 2015-10-30 12:12:09 UTC (rev 191787)
+++ trunk/Source/WTF/wtf/glib/WorkQueueGLib.cpp 2015-10-30 12:46:55 UTC (rev 191788)
@@ -28,7 +28,7 @@
#include "config.h"
#include "WorkQueue.h"
-#include <gio/gio.h>
+#include <glib.h>
#include <string.h>
namespace WTF {
@@ -84,33 +84,6 @@
m_eventContext = nullptr;
}
-void WorkQueue::registerSocketEventHandler(int fileDescriptor, std::function<void ()> function, std::function<void ()> closeFunction)
-{
- GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(fileDescriptor, 0));
- ref();
- m_socketEventSource.schedule("[WebKit] WorkQueue::SocketEventHandler", [function, closeFunction](GIOCondition condition) {
- if (condition & G_IO_HUP || condition & G_IO_ERR || condition & G_IO_NVAL) {
- closeFunction();
- return GMainLoopSource::Stop;
- }
-
- if (condition & G_IO_IN) {
- function();
- return GMainLoopSource::Continue;
- }
-
- ASSERT_NOT_REACHED();
- return GMainLoopSource::Stop;
- }, socket.get(), G_IO_IN,
- [this] { deref(); },
- m_eventContext.get());
-}
-
-void WorkQueue::unregisterSocketEventHandler(int)
-{
- m_socketEventSource.cancel();
-}
-
void WorkQueue::dispatch(std::function<void ()> function)
{
ref();
Modified: trunk/Source/WebKit2/ChangeLog (191787 => 191788)
--- trunk/Source/WebKit2/ChangeLog 2015-10-30 12:12:09 UTC (rev 191787)
+++ trunk/Source/WebKit2/ChangeLog 2015-10-30 12:46:55 UTC (rev 191788)
@@ -1,5 +1,20 @@
2015-10-30 Carlos Garcia Campos <[email protected]>
+ [GTK] Move the socket polling off the WorkQueue
+ https://bugs.webkit.org/show_bug.cgi?id=150593
+
+ Reviewed by Anders Carlsson.
+
+ Create the socket poll source in Connection::open and attach it to
+ the connection work queue context.
+
+ * Platform/IPC/Connection.h:
+ * Platform/IPC/unix/ConnectionUnix.cpp:
+ (IPC::Connection::platformInvalidate):
+ (IPC::Connection::open):
+
+2015-10-30 Carlos Garcia Campos <[email protected]>
+
[GTK] Use RunLoop::Timer instead of GMainLoopSource
https://bugs.webkit.org/show_bug.cgi?id=150592
Modified: trunk/Source/WebKit2/Platform/IPC/Connection.h (191787 => 191788)
--- trunk/Source/WebKit2/Platform/IPC/Connection.h 2015-10-30 12:12:09 UTC (rev 191787)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.h 2015-10-30 12:46:55 UTC (rev 191788)
@@ -52,6 +52,10 @@
#include "PlatformProcessIdentifier.h"
#endif
+#if PLATFORM(GTK)
+#include <wtf/glib/GMainLoopSource.h>
+#endif
+
namespace IPC {
struct WaitForMessageState;
@@ -354,7 +358,10 @@
Vector<int> m_fileDescriptors;
size_t m_fileDescriptorsSize;
int m_socketDescriptor;
+#if PLATFORM(GTK)
+ GMainLoopSource m_socketEventSource;
#endif
+#endif
};
template<typename T> bool Connection::send(T&& message, uint64_t destinationID, unsigned messageSendFlags)
Modified: trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp (191787 => 191788)
--- trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp 2015-10-30 12:12:09 UTC (rev 191787)
+++ trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp 2015-10-30 12:46:55 UTC (rev 191788)
@@ -40,7 +40,7 @@
#include <wtf/UniStdExtras.h>
#if PLATFORM(GTK)
-#include <glib.h>
+#include <gio/gio.h>
#endif
#ifdef SOCK_SEQPACKET
@@ -147,7 +147,9 @@
if (!m_isConnected)
return;
-#if PLATFORM(GTK) || PLATFORM(EFL)
+#if PLATFORM(GTK)
+ m_socketEventSource.cancel();
+#elif PLATFORM(EFL)
m_connectionQueue->unregisterSocketEventHandler(m_socketDescriptor);
#endif
@@ -374,13 +376,21 @@
RefPtr<Connection> protectedThis(this);
m_isConnected = true;
#if PLATFORM(GTK)
- m_connectionQueue->registerSocketEventHandler(m_socketDescriptor,
- [protectedThis] {
+ GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(m_socketDescriptor, nullptr));
+ m_socketEventSource.schedule("[WebKit] Connection::SocketEventHandler", [protectedThis] (GIOCondition condition) {
+ if (condition & G_IO_HUP || condition & G_IO_ERR || condition & G_IO_NVAL) {
+ protectedThis->connectionDidClose();
+ return GMainLoopSource::Stop;
+ }
+
+ if (condition & G_IO_IN) {
protectedThis->readyReadHandler();
- },
- [protectedThis] {
- protectedThis->connectionDidClose();
- });
+ return GMainLoopSource::Continue;
+ }
+
+ ASSERT_NOT_REACHED();
+ return GMainLoopSource::Stop;
+ }, socket.get(), G_IO_IN, nullptr, m_connectionQueue->mainContext());
#elif PLATFORM(EFL)
m_connectionQueue->registerSocketEventHandler(m_socketDescriptor,
[protectedThis] {