Changeset 176120 in webkit


Ignore:
Timestamp:
Nov 14, 2014 1:21:48 AM (9 years ago)
Author:
Carlos Garcia Campos
Message:

[SOUP] Use GMainLoopSource for request timeout in ResourceHandle
https://bugs.webkit.org/show_bug.cgi?id=138695

Reviewed by Sergio Villar Senin.

We are currently using soup_timeout_add() that simply creates a
GSource and attaches it to the given context. Using
GMainLoopSource we simplify the code and fix any potential problem
of converting the double value into milliseconds.

  • platform/network/ResourceHandleInternal.h:
  • platform/network/soup/ResourceHandleSoup.cpp:

(WebCore::cleanupSoupRequestOperation):
(WebCore::ResourceHandle::sendPendingRequest):
(WebCore::ResourceHandle::platformSetDefersLoading):
(WebCore::requestTimeoutCallback): Deleted.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176115 r176120  
     12014-11-14  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [SOUP] Use GMainLoopSource for request timeout in ResourceHandle
     4        https://bugs.webkit.org/show_bug.cgi?id=138695
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        We are currently using soup_timeout_add() that simply creates a
     9        GSource and attaches it to the given context. Using
     10        GMainLoopSource we simplify the code and fix any potential problem
     11        of converting the double value into milliseconds.
     12
     13        * platform/network/ResourceHandleInternal.h:
     14        * platform/network/soup/ResourceHandleSoup.cpp:
     15        (WebCore::cleanupSoupRequestOperation):
     16        (WebCore::ResourceHandle::sendPendingRequest):
     17        (WebCore::ResourceHandle::platformSetDefersLoading):
     18        (WebCore::requestTimeoutCallback): Deleted.
     19
    1202014-11-13  Tim Horton  <timothy_horton@apple.com>
    221
  • trunk/Source/WebCore/platform/network/ResourceHandleInternal.h

    r175719 r176120  
    5252#include "GUniquePtrSoup.h"
    5353#include <libsoup/soup.h>
     54#include <wtf/gobject/GMainLoopSource.h>
    5455#include <wtf/gobject/GRefPtr.h>
    5556#endif
     
    197198        GRefPtr<GCancellable> m_cancellable;
    198199        GRefPtr<GAsyncResult> m_deferredResult;
    199         GRefPtr<GSource> m_timeoutSource;
     200        GMainLoopSource m_timeoutSource;
    200201        GUniquePtr<SoupBuffer> m_soupBuffer;
    201202        unsigned long m_bodySize;
  • trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r174394 r176120  
    232232static void sendRequestCallback(GObject*, GAsyncResult*, gpointer);
    233233static void readCallback(GObject*, GAsyncResult*, gpointer);
    234 static gboolean requestTimeoutCallback(void*);
    235234#if ENABLE(WEB_TIMING)
    236235static int  milisecondsSinceRequest(double requestTime);
     
    591590    }
    592591
    593     if (d->m_timeoutSource) {
    594         g_source_destroy(d->m_timeoutSource.get());
    595         d->m_timeoutSource.clear();
    596     }
     592    d->m_timeoutSource.cancel();
    597593
    598594    if (!isDestroying)
     
    10161012
    10171013    if (d->m_firstRequest.timeoutInterval() > 0) {
    1018         // soup_add_timeout returns a GSource* whose only reference is owned by
    1019         // the context. We need to have our own reference to it, hence not using adoptRef.
    1020         d->m_timeoutSource = soup_add_timeout(g_main_context_get_thread_default(),
    1021             d->m_firstRequest.timeoutInterval() * 1000, requestTimeoutCallback, this);
     1014        d->m_timeoutSource.scheduleAfterDelay("[WebKit] ResourceHandle request timeout", [this] {
     1015            client()->didFail(this, ResourceError::timeoutError(firstRequest().url().string()));
     1016            cancel();
     1017        }, std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(d->m_firstRequest.timeoutInterval())),
     1018        G_PRIORITY_DEFAULT, nullptr, g_main_context_get_thread_default());
    10221019    }
    10231020
     
    12241221    // Except when canceling a possible timeout timer, we only need to take action here to UN-defer loading.
    12251222    if (defersLoading) {
    1226         if (d->m_timeoutSource) {
    1227             g_source_destroy(d->m_timeoutSource.get());
    1228             d->m_timeoutSource.clear();
    1229         }
     1223        d->m_timeoutSource.cancel();
    12301224        return;
    12311225    }
     
    13461340}
    13471341
    1348 static gboolean requestTimeoutCallback(gpointer data)
    1349 {
    1350     RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);
    1351     handle->client()->didFail(handle.get(), ResourceError::timeoutError(handle->getInternal()->m_firstRequest.url().string()));
    1352     handle->cancel();
    1353 
    1354     return FALSE;
    1355 }
    1356 
    13571342}
    13581343
Note: See TracChangeset for help on using the changeset viewer.