<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277225] trunk/Source/WebKit</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277225">277225</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2021-05-08 03:43:06 -0700 (Sat, 08 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[SOUP] Use the new libsoup network metrics API
https://bugs.webkit.org/show_bug.cgi?id=225510

Reviewed by Michael Catanzaro.

Use the new API available in libsoup3. It provides more accurate information for time metrics and also size
metrics that were missing.

* NetworkProcess/soup/NetworkDataTaskSoup.cpp:
(WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup):
(WebKit::NetworkDataTaskSoup::createRequest):
(WebKit::NetworkDataTaskSoup::clearRequest):
(WebKit::NetworkDataTaskSoup::resume):
(WebKit::NetworkDataTaskSoup::didSendRequest):
(WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError):
(WebKit::NetworkDataTaskSoup::continueHTTPRedirection):
(WebKit::NetworkDataTaskSoup::didGetHeaders):
(WebKit::NetworkDataTaskSoup::wroteHeadersCallback):
(WebKit::NetworkDataTaskSoup::wroteBodyCallback):
(WebKit::NetworkDataTaskSoup::gotBodyCallback):
(WebKit::NetworkDataTaskSoup::networkEvent):
(WebKit::NetworkDataTaskSoup::didStartRequest):
(WebKit::NetworkDataTaskSoup::didRestart):
* NetworkProcess/soup/NetworkDataTaskSoup.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesssoupNetworkDataTaskSoupcpp">trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesssoupNetworkDataTaskSouph">trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (277224 => 277225)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-05-08 07:32:45 UTC (rev 277224)
+++ trunk/Source/WebKit/ChangeLog       2021-05-08 10:43:06 UTC (rev 277225)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2021-05-08  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [SOUP] Use the new libsoup network metrics API
+        https://bugs.webkit.org/show_bug.cgi?id=225510
+
+        Reviewed by Michael Catanzaro.
+
+        Use the new API available in libsoup3. It provides more accurate information for time metrics and also size
+        metrics that were missing.
+
+        * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
+        (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup):
+        (WebKit::NetworkDataTaskSoup::createRequest):
+        (WebKit::NetworkDataTaskSoup::clearRequest):
+        (WebKit::NetworkDataTaskSoup::resume):
+        (WebKit::NetworkDataTaskSoup::didSendRequest):
+        (WebKit::NetworkDataTaskSoup::dispatchDidCompleteWithError):
+        (WebKit::NetworkDataTaskSoup::continueHTTPRedirection):
+        (WebKit::NetworkDataTaskSoup::didGetHeaders):
+        (WebKit::NetworkDataTaskSoup::wroteHeadersCallback):
+        (WebKit::NetworkDataTaskSoup::wroteBodyCallback):
+        (WebKit::NetworkDataTaskSoup::gotBodyCallback):
+        (WebKit::NetworkDataTaskSoup::networkEvent):
+        (WebKit::NetworkDataTaskSoup::didStartRequest):
+        (WebKit::NetworkDataTaskSoup::didRestart):
+        * NetworkProcess/soup/NetworkDataTaskSoup.h:
+
</ins><span class="cx"> 2021-05-07  Brent Fulgham  <bfulgham@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] [GPU] Silence warning about com.apple.audio.AudioComponentRegistrar in the WebContent process
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesssoupNetworkDataTaskSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp (277224 => 277225)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp  2021-05-08 07:32:45 UTC (rev 277224)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp     2021-05-08 10:43:06 UTC (rev 277225)
</span><span class="lines">@@ -65,7 +65,9 @@
</span><span class="cx"> 
</span><span class="cx">     auto request = requestWithCredentials;
</span><span class="cx">     if (request.url().protocolIsInHTTPFamily()) {
</span><ins>+#if USE(SOUP2)
</ins><span class="cx">         m_networkLoadMetrics.fetchStart = MonotonicTime::now().secondsSinceEpoch();
</span><ins>+#endif
</ins><span class="cx">         auto url = request.url();
</span><span class="cx">         if (m_storedCredentialsPolicy == StoredCredentialsPolicy::Use) {
</span><span class="cx">             m_user = url.user();
</span><span class="lines">@@ -139,6 +141,9 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     unsigned messageFlags = SOUP_MESSAGE_NO_REDIRECT;
</span><ins>+#if !USE(SOUP2)
+    messageFlags |= SOUP_MESSAGE_COLLECT_METRICS;
+#endif
</ins><span class="cx">     if (m_shouldContentSniff == ContentSniffingPolicy::DoNotSniffContent)
</span><span class="cx">         soup_message_disable_feature(m_soupMessage.get(), SOUP_TYPE_CONTENT_SNIFFER);
</span><span class="cx">     if (m_user.isEmpty() && m_password.isEmpty() && m_storedCredentialsPolicy == StoredCredentialsPolicy::DoNotUse) {
</span><span class="lines">@@ -192,11 +197,16 @@
</span><span class="cx">     g_signal_connect(m_soupMessage.get(), "wrote-body-data", G_CALLBACK(wroteBodyDataCallback), this);
</span><span class="cx"> #if USE(SOUP2)
</span><span class="cx">     g_signal_connect(static_cast<NetworkSessionSoup&>(*m_session).soupSession(), "authenticate",  G_CALLBACK(authenticateCallback), this);
</span><ins>+    g_signal_connect(m_soupMessage.get(), "network-event", G_CALLBACK(networkEventCallback), this);
</ins><span class="cx"> #else
</span><span class="cx">     g_signal_connect(m_soupMessage.get(), "authenticate", G_CALLBACK(authenticateCallback), this);
</span><span class="cx">     g_signal_connect(m_soupMessage.get(), "accept-certificate", G_CALLBACK(acceptCertificateCallback), this);
</span><ins>+    if (shouldCaptureExtraNetworkLoadMetrics()) {
+        g_signal_connect(m_soupMessage.get(), "wrote-headers", G_CALLBACK(wroteHeadersCallback), this);
+        g_signal_connect(m_soupMessage.get(), "wrote-body", G_CALLBACK(wroteBodyCallback), this);
+        g_signal_connect(m_soupMessage.get(), "got-body", G_CALLBACK(gotBodyCallback), this);
+    }
</ins><span class="cx"> #endif
</span><del>-    g_signal_connect(m_soupMessage.get(), "network-event", G_CALLBACK(networkEventCallback), this);
</del><span class="cx">     g_signal_connect(m_soupMessage.get(), "restarted", G_CALLBACK(restartedCallback), this);
</span><span class="cx">     g_signal_connect(m_soupMessage.get(), "starting", G_CALLBACK(startingCallback), this);
</span><span class="cx">     if (m_shouldContentSniff == ContentSniffingPolicy::SniffContent)
</span><span class="lines">@@ -226,6 +236,13 @@
</span><span class="cx"> #if USE(SOUP2)
</span><span class="cx">         if (m_session)
</span><span class="cx">             soup_session_cancel_message(static_cast<NetworkSessionSoup&>(*m_session).soupSession(), m_soupMessage.get(), SOUP_STATUS_CANCELLED);
</span><ins>+#else
+        if (m_networkLoadMetrics.fetchStart && !m_networkLoadMetrics.responseEnd) {
+            auto* metrics = soup_message_get_metrics(m_soupMessage.get());
+            auto responseEnd = Seconds::fromMicroseconds(soup_message_metrics_get_response_end(metrics));
+            m_networkLoadMetrics.responseEnd = responseEnd ? responseEnd - m_networkLoadMetrics.fetchStart : Seconds(-1);
+            m_networkLoadMetrics.markComplete();
+        }
</ins><span class="cx"> #endif
</span><span class="cx">         m_soupMessage = nullptr;
</span><span class="cx">     }
</span><span class="lines">@@ -265,6 +282,12 @@
</span><span class="cx">             GRefPtr<GCancellable> protectCancellable(m_cancellable);
</span><span class="cx">             soup_session_send_async(static_cast<NetworkSessionSoup&>(*m_session).soupSession(), m_soupMessage.get(), RunLoopSourcePriority::AsyncIONetwork, m_cancellable.get(),
</span><span class="cx">                 reinterpret_cast<GAsyncReadyCallback>(sendRequestCallback), new SendRequestData({ m_soupMessage, WTFMove(protectedThis) }));
</span><ins>+#if !USE(SOUP2)
+            if (!g_cancellable_is_cancelled(protectCancellable.get()) && !m_networkLoadMetrics.fetchStart) {
+                auto* metrics = soup_message_get_metrics(m_soupMessage.get());
+                m_networkLoadMetrics.fetchStart = Seconds::fromMicroseconds(soup_message_metrics_get_fetch_start(metrics));
+            }
+#endif
</ins><span class="cx">         }
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -420,7 +443,9 @@
</span><span class="cx">     else
</span><span class="cx">         m_inputStream = WTFMove(inputStream);
</span><span class="cx"> 
</span><ins>+#if USE(SOUP2)
</ins><span class="cx">     m_networkLoadMetrics.responseStart = MonotonicTime::now().secondsSinceEpoch() - m_networkLoadMetrics.fetchStart;
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: This cannot be eliminated until other code no longer relies on ResourceResponse's NetworkLoadMetrics.
</span><span class="cx">     m_response.setDeprecatedNetworkLoadMetrics(Box<NetworkLoadMetrics>::create(m_networkLoadMetrics));
</span><span class="lines">@@ -480,8 +505,10 @@
</span><span class="cx"> 
</span><span class="cx"> void NetworkDataTaskSoup::dispatchDidCompleteWithError(const ResourceError& error)
</span><span class="cx"> {
</span><ins>+#if USE(SOUP2)
</ins><span class="cx">     m_networkLoadMetrics.responseEnd = MonotonicTime::now().secondsSinceEpoch() - m_networkLoadMetrics.fetchStart;
</span><span class="cx">     m_networkLoadMetrics.markComplete();
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     m_client->didCompleteWithError(error, m_networkLoadMetrics);
</span><span class="cx"> }
</span><span class="lines">@@ -850,7 +877,14 @@
</span><span class="cx">         if (request.url().protocolIsInHTTPFamily()) {
</span><span class="cx">             if (isCrossOrigin) {
</span><span class="cx">                 m_networkLoadMetrics = { };
</span><ins>+#if USE(SOUP2)
</ins><span class="cx">                 m_networkLoadMetrics.fetchStart = MonotonicTime::now().secondsSinceEpoch();
</span><ins>+#endif
+            } else {
+#if !USE(SOUP2)
+                m_networkLoadMetrics.responseEnd = { };
+                m_networkLoadMetrics.complete = false;
+#endif
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             applyAuthenticationToRequest(request);
</span><span class="lines">@@ -1048,6 +1082,12 @@
</span><span class="cx">         m_credentialForPersistentStorage = Credential();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if !USE(SOUP2)
+    auto* metrics = soup_message_get_metrics(m_soupMessage.get());
+    auto responseStart = Seconds::fromMicroseconds(soup_message_metrics_get_response_start(metrics));
+    m_networkLoadMetrics.responseStart = responseStart - m_networkLoadMetrics.fetchStart;
+#endif
+
</ins><span class="cx">     // Soup adds more headers to the request after starting signal is emitted, and got-headers
</span><span class="cx">     // is the first one we receive after starting, so we use it also to get information about the
</span><span class="cx">     // request headers.
</span><span class="lines">@@ -1062,8 +1102,14 @@
</span><span class="cx">         m_networkLoadMetrics.requestHeaders = WTFMove(requestHeaders);
</span><span class="cx"> 
</span><span class="cx">         m_networkLoadMetrics.priority = toNetworkLoadPriority(soup_message_get_priority(m_soupMessage.get()));
</span><del>-#if SOUP_CHECK_VERSION(2, 99, 4)
</del><ins>+#if !USE(SOUP2)
</ins><span class="cx">         m_networkLoadMetrics.connectionIdentifier = String::number(soup_message_get_connection_id(m_soupMessage.get()));
</span><ins>+        auto* address = soup_message_get_remote_address(m_soupMessage.get());
+        if (G_IS_INET_SOCKET_ADDRESS(address)) {
+            GUniquePtr<char> ipAddress(g_inet_address_to_string(g_inet_socket_address_get_address(G_INET_SOCKET_ADDRESS(address))));
+            m_networkLoadMetrics.remoteAddress = makeString(ipAddress.get(), ':', g_inet_socket_address_get_port(G_INET_SOCKET_ADDRESS(address)));
+        }
+        m_networkLoadMetrics.responseHeaderBytesReceived = soup_message_metrics_get_response_header_bytes_received(metrics);
</ins><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1070,6 +1116,42 @@
</span><span class="cx">     m_networkLoadMetrics.protocol = soupHTTPVersionToString(soup_message_get_http_version(m_soupMessage.get()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if !USE(SOUP2)
+void NetworkDataTaskSoup::wroteHeadersCallback(SoupMessage* soupMessage, NetworkDataTaskSoup* task)
+{
+    if (task->state() == State::Canceling || task->state() == State::Completed || !task->m_client) {
+        task->clearRequest();
+        return;
+    }
+    ASSERT(task->m_soupMessage.get() == soupMessage);
+    auto* metrics = soup_message_get_metrics(soupMessage);
+    task->m_networkLoadMetrics.requestHeaderBytesSent = soup_message_metrics_get_request_header_bytes_sent(metrics);
+}
+
+void NetworkDataTaskSoup::wroteBodyCallback(SoupMessage* soupMessage, NetworkDataTaskSoup* task)
+{
+    if (task->state() == State::Canceling || task->state() == State::Completed || !task->m_client) {
+        task->clearRequest();
+        return;
+    }
+    ASSERT(task->m_soupMessage.get() == soupMessage);
+    auto* metrics = soup_message_get_metrics(soupMessage);
+    task->m_networkLoadMetrics.requestBodyBytesSent = soup_message_metrics_get_request_body_bytes_sent(metrics);
+}
+
+void NetworkDataTaskSoup::gotBodyCallback(SoupMessage* soupMessage, NetworkDataTaskSoup* task)
+{
+    if (task->state() == State::Canceling || task->state() == State::Completed || !task->m_client) {
+        task->clearRequest();
+        return;
+    }
+    ASSERT(task->m_soupMessage.get() == soupMessage);
+    auto* metrics = soup_message_get_metrics(soupMessage);
+    task->m_networkLoadMetrics.responseBodyBytesReceived = soup_message_metrics_get_response_body_bytes_received(metrics);
+    task->m_networkLoadMetrics.responseBodyDecodedSize = soup_message_metrics_get_response_body_size(metrics);
+}
+#endif
+
</ins><span class="cx"> #if USE(SOUP2)
</span><span class="cx"> void NetworkDataTaskSoup::wroteBodyDataCallback(SoupMessage* soupMessage, SoupBuffer* buffer, NetworkDataTaskSoup* task)
</span><span class="cx"> #else
</span><span class="lines">@@ -1240,6 +1322,7 @@
</span><span class="cx">     dispatchDidCompleteWithError(error);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(SOUP2)
</ins><span class="cx"> void NetworkDataTaskSoup::networkEventCallback(SoupMessage* soupMessage, GSocketClientEvent event, GIOStream* stream, NetworkDataTaskSoup* task)
</span><span class="cx"> {
</span><span class="cx">     if (task->state() == State::Canceling || task->state() == State::Completed || !task->m_client)
</span><span class="lines">@@ -1279,11 +1362,9 @@
</span><span class="cx">         break;
</span><span class="cx">     case G_SOCKET_CLIENT_TLS_HANDSHAKING:
</span><span class="cx">         m_networkLoadMetrics.secureConnectionStart = deltaTime;
</span><del>-#if USE(SOUP2)
</del><span class="cx">         RELEASE_ASSERT(G_IS_TLS_CONNECTION(stream));
</span><span class="cx">         g_object_set_data(G_OBJECT(stream), "wk-soup-message", m_soupMessage.get());
</span><span class="cx">         g_signal_connect(stream, "accept-certificate", G_CALLBACK(tlsConnectionAcceptCertificateCallback), this);
</span><del>-#endif
</del><span class="cx">         break;
</span><span class="cx">     case G_SOCKET_CLIENT_TLS_HANDSHAKED:
</span><span class="cx">         break;
</span><span class="lines">@@ -1295,6 +1376,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> void NetworkDataTaskSoup::startingCallback(SoupMessage* soupMessage, NetworkDataTaskSoup* task)
</span><span class="cx"> {
</span><span class="lines">@@ -1349,7 +1431,24 @@
</span><span class="cx"> 
</span><span class="cx"> void NetworkDataTaskSoup::didStartRequest()
</span><span class="cx"> {
</span><ins>+#if USE(SOUP2)
</ins><span class="cx">     m_networkLoadMetrics.requestStart = MonotonicTime::now().secondsSinceEpoch() - m_networkLoadMetrics.fetchStart;
</span><ins>+#else
+    auto* metrics = soup_message_get_metrics(m_soupMessage.get());
+    auto domainLookupStart = Seconds::fromMicroseconds(soup_message_metrics_get_dns_start(metrics));
+    auto domainLookupEnd = Seconds::fromMicroseconds(soup_message_metrics_get_dns_end(metrics));
+    auto connectStart = Seconds::fromMicroseconds(soup_message_metrics_get_connect_start(metrics));
+    auto connectEnd = Seconds::fromMicroseconds(soup_message_metrics_get_connect_end(metrics));
+    auto secureConnectionStart = Seconds::fromMicroseconds(soup_message_metrics_get_tls_start(metrics));
+    auto requestStart = Seconds::fromMicroseconds(soup_message_metrics_get_request_start(metrics));
+
+    m_networkLoadMetrics.domainLookupStart = domainLookupStart ? domainLookupStart - m_networkLoadMetrics.fetchStart : Seconds(-1);
+    m_networkLoadMetrics.domainLookupEnd = domainLookupEnd ? domainLookupEnd - m_networkLoadMetrics.fetchStart : Seconds(-1);
+    m_networkLoadMetrics.connectStart = connectStart ? connectStart - m_networkLoadMetrics.fetchStart : Seconds(-1);
+    m_networkLoadMetrics.connectEnd = connectEnd ? connectEnd - m_networkLoadMetrics.fetchStart : Seconds(-1);
+    m_networkLoadMetrics.secureConnectionStart = secureConnectionStart ? secureConnectionStart - m_networkLoadMetrics.fetchStart : Seconds(-1);
+    m_networkLoadMetrics.requestStart = requestStart - m_networkLoadMetrics.fetchStart;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void NetworkDataTaskSoup::restartedCallback(SoupMessage* soupMessage, NetworkDataTaskSoup* task)
</span><span class="lines">@@ -1366,8 +1465,11 @@
</span><span class="cx"> void NetworkDataTaskSoup::didRestart()
</span><span class="cx"> {
</span><span class="cx">     m_networkLoadMetrics = { };
</span><ins>+#if USE(SOUP2)
</ins><span class="cx">     m_networkLoadMetrics.fetchStart = MonotonicTime::now().secondsSinceEpoch();
</span><del>-#if !USE(SOUP2)
</del><ins>+#else
+    auto* metrics = soup_message_get_metrics(m_soupMessage.get());
+    m_networkLoadMetrics.fetchStart = Seconds::fromMicroseconds(soup_message_metrics_get_fetch_start(metrics));
</ins><span class="cx">     m_currentRequest.updateSoupMessageBody(m_soupMessage.get(), m_session->blobRegistry());
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesssoupNetworkDataTaskSouph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h (277224 => 277225)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h    2021-05-08 07:32:45 UTC (rev 277224)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h       2021-05-08 10:43:06 UTC (rev 277225)
</span><span class="lines">@@ -127,6 +127,12 @@
</span><span class="cx"> #endif
</span><span class="cx">     void didWriteBodyData(uint64_t bytesSent);
</span><span class="cx"> 
</span><ins>+#if !USE(SOUP2)
+    static void wroteHeadersCallback(SoupMessage*, NetworkDataTaskSoup*);
+    static void wroteBodyCallback(SoupMessage*, NetworkDataTaskSoup*);
+    static void gotBodyCallback(SoupMessage*, NetworkDataTaskSoup*);
+#endif
+
</ins><span class="cx">     void download();
</span><span class="cx">     static void writeDownloadCallback(GOutputStream*, GAsyncResult*, NetworkDataTaskSoup*);
</span><span class="cx">     void writeDownload();
</span><span class="lines">@@ -137,8 +143,11 @@
</span><span class="cx"> 
</span><span class="cx">     void didFail(const WebCore::ResourceError&);
</span><span class="cx"> 
</span><ins>+#if USE(SOUP2)
</ins><span class="cx">     static void networkEventCallback(SoupMessage*, GSocketClientEvent, GIOStream*, NetworkDataTaskSoup*);
</span><span class="cx">     void networkEvent(GSocketClientEvent, GIOStream*);
</span><ins>+#endif
+
</ins><span class="cx"> #if SOUP_CHECK_VERSION(2, 49, 91)
</span><span class="cx">     static void startingCallback(SoupMessage*, NetworkDataTaskSoup*);
</span><span class="cx"> #else
</span></span></pre>
</div>
</div>

</body>
</html>