[GTK] Dot not allow to create delete-on-destroy GMainLoopSources
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Sep 2014 06:51:24 +0000 (06:51 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Sep 2014 06:51:24 +0000 (06:51 +0000)
commitbae460e1b3291221766e8f7c38a1c1254be515a7
treeadbd084304e6dceaa627a6b5612c49451be13ec4
parent42a24e3458d6332316b29ae637731d9f0c526766
[GTK] Dot not allow to create delete-on-destroy GMainLoopSources
https://bugs.webkit.org/show_bug.cgi?id=136923

Reviewed by Gustavo Noronha Silva.

Source/WebCore:

* platform/gtk/GtkDragAndDropHelper.cpp:
(WebCore::GtkDragAndDropHelper::handleDragLeave): Use GMainLoopSource::scheduleAndDeleteOnDestroy().

Source/WebKit2:

* Platform/gtk/WorkQueueGtk.cpp:
(WorkQueue::dispatch): Use GMainLoopSource::scheduleAndDeleteOnDestroy().
(WorkQueue::dispatchAfter): Use GMainLoopSource::scheduleAfterDelayAndDeleteOnDestroy().

Source/WTF:

We have several asserts to ensure that delete-on-destroy sources
are not misused, like not scheduling socket sources on a
delete-on-destroy GMainLoopSource or not allowing to cancel them
before they have been dispatched. It's better to ensure all those
things at compile time, using static methods to schedule sources
creating a delete-on-destroy GMainLoopSource that is not returned
to the user.

* wtf/gobject/GMainLoopSource.cpp:
(WTF::GMainLoopSource::create): Private static method to create a
delete-on-destroy GMainLoopSource.
(WTF::GMainLoopSource::cancelWithoutLocking): Return early in case
of delete-on-destroy source, since they can't be cancelled.
(WTF::GMainLoopSource::schedule): Remove assertion to ensure
socket sources are not scheduled on a delete-on-destroy GMainLoopSource.
(WTF::GMainLoopSource::scheduleAndDeleteOnDestroy):
(WTF::GMainLoopSource::scheduleAfterDelayAndDeleteOnDestroy):
(WTF::GMainLoopSource::createAndDeleteOnDestroy): Deleted.
* wtf/gobject/GMainLoopSource.h:
* wtf/gtk/MainThreadGtk.cpp:
(WTF::scheduleDispatchFunctionsOnMainThread): Use GMainLoopSource::scheduleAndDeleteOnDestroy()
* wtf/gtk/RunLoopGtk.cpp:
(WTF::RunLoop::wakeUp): Ditto.

Tools:

* TestWebKitAPI/Tests/WTF/gobject/GMainLoopSource.cpp:
(TestWebKitAPI::TEST): Use the new API that doesn't allow to use
the source.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/gobject/GMainLoopSource.cpp
Source/WTF/wtf/gobject/GMainLoopSource.h
Source/WTF/wtf/gtk/MainThreadGtk.cpp
Source/WTF/wtf/gtk/RunLoopGtk.cpp
Source/WebCore/ChangeLog
Source/WebCore/platform/gtk/GtkDragAndDropHelper.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/gobject/GMainLoopSource.cpp