Title: [192791] trunk
Revision
192791
Author
[email protected]
Date
2015-11-30 00:05:51 -0800 (Mon, 30 Nov 2015)

Log Message

[GLIB] Remove GMainLoopSource and GThreadSafeMainLoopSource
https://bugs.webkit.org/show_bug.cgi?id=151633

Reviewed by Csaba Osztrogonác.

Source/WTF:

* WTF.vcxproj/WTF.vcxproj:
* WTF.vcxproj/WTF.vcxproj.filters:
* wtf/PlatformEfl.cmake:
* wtf/PlatformGTK.cmake:
* wtf/glib/GMainLoopSource.cpp: Removed.
* wtf/glib/GMainLoopSource.h: Removed.
* wtf/glib/GThreadSafeMainLoopSource.cpp: Removed.
* wtf/glib/GThreadSafeMainLoopSource.h: Removed.

Tools:

* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/Tests/WTF/glib/GMainLoopSource.cpp: Removed.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (192790 => 192791)


--- trunk/Source/WTF/ChangeLog	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Source/WTF/ChangeLog	2015-11-30 08:05:51 UTC (rev 192791)
@@ -1,3 +1,19 @@
+2015-11-30  Carlos Garcia Campos  <[email protected]>
+
+        [GLIB] Remove GMainLoopSource and GThreadSafeMainLoopSource
+        https://bugs.webkit.org/show_bug.cgi?id=151633
+
+        Reviewed by Csaba Osztrogonác.
+
+        * WTF.vcxproj/WTF.vcxproj:
+        * WTF.vcxproj/WTF.vcxproj.filters:
+        * wtf/PlatformEfl.cmake:
+        * wtf/PlatformGTK.cmake:
+        * wtf/glib/GMainLoopSource.cpp: Removed.
+        * wtf/glib/GMainLoopSource.h: Removed.
+        * wtf/glib/GThreadSafeMainLoopSource.cpp: Removed.
+        * wtf/glib/GThreadSafeMainLoopSource.h: Removed.
+
 2015-11-27  Csaba Osztrogonác  <[email protected]>
 
         Fix build warning in bignum.cc

Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj (192790 => 192791)


--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj	2015-11-30 08:05:51 UTC (rev 192791)
@@ -83,16 +83,6 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
-    <ClCompile Include="..\wtf\glib\GMainLoopSource.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
-    </ClCompile>
     <ClCompile Include="..\wtf\glib\GRefPtr.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -103,7 +93,6 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
-    <ClCompile Include="..\wtf\glib\GThreadSafeMainLoopSource.cpp" />
     <ClCompile Include="..\wtf\GregorianDateTime.cpp" />
     <ClCompile Include="..\wtf\HashTable.cpp" />
     <ClCompile Include="..\wtf\Lock.cpp" />
@@ -209,11 +198,9 @@
     <ClInclude Include="..\wtf\Functional.h" />
     <ClInclude Include="..\wtf\GetPtr.h" />
     <ClInclude Include="..\wtf\glib\GLibUtilities.h" />
-    <ClInclude Include="..\wtf\glib\GMainLoopSource.h" />
     <ClInclude Include="..\wtf\glib\GMutexLocker.h" />
     <ClInclude Include="..\wtf\glib\GTypedefs.h" />
     <ClInclude Include="..\wtf\glib\GRefPtr.h" />
-    <ClInclude Include="..\wtf\glib\GThreadSafeMainLoopSource.h" />
     <ClInclude Include="..\wtf\glib\GUniquePtr.h" />
     <ClInclude Include="..\wtf\GregorianDateTime.h" />
     <ClInclude Include="..\wtf\HashCountedSet.h" />

Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters (192790 => 192791)


--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters	2015-11-30 08:05:51 UTC (rev 192791)
@@ -240,15 +240,9 @@
     <ClCompile Include="..\wtf\win\RunLoopWin.cpp">
       <Filter>wtf\win</Filter>
     </ClCompile>
-    <ClCompile Include="..\wtf\glib\GMainLoopSource.cpp">
-      <Filter>wtf\glib</Filter>
-    </ClCompile>
     <ClCompile Include="..\wtf\FastBitVector.cpp">
       <Filter>wtf</Filter>
     </ClCompile>
-    <ClCompile Include="..\wtf\glib\GThreadSafeMainLoopSource.cpp">
-      <Filter>wtf\glib</Filter>
-    </ClCompile>
     <ClCompile Include="..\wtf\RefCounter.cpp" />
     <ClCompile Include="..\wtf\win\WTFDLL.cpp">
       <Filter>wtf\win</Filter>
@@ -707,18 +701,12 @@
     <ClInclude Include="..\wtf\RunLoop.h">
       <Filter>wtf</Filter>
     </ClInclude>
-    <ClInclude Include="..\wtf\glib\GMainLoopSource.h">
-      <Filter>wtf\glib</Filter>
-    </ClInclude>
     <ClInclude Include="..\wtf\glib\GUniquePtr.h">
       <Filter>wtf\glib</Filter>
     </ClInclude>
     <ClInclude Include="..\wtf\HashMethod.h">
       <Filter>wtf</Filter>
     </ClInclude>
-    <ClInclude Include="..\wtf\glib\GThreadSafeMainLoopSource.h">
-      <Filter>wtf\glib</Filter>
-    </ClInclude>
     <ClInclude Include="..\wtf\RefCounter.h" />
     <ClInclude Include="..\wtf\WorkQueue.h">
       <Filter>wtf</Filter>

Modified: trunk/Source/WTF/wtf/PlatformEfl.cmake (192790 => 192791)


