Title: [191787] trunk/Source
Revision
191787
Author
[email protected]
Date
2015-10-30 05:12:09 -0700 (Fri, 30 Oct 2015)

Log Message

[GTK] Use RunLoop::Timer instead of GMainLoopSource
https://bugs.webkit.org/show_bug.cgi?id=150592

Reviewed by Žan Doberšek.

Source/WebCore:

* platform/network/ResourceHandle.h:
* platform/network/ResourceHandleInternal.h:
(WebCore::ResourceHandleInternal::ResourceHandleInternal):
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::cleanupSoupRequestOperation):
(WebCore::ResourceHandle::timeoutFired):
(WebCore::ResourceHandle::sendPendingRequest):
(WebCore::ResourceHandle::platformSetDefersLoading):

Source/WebKit2:

* Shared/Downloads/soup/DownloadSoup.cpp:
(WebKit::DownloadClient::DownloadClient):
(WebKit::DownloadClient::didReceiveData):
(WebKit::DownloadClient::handleResponseLater):
* UIProcess/gtk/GestureController.cpp:
(WebKit::GestureController::DragGesture::begin):
(WebKit::GestureController::DragGesture::update):
(WebKit::GestureController::DragGesture::end):
(WebKit::GestureController::DragGesture::longPressFired):
(WebKit::GestureController::DragGesture::DragGesture):
(WebKit::GestureController::ZoomGesture::scaleChanged):
(WebKit::GestureController::ZoomGesture::ZoomGesture):
* UIProcess/gtk/GestureController.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (191786 => 191787)


--- trunk/Source/WebCore/ChangeLog	2015-10-30 11:28:14 UTC (rev 191786)
+++ trunk/Source/WebCore/ChangeLog	2015-10-30 12:12:09 UTC (rev 191787)
@@ -1,3 +1,19 @@
+2015-10-30  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Use RunLoop::Timer instead of GMainLoopSource
+        https://bugs.webkit.org/show_bug.cgi?id=150592
+
+        Reviewed by Žan Doberšek.
+
+        * platform/network/ResourceHandle.h:
+        * platform/network/ResourceHandleInternal.h:
+        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::cleanupSoupRequestOperation):
+        (WebCore::ResourceHandle::timeoutFired):
+        (WebCore::ResourceHandle::sendPendingRequest):
+        (WebCore::ResourceHandle::platformSetDefersLoading):
+
 2015-10-30  Hunseop Jeong  <[email protected]>
 
         REGRESSION(r191776): EFL build broken.

Modified: trunk/Source/WebCore/platform/network/ResourceHandle.h (191786 => 191787)


--- trunk/Source/WebCore/platform/network/ResourceHandle.h	2015-10-30 11:28:14 UTC (rev 191786)
+++ trunk/Source/WebCore/platform/network/ResourceHandle.h	2015-10-30 12:12:09 UTC (rev 191787)
@@ -289,6 +289,10 @@
 static void getConnectionTimingData(NSDictionary *timingData, ResourceLoadTiming&);
 #endif
 
+#if USE(SOUP)
+    void timeoutFired();
+#endif
+
     friend class ResourceHandleInternal;
     std::unique_ptr<ResourceHandleInternal> d;
 

Modified: trunk/Source/WebCore/platform/network/ResourceHandleInternal.h (191786 => 191787)


--- trunk/Source/WebCore/platform/network/ResourceHandleInternal.h	2015-10-30 11:28:14 UTC (rev 191786)
+++ trunk/Source/WebCore/platform/network/ResourceHandleInternal.h	2015-10-30 12:12:09 UTC (rev 191787)
@@ -52,7 +52,7 @@
 #if USE(SOUP)
 #include "GUniquePtrSoup.h"
 #include <libsoup/soup.h>
-#include <wtf/glib/GMainLoopSource.h>
+#include <wtf/RunLoop.h>
 #include <wtf/glib/GRefPtr.h>
 #endif
 
@@ -91,6 +91,7 @@
 #endif
 #if USE(SOUP)
             , m_cancelled(false)
