Modernize how many platform/network classes do isolatedCopy().
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jun 2016 22:43:25 +0000 (22:43 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jun 2016 22:43:25 +0000 (22:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158313

Reviewed by Alex Christensen.

No new tests (Refactor, no behavior change).

* loader/WorkerThreadableLoader.h:

* platform/network/FormData.cpp:
(WebCore::FormData::isolatedCopy):
(WebCore::FormDataElement::isolatedCopy):
(WebCore::FormData::FormData): Deleted.
(WebCore::FormData::deepCopy): Deleted.
* platform/network/FormData.h:

* platform/network/HTTPHeaderMap.cpp:
(WebCore::HTTPHeaderMap::isolatedCopy):
(WebCore::HTTPHeaderMap::copyData): Deleted.
(WebCore::HTTPHeaderMap::adopt): Deleted.
* platform/network/HTTPHeaderMap.h:

* platform/network/ResourceErrorBase.cpp:
(WebCore::ResourceErrorBase::asResourceError):
(WebCore::ResourceErrorBase::isolatedCopy):
* platform/network/ResourceErrorBase.h:
(WebCore::ResourceErrorBase::platformCopy): Deleted.

* platform/network/ResourceLoadTiming.h:
(WebCore::ResourceLoadTiming::isolatedCopy): Not strictly needed for now, but makes it obvious
  that changes will be needed if new members are added later.

* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::isolatedCopy):
(WebCore::ResourceRequestBase::setAsIsolatedCopy):
(WebCore::ResourceRequestBase::copyData): Deleted.
* platform/network/ResourceRequestBase.h:

* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::isolatedCopy):
(WebCore::ResourceResponseBase::copyData): Deleted.
* platform/network/ResourceResponseBase.h:
(WebCore::CrossThreadResourceResponseDataBase::CrossThreadResourceResponseDataBase): Deleted.

* platform/network/cf/ResourceError.h:
* platform/network/cf/ResourceErrorCF.cpp:
(WebCore::ResourceError::doPlatformIsolatedCopy):
(WebCore::ResourceError::platformCopy): Deleted.

* platform/network/cf/ResourceRequest.h:
* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::ResourceRequest::doPlatformSetAsIsolatedCopy):
(WebCore::ResourceRequest::doPlatformCopyData): Deleted.
(WebCore::ResourceRequest::doPlatformAdopt): Deleted.

* platform/network/cf/ResourceResponse.h:
(WebCore::ResourceResponse::doPlatformCopyData): Deleted.
(WebCore::ResourceResponse::doPlatformAdopt): Deleted.

* platform/network/curl/ResourceError.h:
(WebCore::ResourceError::doPlatformIsolatedCopy):

* platform/network/curl/ResourceRequest.h:
(WebCore::ResourceRequest::doPlatformSetAsIsolatedCopy):
(WebCore::ResourceRequest::doPlatformCopyData): Deleted.
(WebCore::ResourceRequest::doPlatformAdopt): Deleted.

* platform/network/curl/ResourceResponse.h:
(WebCore::ResourceResponse::doPlatformCopyData): Deleted.
(WebCore::ResourceResponse::doPlatformAdopt): Deleted.

* platform/network/mac/ResourceErrorMac.mm:
(WebCore::ResourceError::doPlatformIsolatedCopy):

* platform/network/soup/ResourceError.h:
* platform/network/soup/ResourceErrorSoup.cpp:
(WebCore::ResourceError::doPlatformIsolatedCopy):
(WebCore::ResourceError::platformCopy): Deleted.

* platform/network/soup/ResourceRequest.h:
(WebCore::ResourceRequest::doPlatformSetAsIsolatedCopy):
(WebCore::ResourceRequest::doPlatformCopyData): Deleted.
(WebCore::ResourceRequest::doPlatformAdopt): Deleted.

* platform/network/soup/ResourceResponse.h:
(WebCore::ResourceResponse::doPlatformCopyData): Deleted.
(WebCore::ResourceResponse::doPlatformAdopt): Deleted.

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

26 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/WorkerThreadableLoader.h
Source/WebCore/platform/network/FormData.cpp
Source/WebCore/platform/network/FormData.h
Source/WebCore/platform/network/HTTPHeaderMap.cpp
Source/WebCore/platform/network/HTTPHeaderMap.h
Source/WebCore/platform/network/ResourceErrorBase.cpp
Source/WebCore/platform/network/ResourceErrorBase.h
Source/WebCore/platform/network/ResourceLoadTiming.h
Source/WebCore/platform/network/ResourceRequestBase.cpp
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebCore/platform/network/ResourceResponseBase.cpp
Source/WebCore/platform/network/ResourceResponseBase.h
Source/WebCore/platform/network/cf/ResourceError.h
Source/WebCore/platform/network/cf/ResourceErrorCF.cpp
Source/WebCore/platform/network/cf/ResourceRequest.h
Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
Source/WebCore/platform/network/cf/ResourceResponse.h
Source/WebCore/platform/network/curl/ResourceError.h
Source/WebCore/platform/network/curl/ResourceRequest.h
Source/WebCore/platform/network/curl/ResourceResponse.h
Source/WebCore/platform/network/mac/ResourceErrorMac.mm
Source/WebCore/platform/network/soup/ResourceError.h
Source/WebCore/platform/network/soup/ResourceErrorSoup.cpp
Source/WebCore/platform/network/soup/ResourceRequest.h
Source/WebCore/platform/network/soup/ResourceResponse.h

