[SOUP] Use SoupMessage::starting instead of SoupSession::request-started
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Mar 2015 10:24:47 +0000 (10:24 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Mar 2015 10:24:47 +0000 (10:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142164

Reviewed by Sergio Villar Senin.

SoupSession::request-started is deprecated in libsoup 2.50. Both
signals are equivalent, but SoupMessage::starting is also emitted
for resources loaded from the disk cache. This fixes web timing
calculations for cached resources, since we were not initializing
m_requestStart.

* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::startingCallback):
(WebCore::createSoupMessageForHandleAndRequest):
* platform/network/soup/SoupNetworkSession.cpp:
(WebCore::SoupNetworkSession::SoupNetworkSession):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180928 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
Source/WebCore/platform/network/soup/SoupNetworkSession.cpp

index e2809ac..cdcddb5 100644 (file)
@@ -1,3 +1,22 @@
+2015-03-02  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [SOUP] Use SoupMessage::starting instead of SoupSession::request-started
+        https://bugs.webkit.org/show_bug.cgi?id=142164
+
+        Reviewed by Sergio Villar Senin.
+
+        SoupSession::request-started is deprecated in libsoup 2.50. Both
+        signals are equivalent, but SoupMessage::starting is also emitted
+        for resources loaded from the disk cache. This fixes web timing
+        calculations for cached resources, since we were not initializing
+        m_requestStart.
+
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::startingCallback):
+        (WebCore::createSoupMessageForHandleAndRequest):
+        * platform/network/soup/SoupNetworkSession.cpp:
+        (WebCore::SoupNetworkSession::SoupNetworkSession):
+
 2015-03-03  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [SOUP] Synchronous XMLHttpRequests can time out when we reach the max connections limit
index d599109..278aac5 100644 (file)
@@ -833,6 +833,13 @@ void ResourceHandle::didStartRequest()
     getInternal()->m_response.resourceLoadTiming().requestStart = milisecondsSinceRequest(m_requestTime);
 }
 
+#if SOUP_CHECK_VERSION(2, 49, 91)
+static void startingCallback(SoupMessage*, ResourceHandle* handle)
+{
+    handle->didStartRequest();
+}
+#endif // SOUP_CHECK_VERSION(2, 49, 91)
+
 static void networkEventCallback(SoupMessage*, GSocketClientEvent event, GIOStream*, gpointer data)
 {
     ResourceHandle* handle = static_cast<ResourceHandle*>(data);
@@ -940,6 +947,9 @@ static bool createSoupMessageForHandleAndRequest(ResourceHandle* handle, const R
     soup_message_set_flags(d->m_soupMessage.get(), static_cast<SoupMessageFlags>(soup_message_get_flags(d->m_soupMessage.get()) | flags));
 
 #if ENABLE(WEB_TIMING)
+#if SOUP_CHECK_VERSION(2, 49, 91)
+    g_signal_connect(d->m_soupMessage.get(), "starting", G_CALLBACK(startingCallback), handle);
+#endif
     g_signal_connect(d->m_soupMessage.get(), "network-event", G_CALLBACK(networkEventCallback), handle);
     g_signal_connect(d->m_soupMessage.get(), "restarted", G_CALLBACK(restartedCallback), handle);
 #endif
index 53c928f..8e5dd9c 100644 (file)
@@ -81,7 +81,7 @@ static void authenticateCallback(SoupSession* session, SoupMessage* soupMessage,
     handle->didReceiveAuthenticationChallenge(AuthenticationChallenge(session, soupMessage, soupAuth, retrying, handle.get()));
 }
 
-#if ENABLE(WEB_TIMING)
+#if ENABLE(WEB_TIMING) && !SOUP_CHECK_VERSION(2, 49, 91)
 static void requestStartedCallback(SoupSession*, SoupMessage* soupMessage, SoupSocket*, gpointer)
 {
     RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(g_object_get_data(G_OBJECT(soupMessage), "handle"));
@@ -114,7 +114,7 @@ SoupNetworkSession::SoupNetworkSession(SoupCookieJar* cookieJar)
     setupLogger();
 
     g_signal_connect(m_soupSession.get(), "authenticate", G_CALLBACK(authenticateCallback), nullptr);
-#if ENABLE(WEB_TIMING)
+#if ENABLE(WEB_TIMING) && !SOUP_CHECK_VERSION(2, 49, 91)
     g_signal_connect(m_soupSession.get(), "request-started", G_CALLBACK(requestStartedCallback), nullptr);
 #endif
 }