+            , m_timeoutSource(RunLoop::main(), loader, &ResourceHandle::timeoutFired)
             , m_bodySize(0)
             , m_bodyDataSent(0)
             , m_redirectCount(0)
@@ -169,7 +170,7 @@
         GRefPtr<SoupMultipartInputStream> m_multipartInputStream;
         GRefPtr<GCancellable> m_cancellable;
         GRefPtr<GAsyncResult> m_deferredResult;
-        GMainLoopSource m_timeoutSource;
+        RunLoop::Timer<ResourceHandle> m_timeoutSource;
         GUniquePtr<SoupBuffer> m_soupBuffer;
         unsigned long m_bodySize;
         unsigned long m_bodyDataSent;

Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (191786 => 191787)


--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2015-10-30 11:28:14 UTC (rev 191786)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2015-10-30 12:12:09 UTC (rev 191787)
@@ -601,7 +601,7 @@
         d->m_soupMessage.clear();
     }
 
-    d->m_timeoutSource.cancel();
+    d->m_timeoutSource.stop();
 
     if (!isDestroying)
         handle->deref();
@@ -1049,19 +1049,20 @@
     return newHandle;
 }
 
+void ResourceHandle::timeoutFired()
+{
+    client()->didFail(this, ResourceError::timeoutError(firstRequest().url().string()));
+    cancel();
+}
+
 void ResourceHandle::sendPendingRequest()
 {
 #if ENABLE(WEB_TIMING)
     m_requestTime = monotonicallyIncreasingTime();
 #endif
 
-    if (d->m_firstRequest.timeoutInterval() > 0) {
-        d->m_timeoutSource.scheduleAfterDelay("[WebKit] ResourceHandle request timeout", [this] {
-            client()->didFail(this, ResourceError::timeoutError(firstRequest().url().string()));
-            cancel();
-        }, std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(d->m_firstRequest.timeoutInterval())),
-        G_PRIORITY_DEFAULT, nullptr, g_main_context_get_thread_default());
-    }
+    if (d->m_firstRequest.timeoutInterval() > 0)
+        d->m_timeoutSource.startOneShot(d->m_firstRequest.timeoutInterval());
 
     // Balanced by a deref() in cleanupSoupRequestOperation, which should always run.
     ref();
@@ -1265,7 +1266,7 @@
 
     // Except when canceling a possible timeout timer, we only need to take action here to UN-defer loading.
     if (defersLoading) {
-        d->m_timeoutSource.cancel();
+        d->m_timeoutSource.stop();
         return;
     }
 

Modified: trunk/Source/WebKit2/ChangeLog (191786 => 191787)


--- trunk/Source/WebKit2/ChangeLog	2015-10-30 11:28:14 UTC (rev 191786)
+++ trunk/Source/WebKit2/ChangeLog	2015-10-30 12:12:09 UTC (rev 191787)
@@ -1,3 +1,24 @@
+2015-10-30  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Use RunLoop::Timer instead of GMainLoopSource
+        https://bugs.webkit.org/show_bug.cgi?id=150592
+
+        Reviewed by Žan Doberšek.
+
+        * Shared/Downloads/soup/DownloadSoup.cpp:
+        (WebKit::DownloadClient::DownloadClient):
+        (WebKit::DownloadClient::didReceiveData):
+        (WebKit::DownloadClient::handleResponseLater):
+        * UIProcess/gtk/GestureController.cpp:
+        (WebKit::GestureController::DragGesture::begin):
+        (WebKit::GestureController::DragGesture::update):
+        (WebKit::GestureController::DragGesture::end):
+        (WebKit::GestureController::DragGesture::longPressFired):
+        (WebKit::GestureController::DragGesture::DragGesture):
+        (WebKit::GestureController::ZoomGesture::scaleChanged):
+        (WebKit::GestureController::ZoomGesture::ZoomGesture):
+        * UIProcess/gtk/GestureController.h:
+
 2015-10-29  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Use a persistent main loop source in RunLoop glib implementation