index a58eb5d..37bf9ff 100644 (file)
@@ -1,3 +1,93 @@
+2016-06-02  Brady Eidson  <beidson@apple.com>
+
+        Modernize how many platform/network classes do isolatedCopy().
+        https://bugs.webkit.org/show_bug.cgi?id=158313
+
+        Reviewed by Alex Christensen.
+
+        No new tests (Refactor, no behavior change).
+
+        * loader/WorkerThreadableLoader.h:
+        
+        * platform/network/FormData.cpp:
+        (WebCore::FormData::isolatedCopy):
+        (WebCore::FormDataElement::isolatedCopy):
+        (WebCore::FormData::FormData): Deleted.
+        (WebCore::FormData::deepCopy): Deleted.
+        * platform/network/FormData.h:
+        
+        * platform/network/HTTPHeaderMap.cpp:
+        (WebCore::HTTPHeaderMap::isolatedCopy):
+        (WebCore::HTTPHeaderMap::copyData): Deleted.
+        (WebCore::HTTPHeaderMap::adopt): Deleted.
+        * platform/network/HTTPHeaderMap.h:
+        
+        * platform/network/ResourceErrorBase.cpp:
+        (WebCore::ResourceErrorBase::asResourceError):
+        (WebCore::ResourceErrorBase::isolatedCopy):
+        * platform/network/ResourceErrorBase.h:
+        (WebCore::ResourceErrorBase::platformCopy): Deleted.
+
+        * platform/network/ResourceLoadTiming.h:
+        (WebCore::ResourceLoadTiming::isolatedCopy): Not strictly needed for now, but makes it obvious
+          that changes will be needed if new members are added later.
+
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::isolatedCopy):
+        (WebCore::ResourceRequestBase::setAsIsolatedCopy):
+        (WebCore::ResourceRequestBase::copyData): Deleted.
+        * platform/network/ResourceRequestBase.h:
+        
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore::ResourceResponseBase::isolatedCopy):
+        (WebCore::ResourceResponseBase::copyData): Deleted.
+        * platform/network/ResourceResponseBase.h:
+        (WebCore::CrossThreadResourceResponseDataBase::CrossThreadResourceResponseDataBase): Deleted.
+        
+        * platform/network/cf/ResourceError.h:
+        * platform/network/cf/ResourceErrorCF.cpp:
+        (WebCore::ResourceError::doPlatformIsolatedCopy):
+        (WebCore::ResourceError::platformCopy): Deleted.
+        
+        * platform/network/cf/ResourceRequest.h:
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::ResourceRequest::doPlatformSetAsIsolatedCopy):
+        (WebCore::ResourceRequest::doPlatformCopyData): Deleted.
+        (WebCore::ResourceRequest::doPlatformAdopt): Deleted.
+        
+        * platform/network/cf/ResourceResponse.h:
+        (WebCore::ResourceResponse::doPlatformCopyData): Deleted.
+        (WebCore::ResourceResponse::doPlatformAdopt): Deleted.
+        
+        * platform/network/curl/ResourceError.h:
+        (WebCore::ResourceError::doPlatformIsolatedCopy):
+        
+        * platform/network/curl/ResourceRequest.h:
+        (WebCore::ResourceRequest::doPlatformSetAsIsolatedCopy):
+        (WebCore::ResourceRequest::doPlatformCopyData): Deleted.
+        (WebCore::ResourceRequest::doPlatformAdopt): Deleted.
+        
+        * platform/network/curl/ResourceResponse.h:
+        (WebCore::ResourceResponse::doPlatformCopyData): Deleted.
+        (WebCore::ResourceResponse::doPlatformAdopt): Deleted.
+        
+        * platform/network/mac/ResourceErrorMac.mm:
+        (WebCore::ResourceError::doPlatformIsolatedCopy):
+        
+        * platform/network/soup/ResourceError.h:
+        * platform/network/soup/ResourceErrorSoup.cpp:
+        (WebCore::ResourceError::doPlatformIsolatedCopy):
+        (WebCore::ResourceError::platformCopy): Deleted.
+        
+        * platform/network/soup/ResourceRequest.h:
+        (WebCore::ResourceRequest::doPlatformSetAsIsolatedCopy):
+        (WebCore::ResourceRequest::doPlatformCopyData): Deleted.
+        (WebCore::ResourceRequest::doPlatformAdopt): Deleted.
+        
+        * platform/network/soup/ResourceResponse.h:
+        (WebCore::ResourceResponse::doPlatformCopyData): Deleted.
+        (WebCore::ResourceResponse::doPlatformAdopt): Deleted.
+
 2016-06-02  Chris Dumez  <cdumez@apple.com>
 
         Crash under CachedResource::addClientToSet()