--- trunk/Source/WTF/wtf/PlatformEfl.cmake	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Source/WTF/wtf/PlatformEfl.cmake	2015-11-30 08:05:51 UTC (rev 192791)
@@ -4,9 +4,7 @@
     efl/RunLoopEfl.cpp
     efl/WorkQueueEfl.cpp
 
-    glib/GMainLoopSource.cpp
     glib/GRefPtr.cpp
-    glib/GThreadSafeMainLoopSource.cpp
 )
 
 list(APPEND WTF_LIBRARIES

Modified: trunk/Source/WTF/wtf/PlatformGTK.cmake (192790 => 192791)


--- trunk/Source/WTF/wtf/PlatformGTK.cmake	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Source/WTF/wtf/PlatformGTK.cmake	2015-11-30 08:05:51 UTC (rev 192791)
@@ -3,9 +3,7 @@
 
 list(APPEND WTF_SOURCES
     glib/GLibUtilities.cpp
-    glib/GMainLoopSource.cpp
     glib/GRefPtr.cpp
-    glib/GThreadSafeMainLoopSource.cpp
     glib/MainThreadGLib.cpp
     glib/RunLoopGLib.cpp
     glib/WorkQueueGLib.cpp

Deleted: trunk/Source/WTF/wtf/glib/GMainLoopSource.cpp (192790 => 192791)


--- trunk/Source/WTF/wtf/glib/GMainLoopSource.cpp	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Source/WTF/wtf/glib/GMainLoopSource.cpp	2015-11-30 08:05:51 UTC (rev 192791)
@@ -1,333 +0,0 @@
-/*
- * Copyright (C) 2014 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 "GMainLoopSource.h"
-
-#if USE(GLIB)
-
-#include <gio/gio.h>
-
-namespace WTF {
-
-GMainLoopSource::~GMainLoopSource()
-{
-    cancel();
-}
-
-bool GMainLoopSource::isScheduled() const
-{
-    return m_status == Scheduled;
-}
-
-bool GMainLoopSource::isActive() const
-{
-    return m_status != Ready;
-}
-
-void GMainLoopSource::cancel()
-{
-    // A valid context should only be present if GMainLoopSource is in the Scheduled or Dispatching state.
-    ASSERT(!m_context.source || m_status == Scheduled || m_status == Dispatching);
-
-    m_status = Ready;
-
-    if (!m_context.source)
-        return;
-
-    Context context;
-    context = WTF::move(m_context);
-    context.destroySource();
-}
-
-void GMainLoopSource::scheduleIdleSource(const char* name, GSourceFunc sourceFunction, int priority, GMainContext* context)
-{
-    ASSERT(m_status == Ready);
-    m_status = Scheduled;
-
-    g_source_set_name(m_context.source.get(), name);
-    if (priority != G_PRIORITY_DEFAULT_IDLE)
-        g_source_set_priority(m_context.source.get(), priority);
-    g_source_set_callback(m_context.source.get(), sourceFunction, this, nullptr);
-    g_source_attach(m_context.source.get(), context);
-}
-
-void GMainLoopSource::schedule(const char* name, std::function<void ()>&& function, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    cancel();
-
-    ASSERT(!m_context.source);
-    m_context = {
-        adoptGRef(g_idle_source_new()),
-        nullptr, // cancellable
-        WTF::move(function),
-        nullptr, // boolCallback
-        WTF::move(destroyFunction)
-    };
-    scheduleIdleSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context);
-}
-
-void GMainLoopSource::schedule(const char* name, std::function<bool ()>&& function, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    cancel();
-
-    ASSERT(!m_context.source);
-    m_context = {
-        adoptGRef(g_idle_source_new()),
-        nullptr, // cancellable
-        nullptr, // voidCallback
-        WTF::move(function),
-        WTF::move(destroyFunction)
-    };
-    scheduleIdleSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context);
-}
-
-void GMainLoopSource::scheduleTimeoutSource(const char* name, GSourceFunc sourceFunction, int priority, GMainContext* context)
-{
-    ASSERT(m_status == Ready);
-    m_status = Scheduled;
-
-    g_source_set_name(m_context.source.get(), name);
-    if (priority != G_PRIORITY_DEFAULT)
-        g_source_set_priority(m_context.source.get(), priority);
-    g_source_set_callback(m_context.source.get(), sourceFunction, this, nullptr);
-    g_source_attach(m_context.source.get(), context);
-}
-
-void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<void ()>&& function, std::chrono::milliseconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    cancel();
-
-    ASSERT(!m_context.source);
-    m_context = {
-        adoptGRef(g_timeout_source_new(delay.count())),
-        nullptr, // cancellable
-        WTF::move(function),
-        nullptr, // boolCallback
-        WTF::move(destroyFunction)
-    };
-    scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context);
-}
-
-void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<bool ()>&& function, std::chrono::milliseconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    cancel();
-
-    ASSERT(!m_context.source);
-    m_context = {
-        adoptGRef(g_timeout_source_new(delay.count())),
-        nullptr, // cancellable
-        nullptr, // voidCallback
-        WTF::move(function),
-        WTF::move(destroyFunction)
-    };
-    scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context);
-}
-
-void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<void ()>&& function, std::chrono::seconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    cancel();
-
-    ASSERT(!m_context.source);
-    m_context = {
-        adoptGRef(g_timeout_source_new_seconds(delay.count())),
-        nullptr, // cancellable
-        WTF::move(function),
-        nullptr, // boolCallback
-        WTF::move(destroyFunction)
-    };
-    scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context);
-}
-
-void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<bool ()>&& function, std::chrono::seconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    cancel();
-
-    ASSERT(!m_context.source);
-    m_context = {
-        adoptGRef(g_timeout_source_new_seconds(delay.count())),
-        nullptr, // cancellable
-        nullptr, // voidCallback
-        WTF::move(function),
-        WTF::move(destroyFunction)
-    };
-    scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context);
-}
-
-struct MicrosecondsTimeoutSource {
-    GSource source;
-    uint64_t delay;
-};
-
-static GSourceFuncs microsecondsTimeoutSourceFunctions = {
-    nullptr, // prepare
-    nullptr, // check
-    // dispatch
-    [](GSource* source, GSourceFunc callback, gpointer userData) -> gboolean
-    {
-        bool repeat = callback(userData);
-        if (repeat)
-            g_source_set_ready_time(source, g_source_get_time(source) + reinterpret_cast<MicrosecondsTimeoutSource*>(source)->delay);
-        return repeat;
-    },
-    nullptr, // finalize
-    nullptr, // closure_callback
-    nullptr // closure_marshall
-};
-
-static GSource* createMicrosecondsTimeoutSource(uint64_t delay)
-{
-    GSource* source = g_source_new(&microsecondsTimeoutSourceFunctions, sizeof(MicrosecondsTimeoutSource));
-    reinterpret_cast<MicrosecondsTimeoutSource*>(source)->delay = delay;
-    g_source_set_ready_time(source, g_get_monotonic_time() + delay);
-    return source;
-}
-
-void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<void ()>&& function, std::chrono::microseconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    cancel();
-
-    ASSERT(!m_context.source);
-    m_context = {
-        adoptGRef(createMicrosecondsTimeoutSource(delay.count())),
-        nullptr, // cancellable
-        WTF::move(function),
-        nullptr, // boolCallback
-        WTF::move(destroyFunction)
-    };
-    scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(voidSourceCallback), priority, context);
-}
-
-void GMainLoopSource::scheduleAfterDelay(const char* name, std::function<bool ()>&& function, std::chrono::microseconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    cancel();
-
-    ASSERT(!m_context.source);
-    m_context = {
-        adoptGRef(createMicrosecondsTimeoutSource(delay.count())),
-        nullptr, // cancellable
-        nullptr, // voidCallback
-        WTF::move(function),
-        WTF::move(destroyFunction)
-    };
-    scheduleTimeoutSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context);
-}
-
-bool GMainLoopSource::prepareVoidCallback(Context& context)
-{
-    if (!m_context.source)
-        return false;
-
-    context = WTF::move(m_context);
-
-    ASSERT(context.voidCallback);
-    ASSERT(m_status == Scheduled);
-    m_status = Dispatching;
-
-    return true;
-}
-
-void GMainLoopSource::finishVoidCallback()
-{
-    m_status = Ready;
-}
-
-void GMainLoopSource::voidCallback()
-{
-    Context context;
-    if (!prepareVoidCallback(context))
-        return;
-
-    context.voidCallback();
-    if (m_status != Ready && !m_context.source) {
-        // Switch to Ready if it hasn't been re-scheduled or cancelled.
-        finishVoidCallback();
-    }
-
-    context.destroySource();
-}
-
-bool GMainLoopSource::prepareBoolCallback(Context& context)
-{
-    if (!m_context.source)
-        return false;
-
-    context = WTF::move(m_context);
-
-    ASSERT(context.boolCallback);
-    ASSERT(m_status == Scheduled || m_status == Dispatching);
-    m_status = Dispatching;
-    return true;
-}
-
-void GMainLoopSource::finishBoolCallback(bool retval, Context& context)
-{
-    // 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;
-}
-
-bool GMainLoopSource::boolCallback()
-{
-    Context context;
-    if (!prepareBoolCallback(context))
-        return Stop;
-
-    bool retval = context.boolCallback();
-    if (m_status != Ready && !m_context.source) {
-        // Prepare for a new iteration or switch to Ready if it hasn't been re-scheduled or cancelled.
-        finishBoolCallback(retval, context);
-    }
-
-    if (context.source)
-        context.destroySource();
-
-    return retval;
-}
-
-gboolean GMainLoopSource::voidSourceCallback(GMainLoopSource* source)
-{
-    source->voidCallback();
-    return G_SOURCE_REMOVE;
-}
-
-gboolean GMainLoopSource::boolSourceCallback(GMainLoopSource* source)
-{
-    return source->boolCallback() == Continue;
-}
-
-void GMainLoopSource::Context::destroySource()
-{
-    g_source_destroy(source.get());
-    if (destroyCallback)
-        destroyCallback();
-}
-
-} // namespace WTF
-
-#endif // USE(GLIB)

Deleted: trunk/Source/WTF/wtf/glib/GMainLoopSource.h (192790 => 192791)


--- trunk/Source/WTF/wtf/glib/GMainLoopSource.h	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Source/WTF/wtf/glib/GMainLoopSource.h	2015-11-30 08:05:51 UTC (rev 192791)
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2014 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 GMainLoopSource_h
-#define GMainLoopSource_h
-
-#if USE(GLIB)
-
-#include <functional>
-#include <glib.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/glib/GRefPtr.h>
-
-namespace WTF {
-
-class GMainLoopSource {
-    WTF_MAKE_NONCOPYABLE(GMainLoopSource);
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    WTF_EXPORT_PRIVATE GMainLoopSource() = default;
-    WTF_EXPORT_PRIVATE virtual ~GMainLoopSource();
-
-    static const bool Stop = false;
-    static const bool Continue = true;
-
-    WTF_EXPORT_PRIVATE bool isScheduled() const;
-    WTF_EXPORT_PRIVATE bool isActive() const;
-
-    WTF_EXPORT_PRIVATE virtual void schedule(const char* name, std::function<void()>&&, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);
-    WTF_EXPORT_PRIVATE virtual void schedule(const char* name, std::function<bool()>&&, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);
-    WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<void()>&&, std::chrono::milliseconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);
-    WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<bool()>&&, std::chrono::milliseconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);
-    WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<void()>&&, std::chrono::seconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);
-    WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<bool()>&&, std::chrono::seconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);
-    WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<void()>&&, std::chrono::microseconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);
-    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();
-
-protected:
-    enum Status { Ready, Scheduled, Dispatching };
-
-    struct Context {
-        Context() = default;
-        Context& operator=(Context&& c)
-        {
-            source = WTF::move(c.source);
-            cancellable = WTF::move(c.cancellable);
-            voidCallback = WTF::move(c.voidCallback);
-            boolCallback = WTF::move(c.boolCallback);
-            destroyCallback = WTF::move(c.destroyCallback);
-            return *this;
-        }
-
-        void destroySource();
-
-        GRefPtr<GSource> source;
-        GRefPtr<GCancellable> cancellable;
-        std::function<void ()> voidCallback;
-        std::function<bool ()> boolCallback;
-        std::function<void ()> destroyCallback;
-    };
-
-    virtual void voidCallback();
-    virtual bool boolCallback();
-
-    virtual bool prepareVoidCallback(Context&);
-    virtual void finishVoidCallback();
-    virtual bool prepareBoolCallback(Context&);
-    virtual void finishBoolCallback(bool retval, Context&);
-
-private:
-    void scheduleIdleSource(const char* name, GSourceFunc, int priority, GMainContext*);
-    void scheduleTimeoutSource(const char* name, GSourceFunc, int priority, GMainContext*);
-
-    static gboolean voidSourceCallback(GMainLoopSource*);
-    static gboolean boolSourceCallback(GMainLoopSource*);
-
-protected:
-    Context m_context;
-    Status m_status { Ready };
-};
-
-} // namespace WTF
-
-using WTF::GMainLoopSource;
-
-#endif // USE(GLIB)
-
-#endif // GMainLoopSource_h

Deleted: trunk/Source/WTF/wtf/glib/GThreadSafeMainLoopSource.cpp (192790 => 192791)


--- trunk/Source/WTF/wtf/glib/GThreadSafeMainLoopSource.cpp	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Source/WTF/wtf/glib/GThreadSafeMainLoopSource.cpp	2015-11-30 08:05:51 UTC (rev 192791)
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2014 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 "GThreadSafeMainLoopSource.h"
-
-#if USE(GLIB)
-
-#include <gio/gio.h>
-#include <wtf/glib/GMutexLocker.h>
-
-namespace WTF {
-
-GThreadSafeMainLoopSource::GThreadSafeMainLoopSource()
-{
-    g_rec_mutex_init(&m_mutex);
-}
-
-GThreadSafeMainLoopSource::~GThreadSafeMainLoopSource()
-{
-    cancel();
-    g_rec_mutex_clear(&m_mutex);
-}
-
-void GThreadSafeMainLoopSource::cancel()
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-
-    // The general cancellable object should only be present if we're currently dispatching this GMainLoopSource.
-    ASSERT(!m_cancellable || m_status == Dispatching);
-
-    // The source is perhaps being cancelled in the middle of a callback dispatch.
-    // Cancelling this GCancellable object will convey this information to the
-    // current execution context when the callback dispatch is finished.
-    g_cancellable_cancel(m_cancellable.get());
-    m_cancellable = nullptr;
-
-    GMainLoopSource::cancel();
-}
-
-void GThreadSafeMainLoopSource::schedule(const char* name, std::function<void ()>&& function, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    GMainLoopSource::schedule(name, WTF::move(function), priority, WTF::move(destroyFunction), context);
-    m_context.cancellable = adoptGRef(g_cancellable_new());
-}
-
-void GThreadSafeMainLoopSource::schedule(const char* name, std::function<bool ()>&& function, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    GMainLoopSource::schedule(name, WTF::move(function), priority, WTF::move(destroyFunction), context);
-    m_context.cancellable = adoptGRef(g_cancellable_new());
-}
-
-void GThreadSafeMainLoopSource::scheduleAfterDelay(const char* name, std::function<void ()>&& function, std::chrono::milliseconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    GMainLoopSource::scheduleAfterDelay(name, WTF::move(function), delay, priority, WTF::move(destroyFunction), context);
-    m_context.cancellable = adoptGRef(g_cancellable_new());
-}
-
-void GThreadSafeMainLoopSource::scheduleAfterDelay(const char* name, std::function<bool ()>&& function, std::chrono::milliseconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    GMainLoopSource::scheduleAfterDelay(name, WTF::move(function), delay, priority, WTF::move(destroyFunction), context);
-    m_context.cancellable = adoptGRef(g_cancellable_new());
-}
-
-void GThreadSafeMainLoopSource::scheduleAfterDelay(const char* name, std::function<void ()>&& function, std::chrono::seconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    GMainLoopSource::scheduleAfterDelay(name, WTF::move(function), delay, priority, WTF::move(destroyFunction), context);
-    m_context.cancellable = adoptGRef(g_cancellable_new());
-}
-
-void GThreadSafeMainLoopSource::scheduleAfterDelay(const char* name, std::function<bool ()>&& function, std::chrono::seconds delay, int priority, std::function<void ()>&& destroyFunction, GMainContext* context)
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    GMainLoopSource::scheduleAfterDelay(name, WTF::move(function), delay, priority, WTF::move(destroyFunction), context);
-    m_context.cancellable = adoptGRef(g_cancellable_new());
-}
-
-bool GThreadSafeMainLoopSource::prepareVoidCallback(Context& context)
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    bool retval = GMainLoopSource::prepareVoidCallback(context);
-    m_cancellable = context.cancellable;
-    return retval;
-}
-
-void GThreadSafeMainLoopSource::finishVoidCallback()
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    GMainLoopSource::finishVoidCallback();
-    m_cancellable = nullptr;
-}
-
-void GThreadSafeMainLoopSource::voidCallback()
-{
-    Context context;
-    if (!prepareVoidCallback(context))
-        return;
-
-    context.voidCallback();
-
-    if (g_cancellable_is_cancelled(context.cancellable.get())) {
-        context.destroySource();
-        return;
-    }
-
-    finishVoidCallback();
-    context.destroySource();
-}
-
-bool GThreadSafeMainLoopSource::prepareBoolCallback(Context& context)
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    bool retval = GMainLoopSource::prepareBoolCallback(context);
-    m_cancellable = context.cancellable;
-    return retval;
-}
-
-void GThreadSafeMainLoopSource::finishBoolCallback(bool retval, Context& context)
-{
-    GMutexLocker<GRecMutex> locker(m_mutex);
-    GMainLoopSource::finishBoolCallback(retval, context);
-    m_cancellable = nullptr;
-}
-
-bool GThreadSafeMainLoopSource::boolCallback()
-{
-    Context context;
-    if (!prepareBoolCallback(context))
-        return Stop;
-
-    bool retval = context.boolCallback();
-
-    if (g_cancellable_is_cancelled(context.cancellable.get())) {
-        context.destroySource();
-        return Stop;
-    }
-
-    finishBoolCallback(retval, context);
-    if (context.source)
-        context.destroySource();
-    return retval;
-}
-
-} // namespace WTF
-
-#endif // USE(GLIB)

Deleted: trunk/Source/WTF/wtf/glib/GThreadSafeMainLoopSource.h (192790 => 192791)


--- trunk/Source/WTF/wtf/glib/GThreadSafeMainLoopSource.h	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Source/WTF/wtf/glib/GThreadSafeMainLoopSource.h	2015-11-30 08:05:51 UTC (rev 192791)
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2014 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 GThreadSafeMainLoopSource_h
-#define GThreadSafeMainLoopSource_h
-
-#if USE(GLIB)
-
-#include <wtf/glib/GMainLoopSource.h>
-
-typedef struct _GRecMutex GRecMutex;
-
-namespace WTF {
-
-class GThreadSafeMainLoopSource final : public GMainLoopSource {
-    WTF_MAKE_NONCOPYABLE(GThreadSafeMainLoopSource);
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    WTF_EXPORT_PRIVATE GThreadSafeMainLoopSource();
-    WTF_EXPORT_PRIVATE virtual ~GThreadSafeMainLoopSource();
-
-    WTF_EXPORT_PRIVATE virtual void schedule(const char* name, std::function<void()>&&, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr) override;
-    WTF_EXPORT_PRIVATE virtual void schedule(const char* name, std::function<bool()>&&, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr) override;
-    WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<void()>&&, std::chrono::milliseconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr) override;
-    WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<bool()>&&, std::chrono::milliseconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr) override;
-    WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<void()>&&, std::chrono::seconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr) override;
-    WTF_EXPORT_PRIVATE virtual void scheduleAfterDelay(const char* name, std::function<bool()>&&, std::chrono::seconds, int priority = G_PRIORITY_DEFAULT, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr) override;
-    WTF_EXPORT_PRIVATE virtual void cancel() override;
-
-private:
-    virtual void voidCallback() override;
-    virtual bool boolCallback() override;
-
-    virtual bool prepareVoidCallback(Context&) override;
-    virtual void finishVoidCallback() override;
-    virtual bool prepareBoolCallback(Context&) override;
-    virtual void finishBoolCallback(bool retval, Context&) override;
-
-    GRecMutex m_mutex;
-    GRefPtr<GCancellable> m_cancellable;
-};
-
-} // namespace WTF
-
-using WTF::GThreadSafeMainLoopSource;
-
-#endif // USE(GLIB)
-
-#endif // GThreadSafeMainLoopSource_h

Modified: trunk/Tools/ChangeLog (192790 => 192791)


--- trunk/Tools/ChangeLog	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Tools/ChangeLog	2015-11-30 08:05:51 UTC (rev 192791)
@@ -1,3 +1,13 @@
+2015-11-30  Carlos Garcia Campos  <[email protected]>
+
+        [GLIB] Remove GMainLoopSource and GThreadSafeMainLoopSource
+        https://bugs.webkit.org/show_bug.cgi?id=151633
+
+        Reviewed by Csaba Osztrogonác.
+
+        * TestWebKitAPI/PlatformGTK.cmake:
+        * TestWebKitAPI/Tests/WTF/glib/GMainLoopSource.cpp: Removed.
+
 2015-11-27  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Remove the remaining uses of GMainLoopSource

Modified: trunk/Tools/TestWebKitAPI/PlatformGTK.cmake (192790 => 192791)


--- trunk/Tools/TestWebKitAPI/PlatformGTK.cmake	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Tools/TestWebKitAPI/PlatformGTK.cmake	2015-11-30 08:05:51 UTC (rev 192791)
@@ -160,7 +160,6 @@
 set_target_properties(TestWebCore PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebCore)
 
 list(APPEND TestWTF_SOURCES
-    ${TESTWEBKITAPI_DIR}/Tests/WTF/glib/GMainLoopSource.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/glib/GUniquePtr.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/glib/WorkQueueGLib.cpp
 )

Deleted: trunk/Tools/TestWebKitAPI/Tests/WTF/glib/GMainLoopSource.cpp (192790 => 192791)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/glib/GMainLoopSource.cpp	2015-11-30 00:56:22 UTC (rev 192790)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/glib/GMainLoopSource.cpp	2015-11-30 08:05:51 UTC (rev 192791)
@@ -1,497 +0,0 @@
-/*
- * Copyright (C) 2014 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#include <wtf/glib/GThreadSafeMainLoopSource.h>
-#include <stdio.h>
-
-namespace TestWebKitAPI {
-
-template <typename T>
-class GMainLoopSourceTest {
-public:
-    GMainLoopSourceTest()
-        : m_mainLoop(g_main_loop_new(nullptr, TRUE))
-    {
-    }
-
-    ~GMainLoopSourceTest()
-    {
-        g_main_loop_unref(m_mainLoop);
-    }
-
-    void runLoop()
-    {
-        g_main_loop_run(m_mainLoop);
-    }
-
-    void delayedFinish()
-    {
-        g_timeout_add(250,
-            [](gpointer data) {
-                GMainLoopSourceTest& test = *static_cast<GMainLoopSourceTest*>(data);
-                test.finish();
-                return G_SOURCE_REMOVE;
-            }, this);
-    }
-
-    void finish()
-    {
-        g_main_loop_quit(m_mainLoop);
-    }
-
-    T& source() { return m_source; }
-
-private:
-    GMainLoop* m_mainLoop;
-    T m_source;
-};
-
-template <typename T>
-static void basicRescheduling(T& context)
-{
-    EXPECT_TRUE(!context.test.source().isActive());
-
-    context.test.source().schedule("[Test] FirstTask", [&] {
-        // This should never be called. That's why we assert
-        // that the variable is false a few lines later.
-        context.finishedFirstTask = true;
-    });
-    EXPECT_TRUE(context.test.source().isScheduled());
-
-    context.test.source().schedule("[Test] SecondTask", [&] {
-        EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-        context.finishedSecondTask = true;
-        context.test.finish();
-    });
-    EXPECT_TRUE(context.test.source().isScheduled());
-
-    context.test.runLoop();
-
-    EXPECT_TRUE(!context.test.source().isActive());
-    EXPECT_FALSE(context.finishedFirstTask);
-    EXPECT_TRUE(context.finishedSecondTask);
-}
-
-TEST(WTF_GMainLoopSource, BasicRescheduling)
-{
-    struct TestingContext {
-        GMainLoopSourceTest<GMainLoopSource> test;
-        bool finishedFirstTask = false;
-        bool finishedSecondTask = false;
-    } context;
-    basicRescheduling<TestingContext>(context);
-
-    struct ThreadSafeTestingContext {
-        GMainLoopSourceTest<GThreadSafeMainLoopSource> test;
-        bool finishedFirstTask = false;
-        bool finishedSecondTask = false;
-    } threadSafeContext;
-    basicRescheduling<ThreadSafeTestingContext>(threadSafeContext);
-}
-
-template <typename T>
-static void reentrantRescheduling(T& context)
-{
-    EXPECT_TRUE(!context.test.source().isActive());
-
-    context.test.source().schedule("[Test] FirstTask", [&] {
-        EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-
-        context.test.source().schedule("[Test] SecondTask", [&] {
-            EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-            EXPECT_TRUE(context.finishedFirstTask);
-
-            context.finishedSecondTask = true;
-            context.test.finish();
-        });
-        EXPECT_TRUE(context.test.source().isScheduled());
-
-        context.finishedFirstTask = true;
-    });
-    EXPECT_TRUE(context.test.source().isScheduled());
-
-    context.test.runLoop();
-
-    EXPECT_TRUE(!context.test.source().isActive());
-    EXPECT_TRUE(context.finishedFirstTask);
-    EXPECT_TRUE(context.finishedSecondTask);
-}
-
-TEST(WTF_GMainLoopSource, ReentrantRescheduling)
-{
-    struct TestingContext {
-        GMainLoopSourceTest<GMainLoopSource> test;
-        bool finishedFirstTask = false;
-        bool finishedSecondTask = false;
-    } context;
-    reentrantRescheduling<TestingContext>(context);
-
-    struct ThreadSafeTestingContext {
-        GMainLoopSourceTest<GThreadSafeMainLoopSource> test;
-        bool finishedFirstTask = false;
-        bool finishedSecondTask = false;
-    } threadSafeContext;
-    reentrantRescheduling<ThreadSafeTestingContext>(threadSafeContext);
-}
-
-TEST(WTF_GMainLoopSource, ReschedulingFromDifferentThread)
-{
-    struct TestingContext {
-        GMainLoopSourceTest<GThreadSafeMainLoopSource> test;
-        bool finishedFirstTask;
-        bool finishedSecondTask;
-    } context;
-
-    EXPECT_TRUE(!context.test.source().isActive());
-
-    context.test.source().schedule("[Test] FirstTask", [&] {
-        EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-
-        g_usleep(1 * G_USEC_PER_SEC);
-        context.finishedFirstTask = true;
-    });
-    EXPECT_TRUE(context.test.source().isScheduled());
-
-    GThread* helperThread = g_thread_new(nullptr, [](gpointer data) -> gpointer {
-        g_usleep(0.25 * G_USEC_PER_SEC);
-
-        TestingContext& context = *static_cast<TestingContext*>(data);
-        EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-        EXPECT_FALSE(context.finishedFirstTask);
-
-        context.test.source().schedule("[Test] SecondTask", [&] {
-            EXPECT_TRUE(context.finishedFirstTask);
-
-            context.finishedSecondTask = true;
-            context.test.finish();
-        });
-        EXPECT_TRUE(context.test.source().isScheduled());
-
-        g_thread_exit(nullptr);
-        return nullptr;
-    }, &context);
-
-    context.test.runLoop();
-    g_thread_unref(helperThread);
-
-    EXPECT_TRUE(!context.test.source().isActive());
-    EXPECT_TRUE(context.finishedFirstTask);
-    EXPECT_TRUE(context.finishedSecondTask);
-}
-
-TEST(WTF_GMainLoopSource, DestructionDuringDispatch)
-{
-    // This is just a raw test that ensures deleting the GMainLoopSource object during
-    // dispatch does not cause problems. This test succeeds if it doesn't crash.
-
-    GMainLoopSource* source;
-    GMainLoop* loop = g_main_loop_new(nullptr, TRUE);
-
-    source = new GMainLoopSource;
-    source->schedule("[Test] DestroySourceTask", [&] {
-        delete source;
-        g_main_loop_quit(loop);
-    });
-    g_main_loop_run(loop);
-
-    source = new GMainLoopSource;
-    source->schedule("[Test] DestroySourceTask", std::function<bool ()>([&] {
-        delete source;
-        g_main_loop_quit(loop);
-        return false;
-    }));
-    g_main_loop_run(loop);
-
-    g_main_loop_unref(loop);
-}
-
-template <typename T>
-static void cancelRepeatingSourceDuringDispatch(T& context)
-{
-    EXPECT_TRUE(!context.test.source().isActive());
-
-    context.test.source().schedule("[Test] RepeatingTask",
-        std::function<bool ()>([&] {
-            EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-
-            context.callCount++;
-            if (context.callCount == 3)
-                context.test.source().cancel();
-            return true;
-        }));
-    EXPECT_TRUE(context.test.source().isScheduled());
-
-    context.test.delayedFinish();
-    context.test.runLoop();
-
-    EXPECT_TRUE(!context.test.source().isActive());
-    EXPECT_EQ(3, context.callCount);
-}
-
-TEST(WTF_GMainLoopSource, CancelRepeatingSourceDuringDispatch)
-{
-    struct TestingContext {
-        GMainLoopSourceTest<GMainLoopSource> test;
-        unsigned callCount = 0;
-    } context;
-    cancelRepeatingSourceDuringDispatch<TestingContext>(context);
-
-    struct ThreadSafeTestingContext {
-        GMainLoopSourceTest<GThreadSafeMainLoopSource> test;
-        unsigned callCount = 0;
-    } threadSafeContext;
-    cancelRepeatingSourceDuringDispatch<ThreadSafeTestingContext>(threadSafeContext);
-}
-
-template <typename T>
-static void basicDestroyCallbacks()
-{
-    {
-        T context;
-        EXPECT_TRUE(!context.test.source().isActive());
-        context.test.source().schedule("[Test] DestroyCallback",
-            [&] {
-                EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-                context.callbackCalled = true;
-            }, G_PRIORITY_DEFAULT,
-            [&] {
-                EXPECT_TRUE(!context.test.source().isActive());
-                context.destroyCallbackCalled = true;
-                context.test.finish();
-            });
-        EXPECT_TRUE(context.test.source().isScheduled());
-
-        context.test.runLoop();
-
-        EXPECT_TRUE(!context.test.source().isActive());
-        EXPECT_TRUE(context.callbackCalled);
-        EXPECT_TRUE(context.destroyCallbackCalled);
-    }
-
-    {
-        T context;
-        EXPECT_TRUE(!context.test.source().isActive());
-        context.test.source().schedule("[Test] DestroyCallback",
-            std::function<bool ()>([&] {
-                EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-                context.callbackCalled = true;
-                return false;
-            }), G_PRIORITY_DEFAULT,
-            [&] {
-                EXPECT_TRUE(!context.test.source().isActive());
-                context.destroyCallbackCalled = true;
-                context.test.finish();
-            });
-        EXPECT_TRUE(context.test.source().isScheduled());
-
-        context.test.runLoop();
-
-        EXPECT_TRUE(!context.test.source().isActive());
-        EXPECT_TRUE(context.callbackCalled);
-        EXPECT_TRUE(context.destroyCallbackCalled);
-    }
-}
-
-TEST(WTF_GMainLoopSource, BasicDestroyCallbacks)
-{
-    struct TestingContext {
-        GMainLoopSourceTest<GMainLoopSource> test;
-        bool callbackCalled = false;
-        bool destroyCallbackCalled = false;
-    };
-    basicDestroyCallbacks<TestingContext>();
-
-    struct ThreadSafeTestingContext {
-        GMainLoopSourceTest<GThreadSafeMainLoopSource> test;
-        bool callbackCalled = false;
-        bool destroyCallbackCalled = false;
-    };
-    basicDestroyCallbacks<ThreadSafeTestingContext>();
-}
-
-template <typename T>
-static void destroyCallbacksAfterCancellingDuringDispatch()
-{
-    {
-        T context;
-        EXPECT_TRUE(!context.test.source().isActive());
-        context.test.source().schedule("[Test] DestroyCallback",
-            [&] {
-                EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-                context.callbackCallCount++;
-                context.test.source().cancel();
-            }, G_PRIORITY_DEFAULT,
-            [&] {
-                EXPECT_TRUE(!context.test.source().isActive());
-                context.destroyCallbackCalled = true;
-                context.test.finish();
-            });
-        EXPECT_TRUE(context.test.source().isScheduled());
-
-        context.test.delayedFinish();
-        context.test.runLoop();
-
-        EXPECT_TRUE(!context.test.source().isActive());
-        EXPECT_EQ(1, context.callbackCallCount);
-        EXPECT_TRUE(context.destroyCallbackCalled);
-    }
-
-    {
-        T context;
-        EXPECT_TRUE(!context.test.source().isActive());
-        context.test.source().schedule("[Test] DestroyCallback",
-            std::function<bool ()>([&] {
-                EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-                context.callbackCallCount++;
-                if (context.callbackCallCount == 3)
-                    context.test.source().cancel();
-                return true;
-            }), G_PRIORITY_DEFAULT,
-            [&] {
-                EXPECT_TRUE(!context.test.source().isActive());
-                context.destroyCallbackCalled = true;
-            });
-        EXPECT_TRUE(context.test.source().isScheduled());
-
-        context.test.delayedFinish();
-        context.test.runLoop();
-
-        EXPECT_TRUE(!context.test.source().isActive());
-        EXPECT_EQ(3, context.callbackCallCount);
-        EXPECT_TRUE(context.destroyCallbackCalled);
-    }
-}
-
-TEST(WTF_GMainLoopSource, DestroyCallbacksAfterCancellingDuringDispatch)
-{
-    struct TestingContext {
-        GMainLoopSourceTest<GMainLoopSource> test;
-        unsigned callbackCallCount= 0;
-        bool destroyCallbackCalled = false;
-    };
-    destroyCallbacksAfterCancellingDuringDispatch<TestingContext>();
-
-    struct ThreadSafeTestingContext {
-        GMainLoopSourceTest<GThreadSafeMainLoopSource> test;
-        unsigned callbackCallCount= 0;
-        bool destroyCallbackCalled = false;
-    };
-    destroyCallbacksAfterCancellingDuringDispatch<ThreadSafeTestingContext>();
-}
-
-template <typename T>
-static void destroyCallbacksAfterReschedulingDuringDispatch()
-{
-    {
-        T context;
-        EXPECT_TRUE(!context.test.source().isActive());
-        context.test.source().schedule("[Test] BaseCallback",
-            [&] {
-                EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-                context.firstCallbackCallCount++;
-                context.test.source().schedule("[Test] ReschedulingCallback",
-                    [&] {
-                        EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-                        context.secondCallbackCallCount++;
-                    }, G_PRIORITY_DEFAULT,
-                    [&] {
-                        EXPECT_TRUE(!context.test.source().isActive());
-                        context.secondDestroyCallbackCalled = true;
-                    });
-                EXPECT_TRUE(context.test.source().isScheduled());
-            }, G_PRIORITY_DEFAULT,
-            [&] {
-                // At this point the GMainLoopSource has been rescheduled, ergo the Scheduled status.
-                EXPECT_TRUE(context.test.source().isScheduled());
-                context.firstDestroyCallbackCalled = true;
-            });
-        EXPECT_TRUE(context.test.source().isScheduled());
-
-        context.test.delayedFinish();
-        context.test.runLoop();
-
-        EXPECT_TRUE(!context.test.source().isActive());
-        EXPECT_EQ(1, context.firstCallbackCallCount);
-        EXPECT_TRUE(context.firstDestroyCallbackCalled);
-        EXPECT_EQ(1, context.secondCallbackCallCount);
-        EXPECT_TRUE(context.secondDestroyCallbackCalled);
-    }
-
-    {
-        T context;
-        EXPECT_TRUE(!context.test.source().isActive());
-        context.test.source().schedule("[Test] BaseCallback",
-            std::function<bool ()>([&] {
-                EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-                context.firstCallbackCallCount++;
-                context.test.source().schedule("[Test] ReschedulingCallback",
-                    std::function<bool ()>([&] {
-                        EXPECT_TRUE(context.test.source().isActive() && !context.test.source().isScheduled());
-                        context.secondCallbackCallCount++;
-                        return context.secondCallbackCallCount != 3;
-                    }), G_PRIORITY_DEFAULT,
-                    [&] {
-                        EXPECT_TRUE(!context.test.source().isActive());
-                        context.secondDestroyCallbackCalled = true;
-                    });
-                EXPECT_TRUE(context.test.source().isScheduled());
-                return true;
-            }), G_PRIORITY_DEFAULT,
-            [&] {
-                // At this point the GMainLoopSource has been rescheduled, ergo the Scheduled status.
-                EXPECT_TRUE(context.test.source().isScheduled());
-                context.firstDestroyCallbackCalled = true;
-            });
-        EXPECT_TRUE(context.test.source().isScheduled());
-
-        context.test.delayedFinish();
-        context.test.runLoop();
-
-        EXPECT_TRUE(!context.test.source().isActive());
-        EXPECT_EQ(1, context.firstCallbackCallCount);
-        EXPECT_TRUE(context.firstDestroyCallbackCalled);
-        EXPECT_EQ(3, context.secondCallbackCallCount);
-        EXPECT_TRUE(context.secondDestroyCallbackCalled);
-    }
-}
-
-TEST(WTF_GMainLoopSource, DestroyCallbacksAfterReschedulingDuringDispatch)
-{
-    struct TestingContext {
-        GMainLoopSourceTest<GMainLoopSource> test;
-        unsigned firstCallbackCallCount = 0;
-        bool firstDestroyCallbackCalled = false;
-        unsigned secondCallbackCallCount = 0;
-        bool secondDestroyCallbackCalled = false;
-    };
-    destroyCallbacksAfterReschedulingDuringDispatch<TestingContext>();
-
-    struct ThreadSafeTestingContext {
-        GMainLoopSourceTest<GThreadSafeMainLoopSource> test;
-        unsigned firstCallbackCallCount = 0;
-        bool firstDestroyCallbackCalled = false;
-        unsigned secondCallbackCallCount = 0;
-        bool secondDestroyCallbackCalled = false;
-    };
-    destroyCallbacksAfterReschedulingDuringDispatch<ThreadSafeTestingContext>();
-}
-
-} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to