Modified: trunk/Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp (191786 => 191787)


--- trunk/Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp	2015-10-30 11:28:14 UTC (rev 191786)
+++ trunk/Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp	2015-10-30 12:12:09 UTC (rev 191787)
@@ -32,7 +32,7 @@
 #include <WebCore/NotImplemented.h>
 #include <WebCore/ResourceHandleInternal.h>
 #include <gio/gio.h>
-#include <wtf/glib/GMainLoopSource.h>
+#include <wtf/RunLoop.h>
 #include <wtf/glib/GRefPtr.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/text/CString.h>
@@ -50,6 +50,7 @@
 public:
     DownloadClient(Download* download)
         : m_download(download)
+        , m_handleResponseLater(RunLoop::main(), this, &DownloadClient::handleResponse)
         , m_allowOverwrite(false)
     {
     }
@@ -131,8 +132,8 @@
 
     void didReceiveData(ResourceHandle*, const char* data, unsigned length, int /*encodedDataLength*/)
     {
-        if (m_handleResponseLater.isScheduled()) {
-            m_handleResponseLater.cancel();
+        if (m_handleResponseLater.isActive()) {
+            m_handleResponseLater.stop();
             handleResponse();
         }
 
@@ -197,13 +198,13 @@
     void handleResponseLater(const ResourceResponse& response)
     {
         ASSERT(m_response.isNull());
-        ASSERT(!m_handleResponseLater.isScheduled());
+        ASSERT(!m_handleResponseLater.isActive());
 
         m_delayedResponse = response;
 
         // Call didReceiveResponse in an idle to make sure the download is added
         // to the DownloadManager downloads map.
-        m_handleResponseLater.schedule("[WebKit] DownloadHandleResponseLater", std::function<void()>(std::bind(&DownloadClient::handleResponse, this)));
+        m_handleResponseLater.startOneShot(0);
     }
 
     Download* m_download;
@@ -212,7 +213,7 @@
     GRefPtr<GFile> m_destinationFile;
     GRefPtr<GFile> m_intermediateFile;
     ResourceResponse m_delayedResponse;
-    GMainLoopSource m_handleResponseLater;
+    RunLoop::Timer<DownloadClient> m_handleResponseLater;
     bool m_allowOverwrite;
 };
 

Modified: trunk/Source/WebKit2/UIProcess/gtk/GestureController.cpp (191786 => 191787)


--- trunk/Source/WebKit2/UIProcess/gtk/GestureController.cpp	2015-10-30 11:28:14 UTC (rev 191786)
+++ trunk/Source/WebKit2/UIProcess/gtk/GestureController.cpp	2015-10-30 12:12:09 UTC (rev 191787)
@@ -127,9 +127,7 @@
     GtkWidget* widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture));
     unsigned delay;
     g_object_get(gtk_widget_get_settings(widget), "gtk-long-press-time", &delay, nullptr);
-    dragGesture->m_longPressTimeout.scheduleAfterDelay("[WebKit] DragGesture long press timeout", [dragGesture]() {
-        dragGesture->m_inDrag = true;
-    }, std::chrono::milliseconds(delay));
+    dragGesture->m_longPressTimeout.startOneShot(delay / 1000.0);
 }
 
 void GestureController::DragGesture::update(DragGesture* dragGesture, double x, double y, GtkGesture* gesture)
@@ -140,7 +138,7 @@
     GtkWidget* widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture));
     if (!dragGesture->m_inDrag && gtk_drag_check_threshold(widget, dragGesture->m_start.x(), dragGesture->m_start.y(), dragGesture->m_start.x() + x, dragGesture->m_start.y() + y)) {
         dragGesture->m_inDrag = true;
-        dragGesture->m_longPressTimeout.cancel();
+        dragGesture->m_longPressTimeout.stop();
     }
 
     if (dragGesture->m_inDrag)