index 06683ea..66be0e8 100644 (file)
@@ -45,8 +45,6 @@ namespace WebCore {
     class ResourceRequest;
     class WorkerGlobalScope;
     class WorkerLoaderProxy;
-    struct CrossThreadResourceResponseData;
-    struct CrossThreadResourceRequestData;
 
     class WorkerThreadableLoader : public RefCounted<WorkerThreadableLoader>, public ThreadableLoader {
         WTF_MAKE_FAST_ALLOCATED;
index 885a981..e27e2b0 100644 (file)
@@ -39,9 +39,6 @@
 namespace WebCore {
 
 inline FormData::FormData()
-    : m_identifier(0)
-    , m_alwaysStream(false)
-    , m_containsPasswordData(false)
 {
 }
 
@@ -115,29 +112,34 @@ Ref<FormData> FormData::copy() const
     return adoptRef(*new FormData(*this));
 }
 
-Ref<FormData> FormData::deepCopy() const
+Ref<FormData> FormData::isolatedCopy() const
 {
-    Ref<FormData> formData(create());
+    // FIXME: isolatedCopy() (historically deepCopy()) only copies certain values from `this`. Why is that?
+    auto formData = create();
 
     formData->m_alwaysStream = m_alwaysStream;
 
     formData->m_elements.reserveInitialCapacity(m_elements.size());
-    for (const FormDataElement& element : m_elements) {
-        switch (element.m_type) {
-        case FormDataElement::Type::Data:
-            formData->m_elements.uncheckedAppend(FormDataElement(element.m_data));
-            break;
-        case FormDataElement::Type::EncodedFile:
-            formData->m_elements.uncheckedAppend(FormDataElement(element.m_filename, element.m_fileStart, element.m_fileLength, element.m_expectedFileModificationTime, element.m_shouldGenerateFile));
-            break;
-        case FormDataElement::Type::EncodedBlob:
-            formData->m_elements.uncheckedAppend(FormDataElement(element.m_url));
-            break;
-        }
-    }
+    for (auto& element : m_elements)
+        formData->m_elements.uncheckedAppend(element.isolatedCopy());
+
     return formData;
 }
 
+FormDataElement FormDataElement::isolatedCopy() const
+{
+    switch (m_type) {
+    case Type::Data:
+        return FormDataElement(m_data);
+    case Type::EncodedFile:
+        return FormDataElement(m_filename.isolatedCopy(), m_fileStart, m_fileLength, m_expectedFileModificationTime, m_shouldGenerateFile);
+    case Type::EncodedBlob:
+        return FormDataElement(m_url.isolatedCopy());
+    }
+
+    RELEASE_ASSERT_NOT_REACHED();
+}
+
 void FormData::appendData(const void* data, size_t size)
 {
     memcpy(expandDataStore(size), data, size);
index b734bb1..7e44dca 100644 (file)
@@ -69,6 +69,8 @@ public:
     {
     }
 
+    FormDataElement isolatedCopy() const;
+
     template<typename Encoder>
     void encode(Encoder&) const;
     template<typename Decoder>
@@ -205,7 +207,7 @@ public:
     // FIXME: Both these functions perform a deep copy of m_elements, but differ in handling of other data members.
     // How much of that is intentional? We need better names that explain the difference.
     Ref<FormData> copy() const;
-    Ref<FormData> deepCopy() const;
+    Ref<FormData> isolatedCopy() const;
 
     template<typename Encoder>
     void encode(Encoder&) const;
@@ -263,10 +265,10 @@ private:
 
     Vector<FormDataElement> m_elements;
 
-    int64_t m_identifier;
-    bool m_alwaysStream;
+    int64_t m_identifier { 0 };
+    bool m_alwaysStream { false };
     Vector<char> m_boundary;
-    bool m_containsPasswordData;
+    bool m_containsPasswordData { false };
 };
 
 inline bool operator==(const FormData& a, const FormData& b)
index 5651e98..e29dd83 100644 (file)
@@ -44,31 +44,17 @@ HTTPHeaderMap::~HTTPHeaderMap()
 {
 }
 
-std::unique_ptr<CrossThreadHTTPHeaderMapData> HTTPHeaderMap::copyData() const
+HTTPHeaderMap HTTPHeaderMap::isolatedCopy() const
 {
-    auto data = std::make_unique<CrossThreadHTTPHeaderMapData>();
+    HTTPHeaderMap map;
 
-    data->commonHeaders.reserveInitialCapacity(m_commonHeaders.size());
-    for (const auto& header : m_commonHeaders)
-        data->commonHeaders.uncheckedAppend(std::make_pair(header.key, header.value.isolatedCopy()));
+    for (auto& header : m_commonHeaders)
+        map.m_commonHeaders.set(header.key, header.value.isolatedCopy());
 
-    data->uncommonHeaders.reserveInitialCapacity(m_uncommonHeaders.size());
-    for (const auto& header : m_uncommonHeaders)
-        data->uncommonHeaders.uncheckedAppend(std::make_pair(header.key.isolatedCopy(), header.value.isolatedCopy()));
+    for (auto& header : m_uncommonHeaders)
+        map.m_uncommonHeaders.set(header.key.isolatedCopy(), header.value.isolatedCopy());
 
-    return data;
-}
-
-void HTTPHeaderMap::adopt(std::unique_ptr<CrossThreadHTTPHeaderMapData> data)
-{
-    m_commonHeaders.clear();
-    m_uncommonHeaders.clear();
-
-    for (auto& header : data->commonHeaders)
-        m_commonHeaders.add(header.first, WTFMove(header.second));
-
-    for (auto& header : data->uncommonHeaders)
-        m_uncommonHeaders.add(WTFMove(header.first), WTFMove(header.second));
+    return map;
 }
 
 String HTTPHeaderMap::get(const String& name) const
index d345697..e79a44a 100644 (file)
@@ -24,8 +24,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef HTTPHeaderMap_h
-#define HTTPHeaderMap_h
+#pragma once
 
 #include "HTTPHeaderNames.h"
 #include <utility>
 
 namespace WebCore {
 
-struct CrossThreadHTTPHeaderMapData {
-    Vector<std::pair<HTTPHeaderName, String>> commonHeaders;
-    Vector<std::pair<String, String>> uncommonHeaders;
-};
-
 // FIXME: Not every header fits into a map. Notably, multiple Set-Cookie header fields are needed to set multiple cookies.
 
 class HTTPHeaderMap {
@@ -124,8 +118,7 @@ public:
     WEBCORE_EXPORT ~HTTPHeaderMap();
 
     // Gets a copy of the data suitable for passing to another thread.
-    std::unique_ptr<CrossThreadHTTPHeaderMapData> copyData() const;
-    void adopt(std::unique_ptr<CrossThreadHTTPHeaderMapData>);
+    HTTPHeaderMap isolatedCopy() const;
 
     bool isEmpty() const { return m_commonHeaders.isEmpty() && m_uncommonHeaders.isEmpty(); }
     int size() const { return m_commonHeaders.size() + m_uncommonHeaders.size(); }
@@ -215,5 +208,3 @@ bool HTTPHeaderMap::decode(Decoder& decoder, HTTPHeaderMap& headerMap)
 }
 
 } // namespace WebCore
-
-#endif // HTTPHeaderMap_h
index 10bbbaa..0efd04e 100644 (file)
@@ -31,6 +31,11 @@ namespace WebCore {
 
 const char* const errorDomainWebKitInternal = "WebKitInternal";
 
+inline const ResourceError& ResourceErrorBase::asResourceError() const
+{
+    return *static_cast<const ResourceError*>(this);
+}
+
 ResourceError ResourceErrorBase::isolatedCopy() const
 {
     lazyInit();
@@ -43,7 +48,9 @@ ResourceError ResourceErrorBase::isolatedCopy() const
     errorCopy.m_isNull = m_isNull;
     errorCopy.m_isCancellation = m_isCancellation;
     errorCopy.m_isTimeout = m_isTimeout;
-    platformCopy(errorCopy);
+
+    errorCopy.doPlatformIsolatedCopy(asResourceError());
+
     return errorCopy;
 }
 
index 77f4d60..bb6a3a5 100644 (file)
@@ -78,9 +78,6 @@ protected:
     // The ResourceError subclass may "shadow" this method to lazily initialize platform specific fields
     void platformLazyInit() {}
 
-    // The ResourceError subclass may "shadow" this method to copy platform specific fields
-    void platformCopy(ResourceError&) const {}
-
     // The ResourceError subclass may "shadow" this method to compare platform specific fields
     static bool platformCompare(const ResourceError&, const ResourceError&) { return true; }
 
@@ -91,6 +88,9 @@ protected:
     bool m_isNull : 1;
     bool m_isCancellation : 1;
     bool m_isTimeout : 1;
+
+private:
+    const ResourceError& asResourceError() const;
 };
 
 inline bool operator==(const ResourceError& a, const ResourceError& b) { return ResourceErrorBase::compare(a, b); }
index 9bd945c..75cec49 100644 (file)
@@ -68,6 +68,12 @@ public:
         secureConnectionStart = other.secureConnectionStart;
         return *this;
     }
+
+    ResourceLoadTiming isolatedCopy() const
+    {
+        // There are currently no members that need isolated copies, so we can use the copy constructor.
+        return *this;
+    }
     
     bool operator==(const ResourceLoadTiming& other) const
     {
index 34bb76a..a48be4f 100644 (file)
@@ -52,65 +52,41 @@ inline const ResourceRequest& ResourceRequestBase::asResourceRequest() const
 ResourceRequest ResourceRequestBase::isolatedCopy() const
 {
     ResourceRequest request;
-    request.setAsIsolatedCopy(*this);
+    request.setAsIsolatedCopy(asResourceRequest());
     return request;
 }
 
-void ResourceRequestBase::setAsIsolatedCopy(const ResourceRequestBase& other)
+void ResourceRequestBase::setAsIsolatedCopy(const ResourceRequest& other)
 {
-    auto data = other.copyData();
-
-    setURL(data->url);
-    setCachePolicy(data->cachePolicy);
-    setTimeoutInterval(data->timeoutInterval);
-    setFirstPartyForCookies(data->firstPartyForCookies);
-    setHTTPMethod(data->httpMethod);
-    setPriority(data->priority);
-    setRequester(data->requester);
+    setURL(other.url().isolatedCopy());
+    setCachePolicy(other.cachePolicy());
+    setTimeoutInterval(other.timeoutInterval());
+    setFirstPartyForCookies(other.firstPartyForCookies().isolatedCopy());
+    setHTTPMethod(other.httpMethod().isolatedCopy());
+    setPriority(other.priority());
+    setRequester(other.requester());
 
     updateResourceRequest();
-    m_httpHeaderFields.adopt(WTFMove(data->httpHeaders));
+    m_httpHeaderFields = other.httpHeaderFields().isolatedCopy();
 
-    size_t encodingCount = data->responseContentDispositionEncodingFallbackArray.size();
+    size_t encodingCount = other.m_responseContentDispositionEncodingFallbackArray.size();
     if (encodingCount > 0) {
-        String encoding1 = data->responseContentDispositionEncodingFallbackArray[0];
+        String encoding1 = other.m_responseContentDispositionEncodingFallbackArray[0].isolatedCopy();
         String encoding2;
         String encoding3;
         if (encodingCount > 1) {
-            encoding2 = data->responseContentDispositionEncodingFallbackArray[1];
+            encoding2 = other.m_responseContentDispositionEncodingFallbackArray[1].isolatedCopy();
             if (encodingCount > 2)
-                encoding3 = data->responseContentDispositionEncodingFallbackArray[2];
+                encoding3 = other.m_responseContentDispositionEncodingFallbackArray[2].isolatedCopy();
         }
         ASSERT(encodingCount <= 3);
         setResponseContentDispositionEncodingFallbackArray(encoding1, encoding2, encoding3);
     }
-    setHTTPBody(data->httpBody.copyRef());
-    setAllowCookies(data->allowCookies);
-
-    const_cast<ResourceRequest&>(asResourceRequest()).doPlatformAdopt(WTFMove(data));
-}
+    if (other.m_httpBody)
+        setHTTPBody(other.m_httpBody->isolatedCopy());
+    setAllowCookies(other.m_allowCookies);
 
-std::unique_ptr<CrossThreadResourceRequestData> ResourceRequestBase::copyData() const
-{
-    auto data = std::make_unique<CrossThreadResourceRequestData>();
-    data->url = url().isolatedCopy();
-    data->cachePolicy = m_cachePolicy;
-    data->timeoutInterval = timeoutInterval();
-    data->firstPartyForCookies = firstPartyForCookies().isolatedCopy();
-    data->httpMethod = httpMethod().isolatedCopy();
-    data->httpHeaders = httpHeaderFields().copyData();
-    data->priority = m_priority;
-    data->requester = m_requester;
-
-    data->responseContentDispositionEncodingFallbackArray.reserveInitialCapacity(m_responseContentDispositionEncodingFallbackArray.size());
-    size_t encodingArraySize = m_responseContentDispositionEncodingFallbackArray.size();
-    for (size_t index = 0; index < encodingArraySize; ++index) {
-        data->responseContentDispositionEncodingFallbackArray.append(m_responseContentDispositionEncodingFallbackArray[index].isolatedCopy());
-    }
-    if (m_httpBody)
-        data->httpBody = m_httpBody->deepCopy();
-    data->allowCookies = m_allowCookies;
-    return asResourceRequest().doPlatformCopyData(WTFMove(data));
+    const_cast<ResourceRequest&>(asResourceRequest()).doPlatformSetAsIsolatedCopy(other);
 }
 
 bool ResourceRequestBase::isEmpty() const
index 6b163cb..6e0bbe0 100644 (file)
@@ -48,14 +48,13 @@ enum HTTPBodyUpdatePolicy {
 };
 
 class ResourceRequest;
-struct CrossThreadResourceRequestData;
 
 // Do not use this type directly.  Use ResourceRequest instead.
 class ResourceRequestBase {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     ResourceRequest isolatedCopy() const;
-    WEBCORE_EXPORT void setAsIsolatedCopy(const ResourceRequestBase&);
+    WEBCORE_EXPORT void setAsIsolatedCopy(const ResourceRequest&);
 
     WEBCORE_EXPORT bool isNull() const;
     WEBCORE_EXPORT bool isEmpty() const;
@@ -220,9 +219,6 @@ protected:
 private:
     const ResourceRequest& asResourceRequest() const;
 
-    // Gets a copy of the data suitable for passing to another thread.
-    std::unique_ptr<CrossThreadResourceRequestData> copyData() const;
-
     WEBCORE_EXPORT static double s_defaultTimeoutInterval;
 #if PLATFORM(IOS)
     static bool s_defaultAllowCookies;
@@ -234,20 +230,6 @@ bool equalIgnoringHeaderFields(const ResourceRequestBase&, const ResourceRequest
 inline bool operator==(const ResourceRequest& a, const ResourceRequest& b) { return ResourceRequestBase::compare(a, b); }
 inline bool operator!=(ResourceRequest& a, const ResourceRequest& b) { return !(a == b); }
 
-struct CrossThreadResourceRequestDataBase {
-    URL url;
-    ResourceRequestCachePolicy cachePolicy;
-    double timeoutInterval;
-    URL firstPartyForCookies;
-    String httpMethod;
-    std::unique_ptr<CrossThreadHTTPHeaderMapData> httpHeaders;
-    Vector<String> responseContentDispositionEncodingFallbackArray;
-    RefPtr<FormData> httpBody;
-    bool allowCookies;
-    ResourceLoadPriority priority;
-    ResourceRequestBase::Requester requester;
-};
-
 WEBCORE_EXPORT unsigned initializeMaximumHTTPConnectionCountPerHost();
 #if PLATFORM(IOS)
 WEBCORE_EXPORT void initializeHTTPConnectionSettingsOnStartup();
index 31ff4fa..5b52876 100644 (file)
@@ -66,42 +66,24 @@ ResourceResponseBase::ResourceResponseBase(const URL& url, const String& mimeTyp
 ResourceResponse ResourceResponseBase::isolatedCopy() const
 {
     ResourceResponse response;
-    auto data = copyData();
 
-    response.setURL(data->m_url);
-    response.setMimeType(data->m_mimeType);
-    response.setExpectedContentLength(data->m_expectedContentLength);
-    response.setTextEncodingName(data->m_textEncodingName);
+    response.setURL(url().isolatedCopy());
+    response.setMimeType(mimeType().isolatedCopy());
+    response.setExpectedContentLength(expectedContentLength());
+    response.setTextEncodingName(textEncodingName().isolatedCopy());
 
-    response.setHTTPStatusCode(data->m_httpStatusCode);
-    response.setHTTPStatusText(data->m_httpStatusText);
-    response.setHTTPVersion(data->m_httpVersion);
+    response.setHTTPStatusCode(httpStatusCode());
+    response.setHTTPStatusText(httpStatusText().isolatedCopy());
+    response.setHTTPVersion(httpVersion().isolatedCopy());
 
     response.lazyInit(AllFields);
-    response.m_httpHeaderFields.adopt(WTFMove(data->m_httpHeaders));
-    response.m_resourceLoadTiming = data->m_resourceLoadTiming;
-    response.m_type = data->m_type;
-    response.doPlatformAdopt(WTFMove(data));
+    response.m_httpHeaderFields = httpHeaderFields().isolatedCopy();
+    response.m_resourceLoadTiming = m_resourceLoadTiming.isolatedCopy();
+    response.m_type = m_type;
 
     return response;
 }
 
-std::unique_ptr<CrossThreadResourceResponseData> ResourceResponseBase::copyData() const
-{
-    auto data = std::make_unique<CrossThreadResourceResponseData>();
-    data->m_url = url().isolatedCopy();
-    data->m_mimeType = mimeType().isolatedCopy();
-    data->m_expectedContentLength = expectedContentLength();
-    data->m_textEncodingName = textEncodingName().isolatedCopy();
-    data->m_httpStatusCode = httpStatusCode();
-    data->m_httpStatusText = httpStatusText().isolatedCopy();
-    data->m_httpVersion = httpVersion().isolatedCopy();
-    data->m_httpHeaders = httpHeaderFields().copyData();
-    data->m_resourceLoadTiming = m_resourceLoadTiming;
-    data->m_type = m_type;
-    return asResourceResponse().doPlatformCopyData(WTFMove(data));
-}
-
 // FIXME: Name does not make it clear this is true for HTTPS!
 bool ResourceResponseBase::isHTTP() const
 {
index 5fff359..ad5107f 100644 (file)
@@ -40,7 +40,6 @@
 namespace WebCore {
 
 class ResourceResponse;
-struct CrossThreadResourceResponseData;
 
 // Do not use this class directly, use the class ResponseResponse instead
 class ResourceResponseBase {
@@ -159,9 +158,6 @@ private:
     void parseCacheControlDirectives() const;
     void updateHeaderParsedState(HTTPHeaderName);
 
-    // Gets a copy of the data suitable for passing to another thread.
-    std::unique_ptr<CrossThreadResourceResponseData> copyData() const;
-
 protected:
     bool m_isNull;
     URL m_url;
@@ -274,21 +270,4 @@ bool ResourceResponseBase::decode(Decoder& decoder, ResourceResponseBase& respon
     return true;
 }
 
-struct CrossThreadResourceResponseDataBase {
-    WTF_MAKE_NONCOPYABLE(CrossThreadResourceResponseDataBase); WTF_MAKE_FAST_ALLOCATED;
-public:
-    CrossThreadResourceResponseDataBase() { }
-    URL m_url;
-    String m_mimeType;
-    long long m_expectedContentLength;
-    String m_textEncodingName;
-    int m_httpStatusCode;
-    String m_httpStatusText;
-    String m_httpVersion;
-    std::unique_ptr<CrossThreadHTTPHeaderMapData> m_httpHeaders;
-    ResourceLoadTiming m_resourceLoadTiming;
-    ResourceResponseBase::Type m_type;
-    bool m_isRedirected;
-};
-
 } // namespace WebCore
index c36bdca..2ca04ee 100644 (file)
@@ -83,7 +83,9 @@ private:
     friend class ResourceErrorBase;
 
     void platformLazyInit();
-    void platformCopy(ResourceError&) const;
+
+    void doPlatformIsolatedCopy(const ResourceError&);
+
     bool m_dataIsUpToDate;
 #if USE(CFNETWORK)
     mutable RetainPtr<CFErrorRef> m_platformError;
index 60bfb36..d5b4ee4 100644 (file)
@@ -119,12 +119,13 @@ void ResourceError::platformLazyInit()
     m_dataIsUpToDate = true;
 }
 
-void ResourceError::platformCopy(ResourceError& errorCopy) const
+
+void ResourceError::doPlatformIsolatedCopy(const ResourceError& other)
 {
 #if PLATFORM(WIN)
-    errorCopy.m_certificate = m_certificate;
+    m_certificate = other.m_certificate;
 #else
-    UNUSED_PARAM(errorCopy);
+    UNUSED_PARAM(other);
 #endif
 }
 
index c743f65..8fe8f90 100644 (file)
@@ -126,8 +126,7 @@ private:
     void doUpdatePlatformHTTPBody();
     void doUpdateResourceHTTPBody();
 
-    std::unique_ptr<CrossThreadResourceRequestData> doPlatformCopyData(std::unique_ptr<CrossThreadResourceRequestData>) const;
-    void doPlatformAdopt(std::unique_ptr<CrossThreadResourceRequestData>);
+    void doPlatformSetAsIsolatedCopy(const ResourceRequest&);
 
 #if USE(CFNETWORK)
     RetainPtr<CFURLRequestRef> m_cfRequest;
@@ -142,12 +141,6 @@ private:
     static bool s_httpPipeliningEnabled;
 };
 
-struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase {
-#if ENABLE(CACHE_PARTITIONING)
-    String m_cachePartition;
-#endif
-};
-
 inline bool ResourceRequest::resourcePrioritiesEnabled()
 {
 #if PLATFORM(MAC)
index ac87b2a..90e40f1 100644 (file)
@@ -366,23 +366,16 @@ String ResourceRequest::partitionName(const String& domain)
 }
 #endif
 
-std::unique_ptr<CrossThreadResourceRequestData> ResourceRequest::doPlatformCopyData(std::unique_ptr<CrossThreadResourceRequestData> data) const
+void ResourceRequest::doPlatformSetAsIsolatedCopy(const ResourceRequest& other)
 {
 #if ENABLE(CACHE_PARTITIONING)
-    data->m_cachePartition = m_cachePartition;
-#endif
-    return data;
-}
-
-void ResourceRequest::doPlatformAdopt(std::unique_ptr<CrossThreadResourceRequestData> data)
-{
-#if ENABLE(CACHE_PARTITIONING)
-    m_cachePartition = data->m_cachePartition;
+    m_cachePartition = other.m_cachePartition.isolatedCopy();
 #else
-    UNUSED_PARAM(data);
+    UNUSED_PARAM(other);
 #endif
 }
 
+
 // FIXME: It is confusing that this function both sets connection count and determines maximum request count at network layer. This can and should be done separately.
 unsigned initializeMaximumHTTPConnectionCountPerHost()
 {
index 83946cf..7df0e70 100644 (file)
@@ -100,8 +100,8 @@ private:
     String platformSuggestedFilename() const;
     CertificateInfo platformCertificateInfo() const;
 
-    std::unique_ptr<CrossThreadResourceResponseData> doPlatformCopyData(std::unique_ptr<CrossThreadResourceResponseData> data) const { return data; }
-    void doPlatformAdopt(std::unique_ptr<CrossThreadResourceResponseData>) { }
+    void doPlatformSetAsIsolatedCopy(const ResourceResponse&) const;
+
 #if PLATFORM(COCOA)
     void initNSURLResponse() const;
 #endif
@@ -119,7 +119,4 @@ private:
 #endif
 };
 
-struct CrossThreadResourceResponseData : public CrossThreadResourceResponseDataBase {
-};
-
 } // namespace WebCore
index c31dd42..eec462d 100644 (file)
@@ -54,6 +54,9 @@ public:
     bool hasSSLConnectError() const { return errorCode() == CURLE_SSL_CONNECT_ERROR; }
 
 private:
+    friend class ResourceErrorBase;
+    void doPlatformIsolatedCopy(const ResourceError&) { }
+
     unsigned m_sslErrors;
 };
 
index 654d02f..7dbf64d 100644 (file)
@@ -78,13 +78,9 @@ namespace WebCore {
         void doUpdatePlatformHTTPBody() { }
         void doUpdateResourceHTTPBody() { }
 
-        std::unique_ptr<CrossThreadResourceRequestData> doPlatformCopyData(std::unique_ptr<CrossThreadResourceRequestData> data) const { return data; }
-        void doPlatformAdopt(std::unique_ptr<CrossThreadResourceRequestData>) { }
-        static bool s_httpPipeliningEnabled;
-    };
+        void doPlatformSetAsIsolatedCopy(const ResourceRequest&) { }
 
-    struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase {
+        static bool s_httpPipeliningEnabled;
     };
 
 } // namespace WebCore
index 4307f6e..ea1840f 100644 (file)
@@ -59,8 +59,6 @@ public:
 private:
     friend class ResourceResponseBase;
 
-    std::unique_ptr<CrossThreadResourceResponseData> doPlatformCopyData(std::unique_ptr<CrossThreadResourceResponseData> data) const { return data; }
-    void doPlatformAdopt(std::unique_ptr<CrossThreadResourceResponseData>) { }
     String platformSuggestedFilename() const
     {
         return filenameFromHTTPContentDisposition(httpHeaderField(HTTPHeaderName::ContentDisposition));
@@ -69,9 +67,6 @@ private:
     bool m_responseFired;
 };
 
-struct CrossThreadResourceResponseData : public CrossThreadResourceResponseDataBase {
-};
-
 } // namespace WebCore
 
 #endif // ResourceResponse_h
index 60b0dff..52079bd 100644 (file)
@@ -281,6 +281,10 @@ bool ResourceError::platformCompare(const ResourceError& a, const ResourceError&
     return a.nsError() == b.nsError();
 }
 
+void ResourceError::doPlatformIsolatedCopy(const ResourceError&)
+{
+}
+
 NSError *ResourceError::nsError() const
 {
     if (m_isNull) {
index 447b002..c4d7ada 100644 (file)
@@ -67,7 +67,8 @@ public:
     static bool platformCompare(const ResourceError& a, const ResourceError& b);
 
 private:
-    void platformCopy(ResourceError&) const;
+    friend class ResourceErrorBase;
+    void doPlatformIsolatedCopy(const ResourceError&);
 
     unsigned m_tlsErrors;
     GRefPtr<GTlsCertificate> m_certificate;
index ad6b8e7..db6fd95 100644 (file)
@@ -97,10 +97,10 @@ ResourceError ResourceError::timeoutError(const URL& failingURL)
     return error;
 }
 
-void ResourceError::platformCopy(ResourceError& errorCopy) const
+void ResourceError::doPlatformIsolatedCopy(const ResourceError& other)
 {
-    errorCopy.m_certificate = m_certificate;
-    errorCopy.m_tlsErrors = m_tlsErrors;
+    m_certificate = other.m_certificate;
+    m_tlsErrors = other.m_tlsErrors;
 }
 
 bool ResourceError::platformCompare(const ResourceError& a, const ResourceError& b)
index a171e99..8a235bb 100644 (file)
@@ -120,11 +120,7 @@ namespace WebCore {
         void doUpdatePlatformHTTPBody() { }
         void doUpdateResourceHTTPBody() { }
 
-        std::unique_ptr<CrossThreadResourceRequestData> doPlatformCopyData(std::unique_ptr<CrossThreadResourceRequestData> data) const { return data; }
-        void doPlatformAdopt(std::unique_ptr<CrossThreadResourceRequestData>) { }
-    };
-
-    struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase {
+        void doPlatformSetAsIsolatedCopy(const ResourceRequest&) { }
     };
 
 #if SOUP_CHECK_VERSION(2, 43, 1)
index ff8be2a..27f9b53 100644 (file)
@@ -90,9 +90,6 @@ private:
     void doUpdateResourceResponse() { }
     String platformSuggestedFilename() const;
     CertificateInfo platformCertificateInfo() const;
-
-    std::unique_ptr<CrossThreadResourceResponseData> doPlatformCopyData(std::unique_ptr<CrossThreadResourceResponseData> data) const { return data; }
-    void doPlatformAdopt(std::unique_ptr<CrossThreadResourceResponseData>) { }
 };
 
 template<class Encoder>
@@ -112,9 +109,6 @@ bool ResourceResponse::decode(Decoder& decoder, ResourceResponse& response)
     return true;
 }
 
-struct CrossThreadResourceResponseData : public CrossThreadResourceResponseDataBase {
-};
-
 } // namespace WebCore
 
 #endif // ResourceResponse_h