<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160162] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160162">160162</a></dd>
<dt>Author</dt> <dd>zandobersek@gmail.com</dd>
<dt>Date</dt> <dd>2013-12-05 00:47:45 -0800 (Thu, 05 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK][WK2] Clean up WorkQueueGtk
https://bugs.webkit.org/show_bug.cgi?id=125177
Reviewed by Carlos Garcia Campos.
Clean up the GTK implementation of the WorkQueue class a bit.
- registerSocketEventHandler doesn't take a condition argument anymore -- G_IO_IN was the only condition ever passed into
that method so that is now the hard-coded default.
- Clean up the declarations of GTK-specific bits in the WorkQueue header file. SocketEventSourceIterator typedef is removed
and auto will be used instead.
- WorkQueue::dispatchOnTermination and WorkQueue::SocketEventSource::performWorkOnTermination methods were unused and now removed.
- WorkQueue::SocketEventSource doesn't expect a GIO condition anymore, and WorkQueue::SocketEventSource::checkCondition is removed.
G_IO_IN condition was the only one used is now hard-coded into the check in WorkQueue::SocketEventSource::eventCallback.
- Removed an unnecessary non-null assertion for the heap-allocated SocketEventSource.
- Removed a technically duplicated assertion that a file descriptor is already present in the event sources map. Moved the
assertion before the HashMap::find() call.
- Removed two unnecessary assertions that non-null values are being returned by g_idle_source_new() and g_timeout_source_new().
Both functions are guaranteed to return non-null values.
* Platform/CoreIPC/unix/ConnectionUnix.cpp:
(CoreIPC::Connection::open):
* Platform/WorkQueue.h:
* Platform/gtk/WorkQueueGtk.cpp:
(WorkQueue::SocketEventSource::SocketEventSource):
(WorkQueue::SocketEventSource::eventCallback):
(WorkQueue::registerSocketEventHandler):
(WorkQueue::unregisterSocketEventHandler):
(WorkQueue::dispatch):
(WorkQueue::dispatchAfterDelay):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformCoreIPCunixConnectionUnixcpp">trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp</a></li>
<li><a href="#trunkSourceWebKit2PlatformWorkQueueh">trunk/Source/WebKit2/Platform/WorkQueue.h</a></li>
<li><a href="#trunkSourceWebKit2PlatformgtkWorkQueueGtkcpp">trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (160161 => 160162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2013-12-05 07:41:26 UTC (rev 160161)
+++ trunk/Source/WebKit2/ChangeLog        2013-12-05 08:47:45 UTC (rev 160162)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2013-12-05 Zan Dobersek <zdobersek@igalia.com>
+
+ [GTK][WK2] Clean up WorkQueueGtk
+ https://bugs.webkit.org/show_bug.cgi?id=125177
+
+ Reviewed by Carlos Garcia Campos.
+
+ Clean up the GTK implementation of the WorkQueue class a bit.
+ - registerSocketEventHandler doesn't take a condition argument anymore -- G_IO_IN was the only condition ever passed into
+ that method so that is now the hard-coded default.
+ - Clean up the declarations of GTK-specific bits in the WorkQueue header file. SocketEventSourceIterator typedef is removed
+ and auto will be used instead.
+ - WorkQueue::dispatchOnTermination and WorkQueue::SocketEventSource::performWorkOnTermination methods were unused and now removed.
+ - WorkQueue::SocketEventSource doesn't expect a GIO condition anymore, and WorkQueue::SocketEventSource::checkCondition is removed.
+ G_IO_IN condition was the only one used is now hard-coded into the check in WorkQueue::SocketEventSource::eventCallback.
+ - Removed an unnecessary non-null assertion for the heap-allocated SocketEventSource.
+ - Removed a technically duplicated assertion that a file descriptor is already present in the event sources map. Moved the
+ assertion before the HashMap::find() call.
+ - Removed two unnecessary assertions that non-null values are being returned by g_idle_source_new() and g_timeout_source_new().
+ Both functions are guaranteed to return non-null values.
+
+ * Platform/CoreIPC/unix/ConnectionUnix.cpp:
+ (CoreIPC::Connection::open):
+ * Platform/WorkQueue.h:
+ * Platform/gtk/WorkQueueGtk.cpp:
+ (WorkQueue::SocketEventSource::SocketEventSource):
+ (WorkQueue::SocketEventSource::eventCallback):
+ (WorkQueue::registerSocketEventHandler):
+ (WorkQueue::unregisterSocketEventHandler):
+ (WorkQueue::dispatch):
+ (WorkQueue::dispatchAfterDelay):
+
</ins><span class="cx"> 2013-12-04 Gergo Balogh <geryxyz@inf.u-szeged.hu>
</span><span class="cx">
</span><span class="cx"> Report error when #else is used in message receiver generator's input.
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformCoreIPCunixConnectionUnixcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp (160161 => 160162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp        2013-12-05 07:41:26 UTC (rev 160161)
+++ trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp        2013-12-05 08:47:45 UTC (rev 160162)
</span><span class="lines">@@ -378,7 +378,7 @@
</span><span class="cx">
</span><span class="cx"> m_isConnected = true;
</span><span class="cx"> #if PLATFORM(GTK)
</span><del>- m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, G_IO_IN, WTF::bind(&Connection::readyReadHandler, this), WTF::bind(&Connection::connectionDidClose, this));
</del><ins>+ m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this), WTF::bind(&Connection::connectionDidClose, this));
</ins><span class="cx"> #elif PLATFORM(EFL)
</span><span class="cx"> m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this));
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformWorkQueueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/WorkQueue.h (160161 => 160162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/WorkQueue.h        2013-12-05 07:41:26 UTC (rev 160161)
+++ trunk/Source/WebKit2/Platform/WorkQueue.h        2013-12-05 08:47:45 UTC (rev 160162)
</span><span class="lines">@@ -64,9 +64,8 @@
</span><span class="cx"> #if OS(DARWIN)
</span><span class="cx"> dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; }
</span><span class="cx"> #elif PLATFORM(GTK)
</span><del>- void registerSocketEventHandler(int, int, const Function<void()>& function, const Function<void()>& closeFunction);
</del><ins>+ void registerSocketEventHandler(int, const Function<void()>&, const Function<void()>&);
</ins><span class="cx"> void unregisterSocketEventHandler(int);
</span><del>- void dispatchOnTermination(WebKit::PlatformProcessIdentifier, const Function<void()>&);
</del><span class="cx"> #elif PLATFORM(EFL)
</span><span class="cx"> void registerSocketEventHandler(int, const Function<void()>&);
</span><span class="cx"> void unregisterSocketEventHandler(int);
</span><span class="lines">@@ -82,6 +81,9 @@
</span><span class="cx"> static void executeFunction(void*);
</span><span class="cx"> dispatch_queue_t m_dispatchQueue;
</span><span class="cx"> #elif PLATFORM(GTK)
</span><ins>+ class EventSource;
+ class SocketEventSource;
+
</ins><span class="cx"> static void startWorkQueueThread(WorkQueue*);
</span><span class="cx"> void workQueueThreadBody();
</span><span class="cx"> void dispatchOnSource(GSource*, const Function<void()>&, GSourceFunc);
</span><span class="lines">@@ -91,10 +93,7 @@
</span><span class="cx"> Mutex m_eventLoopLock;
</span><span class="cx"> GRefPtr<GMainLoop> m_eventLoop;
</span><span class="cx"> Mutex m_eventSourcesLock;
</span><del>- class EventSource;
- class SocketEventSource;
</del><span class="cx"> HashMap<int, Vector<SocketEventSource*>> m_eventSources;
</span><del>- typedef HashMap<int, Vector<SocketEventSource*>>::iterator SocketEventSourceIterator;
</del><span class="cx"> #elif PLATFORM(EFL)
</span><span class="cx"> RefPtr<DispatchQueue> m_dispatchQueue;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformgtkWorkQueueGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp (160161 => 160162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp        2013-12-05 07:41:26 UTC (rev 160161)
+++ trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp        2013-12-05 08:47:45 UTC (rev 160162)
</span><span class="lines">@@ -56,13 +56,6 @@
</span><span class="cx"> return FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- static gboolean performWorkOnTermination(GPid, gint, EventSource* eventSource)
- {
- ASSERT(eventSource);
- eventSource->performWork();
- return FALSE;
- }
-
</del><span class="cx"> static void deleteEventSource(EventSource* eventSource)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(eventSource);
</span><span class="lines">@@ -76,9 +69,8 @@
</span><span class="cx">
</span><span class="cx"> class WorkQueue::SocketEventSource : public WorkQueue::EventSource {
</span><span class="cx"> public:
</span><del>- SocketEventSource(const Function<void()>& function, WorkQueue* workQueue, int condition, GCancellable* cancellable, const Function<void()>& closeFunction)
</del><ins>+ SocketEventSource(const Function<void()>& function, WorkQueue* workQueue, GCancellable* cancellable, const Function<void()>& closeFunction)
</ins><span class="cx"> : EventSource(function, workQueue)
</span><del>- , m_condition(condition)
</del><span class="cx"> , m_cancellable(cancellable)
</span><span class="cx"> , m_closeFunction(closeFunction)
</span><span class="cx"> {
</span><span class="lines">@@ -95,13 +87,8 @@
</span><span class="cx"> m_closeFunction();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- bool checkCondition(GIOCondition condition) const
</del><ins>+ static gboolean eventCallback(GSocket* socket, GIOCondition condition, SocketEventSource* eventSource)
</ins><span class="cx"> {
</span><del>- return condition & m_condition;
- }
-
- static gboolean eventCallback(GSocket*, GIOCondition condition, SocketEventSource* eventSource)
- {
</del><span class="cx"> ASSERT(eventSource);
</span><span class="cx">
</span><span class="cx"> if (condition & G_IO_HUP || condition & G_IO_ERR) {
</span><span class="lines">@@ -109,7 +96,7 @@
</span><span class="cx"> return FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (eventSource->checkCondition(condition)) {
</del><ins>+ if (condition & G_IO_IN) {
</ins><span class="cx"> eventSource->performWork();
</span><span class="cx"> return TRUE;
</span><span class="cx"> }
</span><span class="lines">@@ -119,7 +106,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- int m_condition;
</del><span class="cx"> GCancellable* m_cancellable;
</span><span class="cx"> Function<void()> m_closeFunction;
</span><span class="cx"> };
</span><span class="lines">@@ -173,15 +159,14 @@
</span><span class="cx"> g_main_loop_run(m_eventLoop.get());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WorkQueue::registerSocketEventHandler(int fileDescriptor, int condition, const Function<void()>& function, const Function<void()>& closeFunction)
</del><ins>+void WorkQueue::registerSocketEventHandler(int fileDescriptor, const Function<void()>& function, const Function<void()>& closeFunction)
</ins><span class="cx"> {
</span><span class="cx"> GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(fileDescriptor, 0));
</span><span class="cx"> ASSERT(socket);
</span><span class="cx"> GRefPtr<GCancellable> cancellable = adoptGRef(g_cancellable_new());
</span><del>- GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), static_cast<GIOCondition>(condition), cancellable.get()));
</del><ins>+ GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), G_IO_IN, cancellable.get()));
</ins><span class="cx"> ASSERT(dispatchSource);
</span><del>- SocketEventSource* eventSource = new SocketEventSource(function, this, condition, cancellable.get(), closeFunction);
- ASSERT(eventSource);
</del><ins>+ SocketEventSource* eventSource = new SocketEventSource(function, this, cancellable.get(), closeFunction);
</ins><span class="cx">
</span><span class="cx"> g_source_set_callback(dispatchSource.get(), reinterpret_cast<GSourceFunc>(&WorkQueue::SocketEventSource::eventCallback),
</span><span class="cx"> eventSource, reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource));
</span><span class="lines">@@ -190,7 +175,7 @@
</span><span class="cx"> {
</span><span class="cx"> MutexLocker locker(m_eventSourcesLock);
</span><span class="cx"> Vector<SocketEventSource*> sources;
</span><del>- SocketEventSourceIterator it = m_eventSources.find(fileDescriptor);
</del><ins>+ auto it = m_eventSources.find(fileDescriptor);
</ins><span class="cx"> if (it != m_eventSources.end())
</span><span class="cx"> sources = it->value;
</span><span class="cx">
</span><span class="lines">@@ -207,9 +192,8 @@
</span><span class="cx">
</span><span class="cx"> MutexLocker locker(m_eventSourcesLock);
</span><span class="cx">
</span><del>- SocketEventSourceIterator it = m_eventSources.find(fileDescriptor);
- ASSERT(it != m_eventSources.end());
</del><span class="cx"> ASSERT(m_eventSources.contains(fileDescriptor));
</span><ins>+ auto it = m_eventSources.find(fileDescriptor);
</ins><span class="cx">
</span><span class="cx"> if (it != m_eventSources.end()) {
</span><span class="cx"> Vector<SocketEventSource*> sources = it->value;
</span><span class="lines">@@ -231,24 +215,12 @@
</span><span class="cx"> void WorkQueue::dispatch(const Function<void()>& function)
</span><span class="cx"> {
</span><span class="cx"> GRefPtr<GSource> dispatchSource = adoptGRef(g_idle_source_new());
</span><del>- ASSERT(dispatchSource);
</del><span class="cx"> g_source_set_priority(dispatchSource.get(), G_PRIORITY_DEFAULT);
</span><del>-
</del><span class="cx"> dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WorkQueue::dispatchAfterDelay(const Function<void()>& function, double delay)
</span><span class="cx"> {
</span><span class="cx"> GRefPtr<GSource> dispatchSource = adoptGRef(g_timeout_source_new(static_cast<guint>(delay * 1000)));
</span><del>- ASSERT(dispatchSource);
-
</del><span class="cx"> dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
</span><span class="cx"> }
</span><del>-
-void WorkQueue::dispatchOnTermination(WebKit::PlatformProcessIdentifier process, const Function<void()>& function)
-{
- GRefPtr<GSource> dispatchSource = adoptGRef(g_child_watch_source_new(process));
- ASSERT(dispatchSource);
-
- dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnTermination));
-}
</del></span></pre>
</div>
</div>
</body>
</html>