[curl] Remove member objects of CurlRequest not to share by different threads.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jun 2019 14:06:18 +0000 (14:06 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jun 2019 14:06:18 +0000 (14:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198747

Patch by Takashi Komori <Takashi.Komori@sony.com> on 2019-06-13
Reviewed by Fujii Hironori.

Source/WebCore:

Removed m_certificateInfo and m_networkLoadMetrics.
Before patch those objects were updated by different threads.

No tests needed, no functionality changes.

* platform/network/curl/CurlDownload.cpp:
(WebCore::CurlDownload::curlDidReceiveResponse):
(WebCore::CurlDownload::curlDidReceiveBuffer):
(WebCore::CurlDownload::curlDidComplete):
(WebCore::CurlDownload::curlDidFailWithError):
* platform/network/curl/CurlDownload.h:
* platform/network/curl/CurlRequest.cpp:
(WebCore::CurlRequest::start):
(WebCore::CurlRequest::didReceiveHeader):
(WebCore::CurlRequest::didCompleteTransfer):
(WebCore::CurlRequest::invokeDidReceiveResponse):
(WebCore::CurlRequest::networkLoadMetrics):
(WebCore::CurlRequest::updateNetworkLoadMetrics): Deleted.
* platform/network/curl/CurlRequest.h:
(WebCore::CurlRequest::setStartTime):
(WebCore::CurlRequest::certificateInfo const): Deleted.
(WebCore::CurlRequest::networkLoadMetrics const): Deleted.
* platform/network/curl/CurlRequestClient.h:
* platform/network/curl/CurlResourceHandleDelegate.cpp:
(WebCore::CurlResourceHandleDelegate::curlDidSendData):
(WebCore::CurlResourceHandleDelegate::curlDidReceiveResponse):
(WebCore::CurlResourceHandleDelegate::curlDidReceiveBuffer):
(WebCore::CurlResourceHandleDelegate::curlDidComplete):
(WebCore::CurlResourceHandleDelegate::curlDidFailWithError):
* platform/network/curl/CurlResourceHandleDelegate.h:
* platform/network/curl/CurlResponse.h:
(WebCore::CurlResponse::isolatedCopy const):
* platform/network/curl/ResourceResponseCurl.cpp:
(WebCore::ResourceResponse::ResourceResponse):

Source/WebKit:

* NetworkProcess/curl/NetworkDataTaskCurl.cpp:
(WebKit::NetworkDataTaskCurl::curlDidReceiveResponse):
(WebKit::NetworkDataTaskCurl::curlDidComplete):
(WebKit::NetworkDataTaskCurl::curlDidFailWithError):
* NetworkProcess/curl/NetworkDataTaskCurl.h:

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/network/curl/CurlDownload.cpp
Source/WebCore/platform/network/curl/CurlDownload.h
Source/WebCore/platform/network/curl/CurlRequest.cpp
Source/WebCore/platform/network/curl/CurlRequest.h
Source/WebCore/platform/network/curl/CurlRequestClient.h
Source/WebCore/platform/network/curl/CurlResourceHandleDelegate.cpp
Source/WebCore/platform/network/curl/CurlResourceHandleDelegate.h
Source/WebCore/platform/network/curl/CurlResponse.h
Source/WebCore/platform/network/curl/ResourceResponseCurl.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp
Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h

index 7a38ddc..4ff3a5c 100644 (file)
@@ -1,3 +1,45 @@
+2019-06-13  Takashi Komori  <Takashi.Komori@sony.com>
+
+        [curl] Remove member objects of CurlRequest not to share by different threads.
+        https://bugs.webkit.org/show_bug.cgi?id=198747
+
+        Reviewed by Fujii Hironori.
+
+        Removed m_certificateInfo and m_networkLoadMetrics.
+        Before patch those objects were updated by different threads.
+
+        No tests needed, no functionality changes.
+
+        * platform/network/curl/CurlDownload.cpp:
+        (WebCore::CurlDownload::curlDidReceiveResponse):
+        (WebCore::CurlDownload::curlDidReceiveBuffer):
+        (WebCore::CurlDownload::curlDidComplete):
+        (WebCore::CurlDownload::curlDidFailWithError):
+        * platform/network/curl/CurlDownload.h:
+        * platform/network/curl/CurlRequest.cpp:
+        (WebCore::CurlRequest::start):
+        (WebCore::CurlRequest::didReceiveHeader):
+        (WebCore::CurlRequest::didCompleteTransfer):
+        (WebCore::CurlRequest::invokeDidReceiveResponse):
+        (WebCore::CurlRequest::networkLoadMetrics):
+        (WebCore::CurlRequest::updateNetworkLoadMetrics): Deleted.
+        * platform/network/curl/CurlRequest.h:
+        (WebCore::CurlRequest::setStartTime):
+        (WebCore::CurlRequest::certificateInfo const): Deleted.
+        (WebCore::CurlRequest::networkLoadMetrics const): Deleted.
+        * platform/network/curl/CurlRequestClient.h:
+        * platform/network/curl/CurlResourceHandleDelegate.cpp:
+        (WebCore::CurlResourceHandleDelegate::curlDidSendData):
+        (WebCore::CurlResourceHandleDelegate::curlDidReceiveResponse):
+        (WebCore::CurlResourceHandleDelegate::curlDidReceiveBuffer):
+        (WebCore::CurlResourceHandleDelegate::curlDidComplete):
+        (WebCore::CurlResourceHandleDelegate::curlDidFailWithError):
+        * platform/network/curl/CurlResourceHandleDelegate.h:
+        * platform/network/curl/CurlResponse.h:
+        (WebCore::CurlResponse::isolatedCopy const):
+        * platform/network/curl/ResourceResponseCurl.cpp:
+        (WebCore::ResourceResponse::ResourceResponse):
+
 2019-06-13  Zan Dobersek  <zdobersek@igalia.com>
 
         [Nicosia] Add SceneIntegration
index 186420a..1ace246 100644 (file)
@@ -80,7 +80,7 @@ Ref<CurlRequest> CurlDownload::createCurlRequest(ResourceRequest& request)
     return curlRequest;
 }
 
-void CurlDownload::curlDidReceiveResponse(CurlRequest& request, const CurlResponse& response)
+void CurlDownload::curlDidReceiveResponse(CurlRequest& request, CurlResponse&& response)
 {
     ASSERT(isMainThread());
 
@@ -101,7 +101,7 @@ void CurlDownload::curlDidReceiveResponse(CurlRequest& request, const CurlRespon
 }
 
 
-void CurlDownload::curlDidReceiveBuffer(CurlRequest& request, Ref<SharedBuffer>&& buffer)
+void CurlDownload::curlDidReceiveBuffer(CurlRequest&, Ref<SharedBuffer>&& buffer)
 {
     ASSERT(isMainThread());
 
@@ -112,7 +112,7 @@ void CurlDownload::curlDidReceiveBuffer(CurlRequest& request, Ref<SharedBuffer>&
         m_listener->didReceiveDataOfLength(buffer->size());
 }
 
-void CurlDownload::curlDidComplete(CurlRequest& request)
+void CurlDownload::curlDidComplete(CurlRequest& request, NetworkLoadMetrics&&)
 {
     ASSERT(isMainThread());
 
@@ -128,7 +128,7 @@ void CurlDownload::curlDidComplete(CurlRequest& request)
         m_listener->didFinish();
 }
 
-void CurlDownload::curlDidFailWithError(CurlRequest& request, const ResourceError& resourceError)
+void CurlDownload::curlDidFailWithError(CurlRequest& request, ResourceError&&, CertificateInfo&&)
 {
     ASSERT(isMainThread());
 
index a739dfa..a3aa0cf 100644 (file)
@@ -71,10 +71,10 @@ public:
 private:
     Ref<CurlRequest> createCurlRequest(ResourceRequest&);
     void curlDidSendData(CurlRequest&, unsigned long long, unsigned long long) override { }
-    void curlDidReceiveResponse(CurlRequest&, const CurlResponse&) override;
+    void curlDidReceiveResponse(CurlRequest&, CurlResponse&&) override;
     void curlDidReceiveBuffer(CurlRequest&, Ref<SharedBuffer>&&) override;
-    void curlDidComplete(CurlRequest&) override;
-    void curlDidFailWithError(CurlRequest&, const ResourceError&) override;
+    void curlDidComplete(CurlRequest&, NetworkLoadMetrics&&) override;
+    void curlDidFailWithError(CurlRequest&, ResourceError&&, CertificateInfo&&) override;
 
     bool shouldRedirectAsGET(const ResourceRequest&, bool crossOrigin);
     void willSendRequest();
index 7da5995..1cd8ebd 100644 (file)
 
 #if USE(CURL)
 
+#include "CertificateInfo.h"
 #include "CurlRequestClient.h"
 #include "CurlRequestScheduler.h"
 #include "MIMETypeRegistry.h"
+#include "NetworkLoadMetrics.h"
 #include "ResourceError.h"
 #include "SharedBuffer.h"
 #include <wtf/Language.h>
@@ -107,7 +109,7 @@ void CurlRequest::start()
     auto url = m_request.url().isolatedCopy();
 
     if (std::isnan(m_requestStartTime))
-        m_requestStartTime = MonotonicTime::now();
+        m_requestStartTime = MonotonicTime::now().isolatedCopy();
 
     if (url.isLocalFile())
         invokeDidReceiveResponseForFile(url);
@@ -350,13 +352,13 @@ size_t CurlRequest::didReceiveHeader(String&& header)
     if (auto version = m_curlHandle->getHttpVersion())
         m_response.httpVersion = *version;
 
-    updateNetworkLoadMetrics();
-
     if (m_response.availableProxyAuth)
         CurlContext::singleton().setProxyAuthMethod(m_response.availableProxyAuth);
 
     if (auto info = m_curlHandle->certificateInfo())
-        m_certificateInfo = *info;
+        m_response.certificateInfo = WTFMove(*info);
+
+    m_response.networkLoadMetrics = networkLoadMetrics();
 
     if (m_enableMultipart)
         m_multipartHandle = CurlMultipartHandle::createIfNeeded(*this, m_response);
@@ -451,26 +453,28 @@ void CurlRequest::didCompleteTransfer(CURLcode result)
         if (m_multipartHandle)
             m_multipartHandle->didComplete();
 
-        updateNetworkLoadMetrics();
+        auto metrics = networkLoadMetrics();
 
         finalizeTransfer();
-        callClient([this, protectedThis = makeRef(*this)](CurlRequest& request, CurlRequestClient& client) {
-            m_networkLoadMetrics.responseEnd = MonotonicTime::now() - m_requestStartTime;
-            m_networkLoadMetrics.markComplete();
+        callClient([requestStartTime = m_requestStartTime.isolatedCopy(), networkLoadMetrics = WTFMove(metrics)](CurlRequest& request, CurlRequestClient& client) mutable {
+            networkLoadMetrics.responseEnd = MonotonicTime::now() - requestStartTime;
+            networkLoadMetrics.markComplete();
 
-            client.curlDidComplete(request);
+            client.curlDidComplete(request, WTFMove(networkLoadMetrics));
         });
     } else {
         auto type = (result == CURLE_OPERATION_TIMEDOUT && timeoutInterval()) ? ResourceError::Type::Timeout : ResourceError::Type::General;
         auto resourceError = ResourceError::httpError(result, m_request.url(), type);
         if (auto sslErrors = m_curlHandle->sslErrors())
             resourceError.setSslErrors(sslErrors);
+
+        CertificateInfo certificateInfo;
         if (auto info = m_curlHandle->certificateInfo())
-            m_certificateInfo = *info;
+            certificateInfo = WTFMove(*info);
 
         finalizeTransfer();
-        callClient([error = resourceError.isolatedCopy()](CurlRequest& request, CurlRequestClient& client) {
-            client.curlDidFailWithError(request, error);
+        callClient([error = WTFMove(resourceError), certificateInfo = WTFMove(certificateInfo)](CurlRequest& request, CurlRequestClient& client) mutable {
+            client.curlDidFailWithError(request, WTFMove(error), WTFMove(certificateInfo));
         });
     }
 
@@ -604,8 +608,9 @@ void CurlRequest::invokeDidReceiveResponse(const CurlResponse& response, Action
     m_didNotifyResponse = true;
     m_actionAfterInvoke = behaviorAfterInvoke;
 
-    callClient([response = response.isolatedCopy()](CurlRequest& request, CurlRequestClient& client) {
-        client.curlDidReceiveResponse(request, response);
+    // FIXME: Replace this isolatedCopy with WTFMove.
+    callClient([response = response.isolatedCopy()](CurlRequest& request, CurlRequestClient& client) mutable {
+        client.curlDidReceiveResponse(request, WTFMove(response));
     });
 }
 
@@ -715,19 +720,22 @@ bool CurlRequest::isHandlePaused() const
     return m_isHandlePaused;
 }
 
-void CurlRequest::updateNetworkLoadMetrics()
+NetworkLoadMetrics CurlRequest::networkLoadMetrics()
 {
-    auto domainLookupStart = m_performStartTime - m_requestStartTime;
+    ASSERT(m_curlHandle);
 
-    if (auto metrics = m_curlHandle->getNetworkLoadMetrics(domainLookupStart)) {
-        m_networkLoadMetrics = *metrics;
-
-        if (m_captureExtraMetrics) {
-            m_curlHandle->addExtraNetworkLoadMetrics(m_networkLoadMetrics);
-            m_networkLoadMetrics.requestHeaders = m_requestHeaders;
-            m_networkLoadMetrics.responseBodyDecodedSize = m_totalReceivedSize;
-        }
+    auto domainLookupStart = m_performStartTime - m_requestStartTime;
+    auto networkLoadMetrics = m_curlHandle->getNetworkLoadMetrics(domainLookupStart);
+    if (!networkLoadMetrics)
+        return NetworkLoadMetrics();
+
+    if (m_captureExtraMetrics) {
+        m_curlHandle->addExtraNetworkLoadMetrics(*networkLoadMetrics);
+        networkLoadMetrics->requestHeaders = m_requestHeaders;
+        networkLoadMetrics->responseBodyDecodedSize = m_totalReceivedSize;
     }
+
+    return WTFMove(*networkLoadMetrics);
 }
 
 void CurlRequest::enableDownloadToFile()
index 9d0e2de..0785cb5 100644 (file)
 
 #pragma once
 
-#include "CertificateInfo.h"
 #include "CurlFormDataStream.h"
 #include "CurlMultipartHandle.h"
 #include "CurlMultipartHandleClient.h"
 #include "CurlRequestSchedulerClient.h"
 #include "CurlResponse.h"
-#include "NetworkLoadMetrics.h"
 #include "ProtectionSpace.h"
 #include "ResourceRequest.h"
 #include <wtf/FileSystem.h>
@@ -42,6 +40,7 @@
 namespace WebCore {
 
 class CurlRequestClient;
+class NetworkLoadMetrics;
 class ResourceError;
 class SharedBuffer;
 
@@ -76,7 +75,7 @@ public:
     WEBCORE_EXPORT void setUserPass(const String&, const String&);
     bool isServerTrustEvaluationDisabled() { return m_shouldDisableServerTrustEvaluation; }
     void disableServerTrustEvaluation() { m_shouldDisableServerTrustEvaluation = true; }
-    void setStartTime(const MonotonicTime& startTime) { m_requestStartTime = startTime; }
+    void setStartTime(const MonotonicTime& startTime) { m_requestStartTime = startTime.isolatedCopy(); }
 
     void start();
     void cancel();
@@ -98,9 +97,6 @@ public:
     void enableDownloadToFile();
     const String& getDownloadedFilePath();
 
-    const CertificateInfo& certificateInfo() const { return m_certificateInfo; }
-    const NetworkLoadMetrics& networkLoadMetrics() const { return m_networkLoadMetrics; }
-
 private:
     enum class Action {
         None,
@@ -154,7 +150,7 @@ private:
     void updateHandlePauseState(bool);
     bool isHandlePaused() const;
 
-    void updateNetworkLoadMetrics();
+    NetworkLoadMetrics networkLoadMetrics();
 
     // Download
     void writeDataToDownloadFileIfEnabled(const SharedBuffer&);
@@ -211,9 +207,7 @@ private:
     String m_downloadFilePath;
     FileSystem::PlatformFileHandle m_downloadFileHandle { FileSystem::invalidPlatformFileHandle };
 
-    CertificateInfo m_certificateInfo;
     bool m_captureExtraMetrics;
-    NetworkLoadMetrics m_networkLoadMetrics;
     HTTPHeaderMap m_requestHeaders;
     MonotonicTime m_requestStartTime { MonotonicTime::nan() };
     MonotonicTime m_performStartTime;
index 033b8e9..08c86c7 100644 (file)
 
 namespace WebCore {
 
+class CertificateInfo;
 class CurlRequest;
 class CurlResponse;
+class NetworkLoadMetrics;
 class ResourceError;
 class SharedBuffer;
 
@@ -40,10 +42,10 @@ public:
     virtual void deref() = 0;
 
     virtual void curlDidSendData(CurlRequest&, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) = 0;
-    virtual void curlDidReceiveResponse(CurlRequest&, const CurlResponse&) = 0;
+    virtual void curlDidReceiveResponse(CurlRequest&, CurlResponse&&) = 0;
     virtual void curlDidReceiveBuffer(CurlRequest&, Ref<SharedBuffer>&&) = 0;
-    virtual void curlDidComplete(CurlRequest&) = 0;
-    virtual void curlDidFailWithError(CurlRequest&, const ResourceError&) = 0;
+    virtual void curlDidComplete(CurlRequest&, NetworkLoadMetrics&&) = 0;
+    virtual void curlDidFailWithError(CurlRequest&, ResourceError&&, CertificateInfo&&) = 0;
 };
 
 } // namespace WebCore
index e675f02..6179c8e 100644 (file)
@@ -74,9 +74,8 @@ ResourceHandleInternal* CurlResourceHandleDelegate::d()
     return m_handle.getInternal();
 }
 
-void CurlResourceHandleDelegate::curlDidSendData(CurlRequest& request, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
+void CurlResourceHandleDelegate::curlDidSendData(CurlRequest&, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
 {
-    UNUSED_PARAM(request);
     ASSERT(isMainThread());
 
     if (cancelledOrClientless())
@@ -99,7 +98,7 @@ static void handleCookieHeaders(ResourceHandleInternal* d, const ResourceRequest
     }
 }
 
-void CurlResourceHandleDelegate::curlDidReceiveResponse(CurlRequest& request, const CurlResponse& receivedResponse)
+void CurlResourceHandleDelegate::curlDidReceiveResponse(CurlRequest& request, CurlResponse&& receivedResponse)
 {
     ASSERT(isMainThread());
     ASSERT(!d()->m_defersLoading);
@@ -108,9 +107,8 @@ void CurlResourceHandleDelegate::curlDidReceiveResponse(CurlRequest& request, co
         return;
 
     m_response = ResourceResponse(receivedResponse);
-
-    m_response.setCertificateInfo(request.certificateInfo().isolatedCopy());
-    m_response.setDeprecatedNetworkLoadMetrics(request.networkLoadMetrics().isolatedCopy());
+    m_response.setCertificateInfo(WTFMove(receivedResponse.certificateInfo));
+    m_response.setDeprecatedNetworkLoadMetrics(WTFMove(receivedResponse.networkLoadMetrics));
 
     handleCookieHeaders(d(), request.resourceRequest(), receivedResponse);
 
@@ -145,9 +143,8 @@ void CurlResourceHandleDelegate::curlDidReceiveResponse(CurlRequest& request, co
     });
 }
 
-void CurlResourceHandleDelegate::curlDidReceiveBuffer(CurlRequest& request, Ref<SharedBuffer>&& buffer)
+void CurlResourceHandleDelegate::curlDidReceiveBuffer(CurlRequest&, Ref<SharedBuffer>&& buffer)
 {
-    UNUSED_PARAM(request);
     ASSERT(isMainThread());
 
     if (cancelledOrClientless())
@@ -157,22 +154,19 @@ void CurlResourceHandleDelegate::curlDidReceiveBuffer(CurlRequest& request, Ref<
     client()->didReceiveBuffer(&m_handle, WTFMove(buffer), buffer->size());
 }
 
-void CurlResourceHandleDelegate::curlDidComplete(CurlRequest& request)
+void CurlResourceHandleDelegate::curlDidComplete(CurlRequest&, NetworkLoadMetrics&&)
 {
     ASSERT(isMainThread());
 
     if (cancelledOrClientless())
         return;
 
-    m_response.setDeprecatedNetworkLoadMetrics(request.networkLoadMetrics().isolatedCopy());
-
     CurlCacheManager::singleton().didFinishLoading(m_handle);
     client()->didFinishLoading(&m_handle);
 }
 
-void CurlResourceHandleDelegate::curlDidFailWithError(CurlRequest& request, const ResourceError& resourceError)
+void CurlResourceHandleDelegate::curlDidFailWithError(CurlRequest&, ResourceError&& resourceError, CertificateInfo&&)
 {
-    UNUSED_PARAM(request);
     ASSERT(isMainThread());
 
     if (cancelledOrClientless())
index 39b6be9..6d55864 100644 (file)
@@ -52,10 +52,10 @@ public:
     void deref() final;
 
     void curlDidSendData(CurlRequest&, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) final;
-    void curlDidReceiveResponse(CurlRequest&, const CurlResponse&) final;
+    void curlDidReceiveResponse(CurlRequest&, CurlResponse&&) final;
     void curlDidReceiveBuffer(CurlRequest&, Ref<SharedBuffer>&&) final;
-    void curlDidComplete(CurlRequest&) final;
-    void curlDidFailWithError(CurlRequest&, const ResourceError&) final;
+    void curlDidComplete(CurlRequest&, NetworkLoadMetrics&&) final;
+    void curlDidFailWithError(CurlRequest&, ResourceError&&, CertificateInfo&&) final;
 
 private:
     ResourceHandle& m_handle;
index e611ffc..0b3c6dc 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#include "CertificateInfo.h"
+#include "NetworkLoadMetrics.h"
 #include <wtf/URL.h>
 
 namespace WebCore {
@@ -50,6 +52,9 @@ public:
         copy.availableProxyAuth = availableProxyAuth;
         copy.httpVersion = httpVersion;
 
+        copy.certificateInfo = certificateInfo.isolatedCopy();
+        copy.networkLoadMetrics = networkLoadMetrics.isolatedCopy();
+
         return copy;
     }
 
@@ -63,6 +68,9 @@ public:
     long availableHttpAuth { 0 };
     long availableProxyAuth { 0 };
     long httpVersion { 0 };
+
+    CertificateInfo certificateInfo;
+    NetworkLoadMetrics networkLoadMetrics;
 };
 
 } // namespace WebCore
index f35705c..190a0f2 100644 (file)
@@ -78,8 +78,10 @@ bool ResourceResponse::isAppendableHeader(const String &key)
 }
 
 ResourceResponse::ResourceResponse(const CurlResponse& response)
-    : ResourceResponseBase(response.url, "", response.expectedContentLength, "")
+    : ResourceResponseBase()
 {
+    setURL(response.url);
+    setExpectedContentLength(response.expectedContentLength);
     setHTTPStatusCode(response.statusCode ? response.statusCode : response.httpConnectCode);
 
     for (const auto& header : response.headers)
@@ -101,6 +103,7 @@ ResourceResponse::ResourceResponse(const CurlResponse& response)
     default:
         break;
     }
+
     setMimeType(extractMIMETypeFromMediaType(httpHeaderField(HTTPHeaderName::ContentType)).convertToASCIILowercase());
     setTextEncodingName(extractCharsetFromMediaType(httpHeaderField(HTTPHeaderName::ContentType)));
     setSource(ResourceResponse::Source::Network);
index 027e9ab..8a0f7b3 100644 (file)
@@ -1,3 +1,16 @@
+2019-06-13  Takashi Komori  <Takashi.Komori@sony.com>
+
+        [curl] Remove member objects of CurlRequest not to share by different threads.
+        https://bugs.webkit.org/show_bug.cgi?id=198747
+
+        Reviewed by Fujii Hironori.
+
+        * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
+        (WebKit::NetworkDataTaskCurl::curlDidReceiveResponse):
+        (WebKit::NetworkDataTaskCurl::curlDidComplete):
+        (WebKit::NetworkDataTaskCurl::curlDidFailWithError):
+        * NetworkProcess/curl/NetworkDataTaskCurl.h:
+
 2019-06-13  Zan Dobersek  <zdobersek@igalia.com>
 
         [Nicosia] Add SceneIntegration
index 77633ba..30f794f 100644 (file)
@@ -32,6 +32,7 @@
 #include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/CookieJar.h>
 #include <WebCore/CurlRequest.h>
+#include <WebCore/NetworkLoadMetrics.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/ResourceError.h>
@@ -140,14 +141,15 @@ void NetworkDataTaskCurl::curlDidSendData(CurlRequest&, unsigned long long total
     m_client->didSendData(totalBytesSent, totalBytesExpectedToSend);
 }
 
-void NetworkDataTaskCurl::curlDidReceiveResponse(CurlRequest& request, const CurlResponse& receivedResponse)
+void NetworkDataTaskCurl::curlDidReceiveResponse(CurlRequest& request, CurlResponse&& receivedResponse)
 {
     auto protectedThis = makeRef(*this);
     if (state() == State::Canceling || state() == State::Completed || !m_client)
         return;
 
     m_response = ResourceResponse(receivedResponse);
-    m_response.setDeprecatedNetworkLoadMetrics(request.networkLoadMetrics().isolatedCopy());
+    m_response.setCertificateInfo(WTFMove(receivedResponse.certificateInfo));
+    m_response.setDeprecatedNetworkLoadMetrics(WTFMove(receivedResponse.networkLoadMetrics));
 
     handleCookieHeaders(request.resourceRequest(), receivedResponse);
 
@@ -179,23 +181,21 @@ void NetworkDataTaskCurl::curlDidReceiveBuffer(CurlRequest&, Ref<SharedBuffer>&&
     m_client->didReceiveData(WTFMove(buffer));
 }
 
-void NetworkDataTaskCurl::curlDidComplete(CurlRequest& request)
+void NetworkDataTaskCurl::curlDidComplete(CurlRequest&, NetworkLoadMetrics&& networkLoadMetrics)
 {
     if (state() == State::Canceling || state() == State::Completed || (!m_client && !isDownload()))
         return;
 
-    m_response.setDeprecatedNetworkLoadMetrics(request.networkLoadMetrics().isolatedCopy());
-
-    m_client->didCompleteWithError({ }, m_response.deprecatedNetworkLoadMetrics());
+    m_client->didCompleteWithError({ }, WTFMove(networkLoadMetrics));
 }
 
-void NetworkDataTaskCurl::curlDidFailWithError(CurlRequest& request, const ResourceError& resourceError)
+void NetworkDataTaskCurl::curlDidFailWithError(CurlRequest& request, ResourceError&& resourceError, CertificateInfo&& certificateInfo)
 {
     if (state() == State::Canceling || state() == State::Completed || (!m_client && !isDownload()))
         return;
 
     if (resourceError.isSSLCertVerificationError()) {
-        tryServerTrustEvaluation(AuthenticationChallenge(request.resourceRequest().url(), request.certificateInfo(), resourceError));
+        tryServerTrustEvaluation(AuthenticationChallenge(request.resourceRequest().url(), certificateInfo, resourceError));
         return;
     }
 
index 1b9c007..3fed2f0 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "NetworkDataTask.h"
 #include <WebCore/CurlRequestClient.h>
-#include <WebCore/NetworkLoadMetrics.h>
 #include <WebCore/ProtectionSpace.h>
 #include <WebCore/ResourceResponse.h>
 
@@ -64,10 +63,10 @@ private:
 
     Ref<WebCore::CurlRequest> createCurlRequest(WebCore::ResourceRequest&&, RequestStatus = RequestStatus::NewRequest);
     void curlDidSendData(WebCore::CurlRequest&, unsigned long long, unsigned long long) override;
-    void curlDidReceiveResponse(WebCore::CurlRequest&, const WebCore::CurlResponse&) override;
+    void curlDidReceiveResponse(WebCore::CurlRequest&, WebCore::CurlResponse&&) override;
     void curlDidReceiveBuffer(WebCore::CurlRequest&, Ref<WebCore::SharedBuffer>&&) override;
-    void curlDidComplete(WebCore::CurlRequest&) override;
-    void curlDidFailWithError(WebCore::CurlRequest&, const WebCore::ResourceError&) override;
+    void curlDidComplete(WebCore::CurlRequest&, WebCore::NetworkLoadMetrics&&) override;
+    void curlDidFailWithError(WebCore::CurlRequest&, WebCore::ResourceError&&, WebCore::CertificateInfo&&) override;
 
     void invokeDidReceiveResponse();