@@ -150,7 +148,7 @@
 
 void GestureController::DragGesture::end(DragGesture* dragGesture, GdkEventSequence* sequence, GtkGesture* gesture)
 {
-    dragGesture->m_longPressTimeout.cancel();
+    dragGesture->m_longPressTimeout.stop();
     if (!dragGesture->m_inDrag) {
         dragGesture->handleTap(gtk_gesture_get_last_event(gesture, sequence));
         gtk_gesture_set_state(gesture, GTK_EVENT_SEQUENCE_DENIED);
@@ -158,8 +156,14 @@
         gtk_gesture_set_state(gesture, GTK_EVENT_SEQUENCE_DENIED);
 }
 
+void GestureController::DragGesture::longPressFired()
+{
+    m_inDrag = true;
+}
+
 GestureController::DragGesture::DragGesture(WebPageProxy& page)
     : Gesture(gtk_gesture_drag_new(page.viewWidget()), page)
+    , m_longPressTimeout(RunLoop::main(), this, &GestureController::DragGesture::longPressFired)
     , m_inDrag(false)
 {
     gtk_gesture_single_set_touch_only(GTK_GESTURE_SINGLE(m_gesture.get()), TRUE);
@@ -199,16 +203,17 @@
 {
     zoomGesture->m_scale = zoomGesture->m_initialScale * scale;
     zoomGesture->m_viewPoint = zoomGesture->center();
-    if (zoomGesture->m_idle.isScheduled())
+    if (zoomGesture->m_idle.isActive())
         return;
 
-    zoomGesture->m_idle.schedule("[WebKit] Zoom Gesture Idle", std::bind(&GestureController::ZoomGesture::handleZoom, zoomGesture));
+    zoomGesture->m_idle.startOneShot(0);
 }
 
 GestureController::ZoomGesture::ZoomGesture(WebPageProxy& page)
     : Gesture(gtk_gesture_zoom_new(page.viewWidget()), page)
     , m_initialScale(0)
     , m_scale(0)
+    , m_idle(RunLoop::main(), this, &GestureController::ZoomGesture::handleZoom)
 {
     g_signal_connect_swapped(m_gesture.get(), "begin", G_CALLBACK(begin), this);
     g_signal_connect_swapped(m_gesture.get(), "scale-changed", G_CALLBACK(scaleChanged), this);

Modified: trunk/Source/WebKit2/UIProcess/gtk/GestureController.h (191786 => 191787)


--- trunk/Source/WebKit2/UIProcess/gtk/GestureController.h	2015-10-30 11:28:14 UTC (rev 191786)
+++ trunk/Source/WebKit2/UIProcess/gtk/GestureController.h	2015-10-30 12:12:09 UTC (rev 191787)
@@ -30,7 +30,7 @@
 
 #include <WebCore/FloatPoint.h>
 #include <wtf/Noncopyable.h>
-#include <wtf/glib/GMainLoopSource.h>
+#include <wtf/RunLoop.h>
 #include <wtf/glib/GRefPtr.h>
 
 typedef union _GdkEvent GdkEvent;
@@ -69,6 +69,7 @@
     private:
         void handleDrag(const GdkEvent*, double x, double y);
         void handleTap(const GdkEvent*);
+        void longPressFired();
 
         static void begin(DragGesture*, double x, double y, GtkGesture*);
         static void update(DragGesture*, double x, double y, GtkGesture*);
@@ -76,7 +77,7 @@
 
         WebCore::FloatPoint m_start;
         WebCore::FloatPoint m_offset;
-        GMainLoopSource m_longPressTimeout;
+        RunLoop::Timer<DragGesture> m_longPressTimeout;
         GRefPtr<GtkGesture> m_longPress;
         bool m_inDrag;
     };
@@ -96,7 +97,7 @@
         gdouble m_scale;
         WebCore::IntPoint m_initialPoint;
         WebCore::IntPoint m_viewPoint;
-        GMainLoopSource m_idle;
+        RunLoop::Timer<ZoomGesture> m_idle;
     };
 
     DragGesture m_dragGesture;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to