<!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>[192782] trunk</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/192782">192782</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-11-27 08:54:45 -0800 (Fri, 27 Nov 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Remove the remaining uses of GMainLoopSource
https://bugs.webkit.org/show_bug.cgi?id=151632
Reviewed by Žan Doberšek.
Source/WebKit2:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(_WebKitWebViewBasePrivate::_WebKitWebViewBasePrivate):
(_WebKitWebViewBasePrivate::clearRedirectedWindowSoonTimerFired):
(webkitWebViewBaseClearRedirectedWindowSoon):
(webkitWebViewBaseEnterAcceleratedCompositingMode):
Tools:
* TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp:
(testWebViewSyncRequestOnMaxConns):
* TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::TestRunner):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp:
(WTR::TestRunner::invalidateWaitToDumpWatchdogTimer):
(WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
* WebKitTestRunner/gtk/TestControllerGtk.cpp:
(WTR::timeoutSource):
(WTR::TestController::notifyDone):
(WTR::TestController::platformRunUntil):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestResourcescpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTestcpp">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundlegtkTestRunnerGtkcpp">trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnergtkTestControllerGtkcpp">trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (192781 => 192782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-11-27 14:16:31 UTC (rev 192781)
+++ trunk/Source/WebKit2/ChangeLog        2015-11-27 16:54:45 UTC (rev 192782)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-11-27 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Remove the remaining uses of GMainLoopSource
+ https://bugs.webkit.org/show_bug.cgi?id=151632
+
+ Reviewed by Žan Doberšek.
+
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (_WebKitWebViewBasePrivate::_WebKitWebViewBasePrivate):
+ (_WebKitWebViewBasePrivate::clearRedirectedWindowSoonTimerFired):
+ (webkitWebViewBaseClearRedirectedWindowSoon):
+ (webkitWebViewBaseEnterAcceleratedCompositingMode):
+
</ins><span class="cx"> 2015-11-23 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] Use the network process unconditionally
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (192781 => 192782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2015-11-27 14:16:31 UTC (rev 192781)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2015-11-27 16:54:45 UTC (rev 192782)
</span><span class="lines">@@ -65,7 +65,6 @@
</span><span class="cx"> #include <glib/gi18n-lib.h>
</span><span class="cx"> #include <memory>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><del>-#include <wtf/glib/GMainLoopSource.h>
</del><span class="cx"> #include <wtf/glib/GRefPtr.h>
</span><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx">
</span><span class="lines">@@ -149,6 +148,19 @@
</span><span class="cx"> typedef HashMap<uint32_t, GUniquePtr<GdkEvent>> TouchEventsMap;
</span><span class="cx">
</span><span class="cx"> struct _WebKitWebViewBasePrivate {
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ _WebKitWebViewBasePrivate()
+ : clearRedirectedWindowSoonTimer(RunLoop::main(), this, &_WebKitWebViewBasePrivate::clearRedirectedWindowSoonTimerFired)
+ {
+ }
+
+ void clearRedirectedWindowSoonTimerFired()
+ {
+ if (redirectedWindow)
+ redirectedWindow->resize(IntSize());
+ }
+#endif
+
</ins><span class="cx"> WebKitWebViewChildrenMap children;
</span><span class="cx"> std::unique_ptr<PageClientImpl> pageClient;
</span><span class="cx"> RefPtr<WebPageProxy> pageProxy;
</span><span class="lines">@@ -190,7 +202,7 @@
</span><span class="cx">
</span><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><span class="cx"> std::unique_ptr<RedirectedXCompositeWindow> redirectedWindow;
</span><del>- GMainLoopSource clearRedirectedWindowSoon;
</del><ins>+ RunLoop::Timer<WebKitWebViewBasePrivate> clearRedirectedWindowSoonTimer;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="lines">@@ -1358,12 +1370,8 @@
</span><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><span class="cx"> static void webkitWebViewBaseClearRedirectedWindowSoon(WebKitWebViewBase* webkitWebViewBase)
</span><span class="cx"> {
</span><del>- WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
- static const std::chrono::seconds clearRedirectedWindowSoonDelay = 2_s;
- priv->clearRedirectedWindowSoon.scheduleAfterDelay("[WebKit] Clear RedirectedWindow soon", [priv]() {
- if (priv->redirectedWindow)
- priv->redirectedWindow->resize(IntSize());
- }, clearRedirectedWindowSoonDelay);
</del><ins>+ static const double clearRedirectedWindowSoonDelay = 2;
+ webkitWebViewBase->priv->clearRedirectedWindowSoonTimer.startOneShot(clearRedirectedWindowSoonDelay);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -1390,7 +1398,7 @@
</span><span class="cx"> void webkitWebViewBaseEnterAcceleratedCompositingMode(WebKitWebViewBase* webkitWebViewBase)
</span><span class="cx"> {
</span><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><del>- webkitWebViewBase->priv->clearRedirectedWindowSoon.cancel();
</del><ins>+ webkitWebViewBase->priv->clearRedirectedWindowSoonTimer.stop();
</ins><span class="cx"> #else
</span><span class="cx"> UNUSED_PARAM(webkitWebViewBase);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (192781 => 192782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-11-27 14:16:31 UTC (rev 192781)
+++ trunk/Tools/ChangeLog        2015-11-27 16:54:45 UTC (rev 192782)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-11-27 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Remove the remaining uses of GMainLoopSource
+ https://bugs.webkit.org/show_bug.cgi?id=151632
+
+ Reviewed by Žan Doberšek.
+
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp:
+ (testWebViewSyncRequestOnMaxConns):
+ * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::TestRunner):
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp:
+ (WTR::TestRunner::invalidateWaitToDumpWatchdogTimer):
+ (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
+ * WebKitTestRunner/gtk/TestControllerGtk.cpp:
+ (WTR::timeoutSource):
+ (WTR::TestController::notifyDone):
+ (WTR::TestController::platformRunUntil):
+
</ins><span class="cx"> 2015-11-27 Csaba Osztrogonác <ossy@webkit.org>
</span><span class="cx">
</span><span class="cx"> [cmake] Add testb3 to the build system
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestResourcescpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp (192781 => 192782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp        2015-11-27 14:16:31 UTC (rev 192781)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp        2015-11-27 16:54:45 UTC (rev 192782)
</span><span class="lines">@@ -22,7 +22,6 @@
</span><span class="cx"> #include "WebKitTestServer.h"
</span><span class="cx"> #include "WebViewTest.h"
</span><span class="cx"> #include <wtf/Vector.h>
</span><del>-#include <wtf/glib/GMainLoopSource.h>
</del><span class="cx"> #include <wtf/glib/GMutexLocker.h>
</span><span class="cx"> #include <wtf/glib/GRefPtr.h>
</span><span class="cx">
</span><span class="lines">@@ -706,12 +705,27 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // By default sync XHRs have a 10 seconds timeout, we don't want to wait all that so use our own timeout.
</span><del>- GMainLoopSource timeoutSource;
- timeoutSource.scheduleAfterDelay("Timeout", [] { g_assert_not_reached(); }, std::chrono::seconds(1));
</del><ins>+ guint timeoutSourceID = g_timeout_add(1000, [] (gpointer) -> gboolean {
+ g_assert_not_reached();
+ return G_SOURCE_REMOVE;
+ }, nullptr);
</ins><span class="cx">
</span><del>- GMainLoopSource unlockServerSource;
- unlockServerSource.schedule("Unlock Server Idle", [&lock] { lock.unlock(); });
</del><ins>+ struct UnlockServerSourceContext {
+ WTF::GMutexLocker<GMutex>& lock;
+ guint unlockServerSourceID;
+ } context = {
+ lock,
+ g_idle_add_full(G_PRIORITY_DEFAULT, [](gpointer userData) -> gboolean {
+ auto& context = *static_cast<UnlockServerSourceContext*>(userData);
+ context.unlockServerSourceID = 0;
+ context.lock.unlock();
+ return G_SOURCE_REMOVE;
+ }, &context, nullptr)
+ };
</ins><span class="cx"> test->waitUntilResourcesLoaded(s_maxConnectionsPerHost + 3); // s_maxConnectionsPerHost resource + main resource + 2 XHR.
</span><ins>+ g_source_remove(timeoutSourceID);
+ if (context.unlockServerSourceID)
+ g_source_remove(context.unlockServerSourceID);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void addCacheHTTPHeadersToResponse(SoupMessage* message)
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp (192781 => 192782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp        2015-11-27 14:16:31 UTC (rev 192781)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp        2015-11-27 16:54:45 UTC (rev 192782)
</span><span class="lines">@@ -23,7 +23,6 @@
</span><span class="cx">
</span><span class="cx"> #include <JavaScriptCore/JSRetainPtr.h>
</span><span class="cx"> #include <WebCore/GUniquePtrGtk.h>
</span><del>-#include <wtf/glib/GMainLoopSource.h>
</del><span class="cx">
</span><span class="cx"> WebViewTest::WebViewTest(WebKitUserContentManager* userContentManager)
</span><span class="cx"> : m_webView(WEBKIT_WEB_VIEW(g_object_ref_sink(g_object_new(WEBKIT_TYPE_WEB_VIEW, "web-context", m_webContext.get(), "user-content-manager", userContentManager, nullptr))))
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (192781 => 192782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp        2015-11-27 14:16:31 UTC (rev 192781)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp        2015-11-27 16:54:45 UTC (rev 192782)
</span><span class="lines">@@ -96,6 +96,9 @@
</span><span class="cx"> , m_databaseMaxQuota(-1)
</span><span class="cx"> , m_userStyleSheetEnabled(false)
</span><span class="cx"> , m_userStyleSheetLocation(adoptWK(WKStringCreateWithUTF8CString("")))
</span><ins>+#if PLATFORM(GTK)
+ , m_waitToDumpWatchdogTimer(RunLoop::main(), this, &TestRunner::waitToDumpWatchdogTimerFired)
+#endif
</ins><span class="cx"> {
</span><span class="cx"> platformInitialize();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (192781 => 192782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h        2015-11-27 14:16:31 UTC (rev 192781)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h        2015-11-27 16:54:45 UTC (rev 192782)
</span><span class="lines">@@ -38,8 +38,11 @@
</span><span class="cx"> #include <CoreFoundation/CFRunLoop.h>
</span><span class="cx"> typedef RetainPtr<CFRunLoopTimerRef> PlatformTimerRef;
</span><span class="cx"> #elif PLATFORM(GTK)
</span><del>-#include <wtf/glib/GMainLoopSource.h>
-typedef GMainLoopSource PlatformTimerRef;
</del><ins>+#include <wtf/RunLoop.h>
+namespace WTR {
+class TestRunner;
+typedef RunLoop::Timer<TestRunner> PlatformTimerRef;
+}
</ins><span class="cx"> #elif PLATFORM(EFL)
</span><span class="cx"> typedef Ecore_Timer* PlatformTimerRef;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundlegtkTestRunnerGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp (192781 => 192782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp        2015-11-27 14:16:31 UTC (rev 192781)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp        2015-11-27 16:54:45 UTC (rev 192782)
</span><span class="lines">@@ -40,16 +40,15 @@
</span><span class="cx">
</span><span class="cx"> void TestRunner::invalidateWaitToDumpWatchdogTimer()
</span><span class="cx"> {
</span><del>- m_waitToDumpWatchdogTimer.cancel();
</del><ins>+ m_waitToDumpWatchdogTimer.stop();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()
</span><span class="cx"> {
</span><del>- if (m_waitToDumpWatchdogTimer.isScheduled())
</del><ins>+ if (m_waitToDumpWatchdogTimer.isActive())
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- m_waitToDumpWatchdogTimer.scheduleAfterDelay("[WTR] waitToDumpWatchdogTimerCallback", [this] { waitToDumpWatchdogTimerFired(); },
- std::chrono::milliseconds(m_timeout));
</del><ins>+ m_waitToDumpWatchdogTimer.startOneShot(m_timeout / 1000.0);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef url)
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnergtkTestControllerGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp (192781 => 192782)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp        2015-11-27 14:16:31 UTC (rev 192781)
+++ trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp        2015-11-27 16:54:45 UTC (rev 192782)
</span><span class="lines">@@ -31,17 +31,33 @@
</span><span class="cx"> #include <gtk/gtk.h>
</span><span class="cx"> #include <wtf/Platform.h>
</span><span class="cx"> #include <wtf/RunLoop.h>
</span><del>-#include <wtf/glib/GMainLoopSource.h>
</del><ins>+#include <wtf/glib/GRefPtr.h>
</ins><span class="cx"> #include <wtf/glib/GUniquePtr.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span><span class="cx"> namespace WTR {
</span><span class="cx">
</span><del>-static GMainLoopSource timeoutSource;
</del><ins>+static GSource* timeoutSource()
+{
+ static GRefPtr<GSource> source = nullptr;
+ if (!source) {
+ source = adoptGRef(g_timeout_source_new(0));
+ g_source_set_ready_time(source.get(), -1);
+ g_source_set_name(source.get(), "[WTR] Test timeout source");
+ g_source_set_callback(source.get(), [](gpointer userData) -> gboolean {
+ g_source_set_ready_time(static_cast<GSource*>(userData), -1);
+ fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n");
+ RunLoop::main().stop();
+ return G_SOURCE_CONTINUE;
+ }, source.get(), nullptr);
+ g_source_attach(source.get(), nullptr);
+ }
+ return source.get();
+}
</ins><span class="cx">
</span><span class="cx"> void TestController::notifyDone()
</span><span class="cx"> {
</span><del>- timeoutSource.cancel();
</del><ins>+ g_source_set_ready_time(timeoutSource(), -1);
</ins><span class="cx"> RunLoop::main().stop();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -61,12 +77,17 @@
</span><span class="cx"> void TestController::platformRunUntil(bool&, double timeout)
</span><span class="cx"> {
</span><span class="cx"> if (timeout > 0) {
</span><del>- timeoutSource.scheduleAfterDelay("[WTR] Test timeout source", [] {
- fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n");
- RunLoop::main().stop();
- }, std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(timeout)));
</del><ins>+ // FIXME: This conversion is now repeated in several places, it should be moved to a common place in WTF and used everywhere.
+ auto timeoutDuration = std::chrono::duration<double>(timeout);
+ auto safeDuration = std::chrono::microseconds::max();
+ if (timeoutDuration < safeDuration)
+ safeDuration = std::chrono::duration_cast<std::chrono::microseconds>(timeoutDuration);
+ gint64 currentTime = g_get_monotonic_time();
+ gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, safeDuration.count());
+ ASSERT(targetTime >= currentTime);
+ g_source_set_ready_time(timeoutSource(), targetTime);
</ins><span class="cx"> } else
</span><del>- timeoutSource.cancel();
</del><ins>+ g_source_set_ready_time(timeoutSource(), -1);
</ins><span class="cx"> RunLoop::main().run();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>