Overhaul cross-thread use of ResourceRequest, ResourceResponse, and ResourceError.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jun 2016 18:17:47 +0000 (18:17 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Jun 2016 18:17:47 +0000 (18:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158293

Reviewed by Darin Adler.

Source/WebCore:

No new tests (Refactor, no behavior change).

* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveResponse):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck):

* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::removeRequestFromSessionCaches):

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

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

Made copyData private, and made "adopt" be "isolatedCopy".
Rest of the changes are all re-indenting the file.
* platform/network/ResourceRequestBase.h:
(WebCore::ResourceRequestBase::responseContentDispositionEncodingFallbackArray):
(WebCore::ResourceRequestBase::reportUploadProgress):
(WebCore::ResourceRequestBase::setReportUploadProgress):
(WebCore::ResourceRequestBase::reportLoadTiming):
(WebCore::ResourceRequestBase::setReportLoadTiming):
(WebCore::ResourceRequestBase::reportRawHeaders):
(WebCore::ResourceRequestBase::setReportRawHeaders):
(WebCore::ResourceRequestBase::hiddenFromInspector):
(WebCore::ResourceRequestBase::setHiddenFromInspector):
(WebCore::ResourceRequestBase::requester):
(WebCore::ResourceRequestBase::setRequester):
(WebCore::ResourceRequestBase::encodingRequiresPlatformData):
(WebCore::ResourceRequestBase::ResourceRequestBase):
(WebCore::ResourceRequestBase::platformCompare):
(WebCore::operator==):
(WebCore::operator!=):

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

* platform/network/cf/ResourceError.h:
(WebCore::ResourceError::isolatedCopy): Deleted.

Removed platform-specific isolatedCopy, and re-indented the header:
* platform/network/cf/ResourceRequest.h:
(WebCore::ResourceRequest::ResourceRequest):
(WebCore::ResourceRequest::encodingRequiresPlatformData):
(WebCore::ResourceRequest::cachePartition):
(WebCore::ResourceRequest::setCachePartition):
(WebCore::ResourceRequest::setDomainForCachePartition):
(WebCore::ResourceRequest::resourcePrioritiesEnabled):
(WebCore::ResourceRequest::isolatedCopy): Deleted.

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

Source/WebKit2:

* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::Entry):

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

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/WorkerThreadableLoader.cpp
Source/WebCore/loader/cache/MemoryCache.cpp
Source/WebCore/platform/network/ResourceErrorBase.cpp
Source/WebCore/platform/network/ResourceErrorBase.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/ResourceRequest.h
Source/WebCore/platform/network/cf/ResourceResponse.h
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp

index f7a547f..ceeec8f 100644 (file)
@@ -1,3 +1,72 @@
+2016-06-02  Brady Eidson  <beidson@apple.com>
+
+        Overhaul cross-thread use of ResourceRequest, ResourceResponse, and ResourceError.
+        https://bugs.webkit.org/show_bug.cgi?id=158293
+
+        Reviewed by Darin Adler.
+
+        No new tests (Refactor, no behavior change).
+
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveResponse):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck):
+
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::removeRequestFromSessionCaches):
+
+        * platform/network/ResourceErrorBase.cpp:
+        (WebCore::ResourceErrorBase::isolatedCopy):
+        (WebCore::ResourceErrorBase::copy): Deleted.
+        * platform/network/ResourceErrorBase.h:
+
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::isolatedCopy):
+        (WebCore::ResourceRequestBase::setAsIsolatedCopy):
+        (WebCore::ResourceRequestBase::adopt): Deleted.
+        
+        Made copyData private, and made "adopt" be "isolatedCopy".
+        Rest of the changes are all re-indenting the file.
+        * platform/network/ResourceRequestBase.h:
+        (WebCore::ResourceRequestBase::responseContentDispositionEncodingFallbackArray):
+        (WebCore::ResourceRequestBase::reportUploadProgress):
+        (WebCore::ResourceRequestBase::setReportUploadProgress):
+        (WebCore::ResourceRequestBase::reportLoadTiming):
+        (WebCore::ResourceRequestBase::setReportLoadTiming):
+        (WebCore::ResourceRequestBase::reportRawHeaders):
+        (WebCore::ResourceRequestBase::setReportRawHeaders):
+        (WebCore::ResourceRequestBase::hiddenFromInspector):
+        (WebCore::ResourceRequestBase::setHiddenFromInspector):
+        (WebCore::ResourceRequestBase::requester):
+        (WebCore::ResourceRequestBase::setRequester):
+        (WebCore::ResourceRequestBase::encodingRequiresPlatformData):
+        (WebCore::ResourceRequestBase::ResourceRequestBase):
+        (WebCore::ResourceRequestBase::platformCompare):
+        (WebCore::operator==):
+        (WebCore::operator!=):
+
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore::ResourceResponseBase::isolatedCopy):
+        (WebCore::ResourceResponseBase::adopt): Deleted.
+        * platform/network/ResourceResponseBase.h:
+
+        * platform/network/cf/ResourceError.h:
+        (WebCore::ResourceError::isolatedCopy): Deleted.
+
+        Removed platform-specific isolatedCopy, and re-indented the header:
+        * platform/network/cf/ResourceRequest.h:
+        (WebCore::ResourceRequest::ResourceRequest):
+        (WebCore::ResourceRequest::encodingRequiresPlatformData):
+        (WebCore::ResourceRequest::cachePartition):
+        (WebCore::ResourceRequest::setCachePartition):
+        (WebCore::ResourceRequest::setDomainForCachePartition):
+        (WebCore::ResourceRequest::resourcePrioritiesEnabled):
+        (WebCore::ResourceRequest::isolatedCopy): Deleted.
+
+        * platform/network/cf/ResourceResponse.h:
+        (WebCore::ResourceResponse::isolatedCopy): Deleted.
+
 2016-06-02  Chris Dumez  <cdumez@apple.com>
 
         Modernize various lambda captures
index 52e1f2a..97e02f8 100644 (file)
@@ -96,17 +96,16 @@ WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(ThreadableLoaderClien
     auto contentSecurityPolicyCopy = std::make_unique<ContentSecurityPolicy>(*securityOrigin);
     contentSecurityPolicyCopy->copyStateFrom(contentSecurityPolicy);
 
-    m_loaderProxy.postTaskToLoader([this, requestData = request.copyData(), options = options.isolatedCopy(), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy), outgoingReferrer = outgoingReferrer.isolatedCopy()](ScriptExecutionContext& context) mutable {
+    m_loaderProxy.postTaskToLoader([this, request = request.isolatedCopy(), options = options.isolatedCopy(), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy), outgoingReferrer = outgoingReferrer.isolatedCopy()](ScriptExecutionContext& context) mutable {
         ASSERT(isMainThread());
         Document& document = downcast<Document>(context);
 
-        auto request = ResourceRequest::adopt(WTFMove(requestData));
-        request->setHTTPReferrer(outgoingReferrer);
+        request.setHTTPReferrer(outgoingReferrer);
 
         // FIXME: If the a site requests a local resource, then this will return a non-zero value but the sync path
         // will return a 0 value. Either this should return 0 or the other code path should do a callback with
         // a failure.
-        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, *options, WTFMove(contentSecurityPolicyCopy));
+        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, request, *options, WTFMove(contentSecurityPolicyCopy));
         ASSERT(m_mainThreadLoader || m_loadingFinished);
     });
 }
@@ -163,10 +162,9 @@ void WorkerThreadableLoader::MainThreadBridge::didSendData(unsigned long long by
 void WorkerThreadableLoader::MainThreadBridge::didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
 {
     Ref<ThreadableLoaderClientWrapper> protectedWorkerClientWrapper = *m_workerClientWrapper;
-    m_loaderProxy.postTaskForModeToWorkerGlobalScope([protectedWorkerClientWrapper = WTFMove(protectedWorkerClientWrapper), identifier, responseData = response.copyData()] (ScriptExecutionContext& context) mutable {
+    m_loaderProxy.postTaskForModeToWorkerGlobalScope([protectedWorkerClientWrapper = WTFMove(protectedWorkerClientWrapper), identifier, response = response.isolatedCopy()] (ScriptExecutionContext& context) mutable {
         ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-        auto response(ResourceResponse::adopt(WTFMove(responseData)));
-        protectedWorkerClientWrapper->didReceiveResponse(identifier, *response);
+        protectedWorkerClientWrapper->didReceiveResponse(identifier, response);
     }, m_taskMode);
 }
 
@@ -194,20 +192,18 @@ void WorkerThreadableLoader::MainThreadBridge::didFinishLoading(unsigned long id
 void WorkerThreadableLoader::MainThreadBridge::didFail(const ResourceError& error)
 {
     m_loadingFinished = true;
-    Ref<ThreadableLoaderClientWrapper> protectedWorkerClientWrapper = *m_workerClientWrapper;
-    m_loaderProxy.postTaskForModeToWorkerGlobalScope([protectedWorkerClientWrapper = WTFMove(protectedWorkerClientWrapper), error = error.copy()] (ScriptExecutionContext& context) mutable {
+    m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper = Ref<ThreadableLoaderClientWrapper>(*m_workerClientWrapper), error = error.isolatedCopy()] (ScriptExecutionContext& context) mutable {
         ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-        protectedWorkerClientWrapper->didFail(error);
+        workerClientWrapper->didFail(error);
     }, m_taskMode);
 }
 
 void WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck(const ResourceError& error)
 {
     m_loadingFinished = true;
-    Ref<ThreadableLoaderClientWrapper> protectedWorkerClientWrapper = *m_workerClientWrapper;
-    m_loaderProxy.postTaskForModeToWorkerGlobalScope([protectedWorkerClientWrapper = WTFMove(protectedWorkerClientWrapper), error = error.copy()] (ScriptExecutionContext& context) mutable {
+    m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper = Ref<ThreadableLoaderClientWrapper>(*m_workerClientWrapper), error = error.isolatedCopy()] (ScriptExecutionContext& context) mutable {
         ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-        protectedWorkerClientWrapper->didFailAccessControlCheck(error);
+        workerClientWrapper->didFailAccessControlCheck(error);
     }, m_taskMode);
 }
 
index 6f5a42a..693501e 100644 (file)
@@ -655,10 +655,8 @@ void MemoryCache::adjustSize(bool live, int delta)
 void MemoryCache::removeRequestFromSessionCaches(ScriptExecutionContext& context, const ResourceRequest& request)
 {
     if (is<WorkerGlobalScope>(context)) {
-        CrossThreadResourceRequestData* requestData = request.copyData().release();
-        downcast<WorkerGlobalScope>(context).thread().workerLoaderProxy().postTaskToLoader([requestData] (ScriptExecutionContext& context) {
-            auto request(ResourceRequest::adopt(std::unique_ptr<CrossThreadResourceRequestData>(requestData)));
-            MemoryCache::removeRequestFromSessionCaches(context, *request);
+        downcast<WorkerGlobalScope>(context).thread().workerLoaderProxy().postTaskToLoader([request = request.isolatedCopy()] (ScriptExecutionContext& context) {
+            MemoryCache::removeRequestFromSessionCaches(context, request);
         });
         return;
     }
index ce58f8e..10bbbaa 100644 (file)
@@ -31,7 +31,7 @@ namespace WebCore {
 
 const char* const errorDomainWebKitInternal = "WebKitInternal";
 
-ResourceError ResourceErrorBase::copy() const
+ResourceError ResourceErrorBase::isolatedCopy() const
 {
     lazyInit();
 
index a80e761..77f4d60 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef ResourceErrorBase_h
-#define ResourceErrorBase_h
+#pragma once
 
 #include "URL.h"
 #include <wtf/text/WTFString.h>
@@ -37,8 +36,7 @@ extern const char* const errorDomainWebKitInternal; // Used for errors that won'
 
 class ResourceErrorBase {
 public:
-    // Makes a deep copy. Useful for when you need to use a ResourceError on another thread.
-    ResourceError copy() const;
+    ResourceError isolatedCopy() const;
 
     bool isNull() const { return m_isNull; }
 
@@ -99,5 +97,3 @@ inline bool operator==(const ResourceError& a, const ResourceError& b) { return
 inline bool operator!=(const ResourceError& a, const ResourceError& b) { return !(a == b); }
 
 } // namespace WebCore
-
-#endif // ResourceErrorBase_h
index 624f99b..34bb76a 100644 (file)
@@ -49,19 +49,27 @@ inline const ResourceRequest& ResourceRequestBase::asResourceRequest() const
     return *static_cast<const ResourceRequest*>(this);
 }
 
-std::unique_ptr<ResourceRequest> ResourceRequestBase::adopt(std::unique_ptr<CrossThreadResourceRequestData> data)
+ResourceRequest ResourceRequestBase::isolatedCopy() const
 {
-    auto request = std::make_unique<ResourceRequest>();
-    request->setURL(data->url);
-    request->setCachePolicy(data->cachePolicy);
-    request->setTimeoutInterval(data->timeoutInterval);
-    request->setFirstPartyForCookies(data->firstPartyForCookies);
-    request->setHTTPMethod(data->httpMethod);
-    request->setPriority(data->priority);
-    request->setRequester(data->requester);
+    ResourceRequest request;
+    request.setAsIsolatedCopy(*this);
+    return request;
+}
+
+void ResourceRequestBase::setAsIsolatedCopy(const ResourceRequestBase& other)
+{
+    auto data = other.copyData();
 
-    request->updateResourceRequest();
-    request->m_httpHeaderFields.adopt(WTFMove(data->httpHeaders));
+    setURL(data->url);
+    setCachePolicy(data->cachePolicy);
+    setTimeoutInterval(data->timeoutInterval);
+    setFirstPartyForCookies(data->firstPartyForCookies);
+    setHTTPMethod(data->httpMethod);
+    setPriority(data->priority);
+    setRequester(data->requester);
+
+    updateResourceRequest();
+    m_httpHeaderFields.adopt(WTFMove(data->httpHeaders));
 
     size_t encodingCount = data->responseContentDispositionEncodingFallbackArray.size();
     if (encodingCount > 0) {
@@ -74,12 +82,12 @@ std::unique_ptr<ResourceRequest> ResourceRequestBase::adopt(std::unique_ptr<Cros
                 encoding3 = data->responseContentDispositionEncodingFallbackArray[2];
         }
         ASSERT(encodingCount <= 3);
-        request->setResponseContentDispositionEncodingFallbackArray(encoding1, encoding2, encoding3);
+        setResponseContentDispositionEncodingFallbackArray(encoding1, encoding2, encoding3);
     }
-    request->setHTTPBody(data->httpBody.copyRef());
-    request->setAllowCookies(data->allowCookies);
-    request->doPlatformAdopt(WTFMove(data));
-    return request;
+    setHTTPBody(data->httpBody.copyRef());
+    setAllowCookies(data->allowCookies);
+
+    const_cast<ResourceRequest&>(asResourceRequest()).doPlatformAdopt(WTFMove(data));
 }
 
 std::unique_ptr<CrossThreadResourceRequestData> ResourceRequestBase::copyData() const
index 285fdac..6b163cb 100644 (file)
 
 namespace WebCore {
 
-    enum ResourceRequestCachePolicy {
-        UseProtocolCachePolicy, // normal load
-        ReloadIgnoringCacheData, // reload
-        ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data
-        ReturnCacheDataDontLoad  // results of a post - allow stale data and only use cache
-    };
-
-    enum HTTPBodyUpdatePolicy {
-        DoNotUpdateHTTPBody,
-        UpdateHTTPBody
-    };
-
-    class ResourceRequest;
-    struct CrossThreadResourceRequestData;
-
-    // Do not use this type directly.  Use ResourceRequest instead.
-    class ResourceRequestBase {
-        WTF_MAKE_FAST_ALLOCATED;
-    public:
-        WEBCORE_EXPORT static std::unique_ptr<ResourceRequest> adopt(std::unique_ptr<CrossThreadResourceRequestData>);
-
-        // Gets a copy of the data suitable for passing to another thread.
-        WEBCORE_EXPORT std::unique_ptr<CrossThreadResourceRequestData> copyData() const;
-
-        WEBCORE_EXPORT bool isNull() const;
-        WEBCORE_EXPORT bool isEmpty() const;
-
-        WEBCORE_EXPORT const URL& url() const;
-        WEBCORE_EXPORT void setURL(const URL& url);
-
-        WEBCORE_EXPORT void removeCredentials();
-
-        WEBCORE_EXPORT ResourceRequestCachePolicy cachePolicy() const;
-        WEBCORE_EXPORT void setCachePolicy(ResourceRequestCachePolicy cachePolicy);
-        
-        double timeoutInterval() const; // May return 0 when using platform default.
-        void setTimeoutInterval(double timeoutInterval);
-        
-        WEBCORE_EXPORT const URL& firstPartyForCookies() const;
-        WEBCORE_EXPORT void setFirstPartyForCookies(const URL&);
-        
-        WEBCORE_EXPORT const String& httpMethod() const;
-        WEBCORE_EXPORT void setHTTPMethod(const String& httpMethod);
-        
-        WEBCORE_EXPORT const HTTPHeaderMap& httpHeaderFields() const;
-        WEBCORE_EXPORT void setHTTPHeaderFields(HTTPHeaderMap);
-
-        WEBCORE_EXPORT String httpHeaderField(const String& name) const;
-        WEBCORE_EXPORT String httpHeaderField(HTTPHeaderName) const;
-        WEBCORE_EXPORT void setHTTPHeaderField(const String& name, const String& value);
-        WEBCORE_EXPORT void setHTTPHeaderField(HTTPHeaderName, const String& value);
-        void addHTTPHeaderField(HTTPHeaderName, const String& value);
-        void addHTTPHeaderField(const String& name, const String& value);
-
-        // Instead of passing a string literal to any of these functions, just use a HTTPHeaderName instead.
-        template<size_t length> String httpHeaderField(const char (&)[length]) const = delete;
-        template<size_t length> void setHTTPHeaderField(const char (&)[length], const String&) = delete;
-        template<size_t length> void addHTTPHeaderField(const char (&)[length], const String&) = delete;
-
-        WEBCORE_EXPORT void clearHTTPAuthorization();
-
-        WEBCORE_EXPORT String httpContentType() const;
-        WEBCORE_EXPORT void setHTTPContentType(const String&);
-        void clearHTTPContentType();
-
-        WEBCORE_EXPORT String httpReferrer() const;
-        WEBCORE_EXPORT void setHTTPReferrer(const String&);
-        WEBCORE_EXPORT void clearHTTPReferrer();
-        
-        String httpOrigin() const;
-        void setHTTPOrigin(const String&);
-        WEBCORE_EXPORT void clearHTTPOrigin();
-
-        WEBCORE_EXPORT String httpUserAgent() const;
-        WEBCORE_EXPORT void setHTTPUserAgent(const String&);
-        void clearHTTPUserAgent();
-
-        String httpAccept() const;
-        void setHTTPAccept(const String&);
-        void clearHTTPAccept();
-
-        void clearHTTPAcceptEncoding();
-
-        const Vector<String>& responseContentDispositionEncodingFallbackArray() const { return m_responseContentDispositionEncodingFallbackArray; }
-        WEBCORE_EXPORT void setResponseContentDispositionEncodingFallbackArray(const String& encoding1, const String& encoding2 = String(), const String& encoding3 = String());
-
-        WEBCORE_EXPORT FormData* httpBody() const;
-        WEBCORE_EXPORT void setHTTPBody(RefPtr<FormData>&&);
-
-        bool allowCookies() const;
-        void setAllowCookies(bool allowCookies);
-
-        WEBCORE_EXPORT ResourceLoadPriority priority() const;
-        WEBCORE_EXPORT void setPriority(ResourceLoadPriority);
-
-        WEBCORE_EXPORT bool isConditional() const;
-        WEBCORE_EXPORT void makeUnconditional();
-
-        // Whether the associated ResourceHandleClient needs to be notified of
-        // upload progress made for that resource.
-        bool reportUploadProgress() const { return m_reportUploadProgress; }
-        void setReportUploadProgress(bool reportUploadProgress) { m_reportUploadProgress = reportUploadProgress; }
-
-        // Whether the timing information should be collected for the request.
-        bool reportLoadTiming() const { return m_reportLoadTiming; }
-        void setReportLoadTiming(bool reportLoadTiming) { m_reportLoadTiming = reportLoadTiming; }
-
-        // Whether actual headers being sent/received should be collected and reported for the request.
-        bool reportRawHeaders() const { return m_reportRawHeaders; }
-        void setReportRawHeaders(bool reportRawHeaders) { m_reportRawHeaders = reportRawHeaders; }
-
-        // Whether this request should be hidden from the Inspector.
-        bool hiddenFromInspector() const { return m_hiddenFromInspector; }
-        void setHiddenFromInspector(bool hiddenFromInspector) { m_hiddenFromInspector = hiddenFromInspector; }
-
-        enum class Requester { Unspecified, Main, XHR, Media };
-        Requester requester() const { return m_requester; }
-        void setRequester(Requester requester) { m_requester = requester; }
+enum ResourceRequestCachePolicy {
+    UseProtocolCachePolicy, // normal load
+    ReloadIgnoringCacheData, // reload
+    ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data
+    ReturnCacheDataDontLoad  // results of a post - allow stale data and only use cache
+};
+
+enum HTTPBodyUpdatePolicy {
+    DoNotUpdateHTTPBody,
+    UpdateHTTPBody
+};
+
+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 bool isNull() const;
+    WEBCORE_EXPORT bool isEmpty() const;
+
+    WEBCORE_EXPORT const URL& url() const;
+    WEBCORE_EXPORT void setURL(const URL& url);
+
+    WEBCORE_EXPORT void removeCredentials();
+
+    WEBCORE_EXPORT ResourceRequestCachePolicy cachePolicy() const;
+    WEBCORE_EXPORT void setCachePolicy(ResourceRequestCachePolicy cachePolicy);
+    
+    double timeoutInterval() const; // May return 0 when using platform default.
+    void setTimeoutInterval(double timeoutInterval);
+    
+    WEBCORE_EXPORT const URL& firstPartyForCookies() const;
+    WEBCORE_EXPORT void setFirstPartyForCookies(const URL&);
+    
+    WEBCORE_EXPORT const String& httpMethod() const;
+    WEBCORE_EXPORT void setHTTPMethod(const String& httpMethod);
+    
+    WEBCORE_EXPORT const HTTPHeaderMap& httpHeaderFields() const;
+    WEBCORE_EXPORT void setHTTPHeaderFields(HTTPHeaderMap);
+
+    WEBCORE_EXPORT String httpHeaderField(const String& name) const;
+    WEBCORE_EXPORT String httpHeaderField(HTTPHeaderName) const;
+    WEBCORE_EXPORT void setHTTPHeaderField(const String& name, const String& value);
+    WEBCORE_EXPORT void setHTTPHeaderField(HTTPHeaderName, const String& value);
+    void addHTTPHeaderField(HTTPHeaderName, const String& value);
+    void addHTTPHeaderField(const String& name, const String& value);
+
+    // Instead of passing a string literal to any of these functions, just use a HTTPHeaderName instead.
+    template<size_t length> String httpHeaderField(const char (&)[length]) const = delete;
+    template<size_t length> void setHTTPHeaderField(const char (&)[length], const String&) = delete;
+    template<size_t length> void addHTTPHeaderField(const char (&)[length], const String&) = delete;
+
+    WEBCORE_EXPORT void clearHTTPAuthorization();
+
+    WEBCORE_EXPORT String httpContentType() const;
+    WEBCORE_EXPORT void setHTTPContentType(const String&);
+    void clearHTTPContentType();
+
+    WEBCORE_EXPORT String httpReferrer() const;
+    WEBCORE_EXPORT void setHTTPReferrer(const String&);
+    WEBCORE_EXPORT void clearHTTPReferrer();
+    
+    String httpOrigin() const;
+    void setHTTPOrigin(const String&);
+    WEBCORE_EXPORT void clearHTTPOrigin();
+
+    WEBCORE_EXPORT String httpUserAgent() const;
+    WEBCORE_EXPORT void setHTTPUserAgent(const String&);
+    void clearHTTPUserAgent();
+
+    String httpAccept() const;
+    void setHTTPAccept(const String&);
+    void clearHTTPAccept();
+
+    void clearHTTPAcceptEncoding();
+
+    const Vector<String>& responseContentDispositionEncodingFallbackArray() const { return m_responseContentDispositionEncodingFallbackArray; }
+    WEBCORE_EXPORT void setResponseContentDispositionEncodingFallbackArray(const String& encoding1, const String& encoding2 = String(), const String& encoding3 = String());
+
+    WEBCORE_EXPORT FormData* httpBody() const;
+    WEBCORE_EXPORT void setHTTPBody(RefPtr<FormData>&&);
+
+    bool allowCookies() const;
+    void setAllowCookies(bool allowCookies);
+
+    WEBCORE_EXPORT ResourceLoadPriority priority() const;
+    WEBCORE_EXPORT void setPriority(ResourceLoadPriority);
+
+    WEBCORE_EXPORT bool isConditional() const;
+    WEBCORE_EXPORT void makeUnconditional();
+
+    // Whether the associated ResourceHandleClient needs to be notified of
+    // upload progress made for that resource.
+    bool reportUploadProgress() const { return m_reportUploadProgress; }
+    void setReportUploadProgress(bool reportUploadProgress) { m_reportUploadProgress = reportUploadProgress; }
+
+    // Whether the timing information should be collected for the request.
+    bool reportLoadTiming() const { return m_reportLoadTiming; }
+    void setReportLoadTiming(bool reportLoadTiming) { m_reportLoadTiming = reportLoadTiming; }
+
+    // Whether actual headers being sent/received should be collected and reported for the request.
+    bool reportRawHeaders() const { return m_reportRawHeaders; }
+    void setReportRawHeaders(bool reportRawHeaders) { m_reportRawHeaders = reportRawHeaders; }
+
+    // Whether this request should be hidden from the Inspector.
+    bool hiddenFromInspector() const { return m_hiddenFromInspector; }
+    void setHiddenFromInspector(bool hiddenFromInspector) { m_hiddenFromInspector = hiddenFromInspector; }
+
+    enum class Requester { Unspecified, Main, XHR, Media };
+    Requester requester() const { return m_requester; }
+    void setRequester(Requester requester) { m_requester = requester; }
 
 #if !PLATFORM(COCOA)
-        bool encodingRequiresPlatformData() const { return true; }
+    bool encodingRequiresPlatformData() const { return true; }
 #endif
-        template<class Encoder> void encodeWithoutPlatformData(Encoder&) const;
-        template<class Decoder> bool decodeWithoutPlatformData(Decoder&);
+    template<class Encoder> void encodeWithoutPlatformData(Encoder&) const;
+    template<class Decoder> bool decodeWithoutPlatformData(Decoder&);
 
-        WEBCORE_EXPORT static double defaultTimeoutInterval(); // May return 0 when using platform default.
-        WEBCORE_EXPORT static void setDefaultTimeoutInterval(double);
+    WEBCORE_EXPORT static double defaultTimeoutInterval(); // May return 0 when using platform default.
+    WEBCORE_EXPORT static void setDefaultTimeoutInterval(double);
 
 #if PLATFORM(IOS)
-        WEBCORE_EXPORT static bool defaultAllowCookies();
-        WEBCORE_EXPORT static void setDefaultAllowCookies(bool);
+    WEBCORE_EXPORT static bool defaultAllowCookies();
+    WEBCORE_EXPORT static void setDefaultAllowCookies(bool);
 #endif
 
-        static bool compare(const ResourceRequest&, const ResourceRequest&);
-
-    protected:
-        // Used when ResourceRequest is initialized from a platform representation of the request
-        ResourceRequestBase()
-            : m_platformRequestUpdated(true)
-            , m_platformRequestBodyUpdated(true)
-        {
-        }
-
-        ResourceRequestBase(const URL& url, ResourceRequestCachePolicy policy)
-            : m_url(url)
-            , m_timeoutInterval(s_defaultTimeoutInterval)
-            , m_httpMethod(ASCIILiteral("GET"))
-            , m_cachePolicy(policy)
+    static bool compare(const ResourceRequest&, const ResourceRequest&);
+
+protected:
+    // Used when ResourceRequest is initialized from a platform representation of the request
+    ResourceRequestBase()
+        : m_platformRequestUpdated(true)
+        , m_platformRequestBodyUpdated(true)
+    {
+    }
+
+    ResourceRequestBase(const URL& url, ResourceRequestCachePolicy policy)
+        : m_url(url)
+        , m_timeoutInterval(s_defaultTimeoutInterval)
+        , m_httpMethod(ASCIILiteral("GET"))
+        , m_cachePolicy(policy)
 #if !PLATFORM(IOS)
-            , m_allowCookies(true)
+        , m_allowCookies(true)
 #else
-            , m_allowCookies(ResourceRequestBase::defaultAllowCookies())
+        , m_allowCookies(ResourceRequestBase::defaultAllowCookies())
 #endif
-            , m_resourceRequestUpdated(true)
-            , m_resourceRequestBodyUpdated(true)
-        {
-        }
-
-        void updatePlatformRequest(HTTPBodyUpdatePolicy = DoNotUpdateHTTPBody) const;
-        void updateResourceRequest(HTTPBodyUpdatePolicy = DoNotUpdateHTTPBody) const;
-
-        // The ResourceRequest subclass may "shadow" this method to compare platform specific fields
-        static bool platformCompare(const ResourceRequest&, const ResourceRequest&) { return true; }
-
-        URL m_url;
-        double m_timeoutInterval; // 0 is a magic value for platform default on platforms that have one.
-        URL m_firstPartyForCookies;
-        String m_httpMethod;
-        HTTPHeaderMap m_httpHeaderFields;
-        Vector<String> m_responseContentDispositionEncodingFallbackArray;
-        RefPtr<FormData> m_httpBody;
-        ResourceRequestCachePolicy m_cachePolicy { UseProtocolCachePolicy };
-        bool m_allowCookies { false };
-        mutable bool m_resourceRequestUpdated { false };
-        mutable bool m_platformRequestUpdated { false };
-        mutable bool m_resourceRequestBodyUpdated { false };
-        mutable bool m_platformRequestBodyUpdated { false };
-        bool m_reportUploadProgress { false };
-        bool m_reportLoadTiming { false };
-        bool m_reportRawHeaders { false };
-        bool m_hiddenFromInspector { false };
-        ResourceLoadPriority m_priority { ResourceLoadPriority::Low };
-        Requester m_requester { Requester::Unspecified };
-
-    private:
-        const ResourceRequest& asResourceRequest() const;
-
-        WEBCORE_EXPORT static double s_defaultTimeoutInterval;
+        , m_resourceRequestUpdated(true)
+        , m_resourceRequestBodyUpdated(true)
+    {
+    }
+
+    void updatePlatformRequest(HTTPBodyUpdatePolicy = DoNotUpdateHTTPBody) const;
+    void updateResourceRequest(HTTPBodyUpdatePolicy = DoNotUpdateHTTPBody) const;
+
+    // The ResourceRequest subclass may "shadow" this method to compare platform specific fields
+    static bool platformCompare(const ResourceRequest&, const ResourceRequest&) { return true; }
+
+    URL m_url;
+    double m_timeoutInterval; // 0 is a magic value for platform default on platforms that have one.
+    URL m_firstPartyForCookies;
+    String m_httpMethod;
+    HTTPHeaderMap m_httpHeaderFields;
+    Vector<String> m_responseContentDispositionEncodingFallbackArray;
+    RefPtr<FormData> m_httpBody;
+    ResourceRequestCachePolicy m_cachePolicy { UseProtocolCachePolicy };
+    bool m_allowCookies { false };
+    mutable bool m_resourceRequestUpdated { false };
+    mutable bool m_platformRequestUpdated { false };
+    mutable bool m_resourceRequestBodyUpdated { false };
+    mutable bool m_platformRequestBodyUpdated { false };
+    bool m_reportUploadProgress { false };
+    bool m_reportLoadTiming { false };
+    bool m_reportRawHeaders { false };
+    bool m_hiddenFromInspector { false };
+    ResourceLoadPriority m_priority { ResourceLoadPriority::Low };
+    Requester m_requester { Requester::Unspecified };
+
+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;
+    static bool s_defaultAllowCookies;
 #endif
-    };
-
-    bool equalIgnoringHeaderFields(const ResourceRequestBase&, const ResourceRequestBase&);
-
-    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();
+};
+
+bool equalIgnoringHeaderFields(const ResourceRequestBase&, const ResourceRequestBase&);
+
+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();
+WEBCORE_EXPORT void initializeHTTPConnectionSettingsOnStartup();
 #endif
 
 template<class Encoder>
index 8aad98c..31ff4fa 100644 (file)
@@ -63,23 +63,26 @@ ResourceResponseBase::ResourceResponseBase(const URL& url, const String& mimeTyp
 {
 }
 
-std::unique_ptr<ResourceResponse> ResourceResponseBase::adopt(std::unique_ptr<CrossThreadResourceResponseData> data)
-{
-    auto response = std::make_unique<ResourceResponse>();
-    response->setURL(data->m_url);
-    response->setMimeType(data->m_mimeType);
-    response->setExpectedContentLength(data->m_expectedContentLength);
-    response->setTextEncodingName(data->m_textEncodingName);
-
-    response->setHTTPStatusCode(data->m_httpStatusCode);
-    response->setHTTPStatusText(data->m_httpStatusText);
-    response->setHTTPVersion(data->m_httpVersion);
-
-    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));
+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.setHTTPStatusCode(data->m_httpStatusCode);
+    response.setHTTPStatusText(data->m_httpStatusText);
+    response.setHTTPVersion(data->m_httpVersion);
+
+    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));
+
     return response;
 }
 
index 6af490a..5fff359 100644 (file)
@@ -24,8 +24,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef ResourceResponseBase_h
-#define ResourceResponseBase_h
+#pragma once
 
 #include "CacheValidation.h"
 #include "CertificateInfo.h"
@@ -47,10 +46,7 @@ struct CrossThreadResourceResponseData;
 class ResourceResponseBase {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static std::unique_ptr<ResourceResponse> adopt(std::unique_ptr<CrossThreadResourceResponseData>);
-
-    // Gets a copy of the data suitable for passing to another thread.
-    std::unique_ptr<CrossThreadResourceResponseData> copyData() const;
+    ResourceResponse isolatedCopy() const;
 
     bool isNull() const { return m_isNull; }
     WEBCORE_EXPORT bool isHTTP() const;
@@ -163,6 +159,9 @@ 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;
@@ -293,5 +292,3 @@ public:
 };
 
 } // namespace WebCore
-
-#endif // ResourceResponseBase_h
index b8fd6a7..c36bdca 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef ResourceError_h
-#define ResourceError_h
+#pragma once
 
 #include "ResourceErrorBase.h"
 
@@ -61,8 +60,6 @@ public:
     WEBCORE_EXPORT CFErrorRef cfError() const;
     WEBCORE_EXPORT operator CFErrorRef() const;
 
-    ResourceError isolatedCopy() const { return copy(); }
-
 #if USE(CFNETWORK)
 #if PLATFORM(WIN)
     ResourceError(const String& domain, int errorCode, const URL& failingURL, const String& localizedDescription, CFDataRef certificate);
@@ -102,5 +99,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // ResourceError_h
index c30f4a1..c743f65 100644 (file)
@@ -38,120 +38,118 @@ typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
 
 namespace WebCore {
 
-    class ResourceRequest : public ResourceRequestBase {
-    public:
-        ResourceRequest(const String& url) 
-            : ResourceRequestBase(URL(ParsedURLString, url), UseProtocolCachePolicy)
-        {
-        }
-
-        ResourceRequest(const URL& url) 
-            : ResourceRequestBase(url, UseProtocolCachePolicy)
-        {
-        }
-
-        ResourceRequest(const URL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
-            : ResourceRequestBase(url, policy)
-        {
-            setHTTPReferrer(referrer);
-        }
-        
-        ResourceRequest()
-            : ResourceRequestBase(URL(), UseProtocolCachePolicy)
-        {
-        }
-        
+class ResourceRequest : public ResourceRequestBase {
+public:
+    ResourceRequest(const String& url) 
+        : ResourceRequestBase(URL(ParsedURLString, url), UseProtocolCachePolicy)
+    {
+    }
+
+    ResourceRequest(const URL& url) 
+        : ResourceRequestBase(url, UseProtocolCachePolicy)
+    {
+    }
+
+    ResourceRequest(const URL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
+        : ResourceRequestBase(url, policy)
+    {
+        setHTTPReferrer(referrer);
+    }
+    
+    ResourceRequest()
+        : ResourceRequestBase(URL(), UseProtocolCachePolicy)
+    {
+    }
+    
 #if USE(CFNETWORK)
 #if PLATFORM(COCOA)
-        WEBCORE_EXPORT ResourceRequest(NSURLRequest *);
-        void updateNSURLRequest();
-        void clearOrUpdateNSURLRequest();
+    WEBCORE_EXPORT ResourceRequest(NSURLRequest *);
+    void updateNSURLRequest();
+    void clearOrUpdateNSURLRequest();
 #endif
 
-        ResourceRequest(CFURLRequestRef cfRequest)
-            : ResourceRequestBase()
-            , m_cfRequest(cfRequest)
-        {
-        }
+    ResourceRequest(CFURLRequestRef cfRequest)
+        : ResourceRequestBase()
+        , m_cfRequest(cfRequest)
+    {
+    }
 #else
-        ResourceRequest(NSURLRequest *nsRequest)
-            : ResourceRequestBase()
-            , m_nsRequest(nsRequest)
-        {
-        }
+    ResourceRequest(NSURLRequest *nsRequest)
+        : ResourceRequestBase()
+        , m_nsRequest(nsRequest)
+    {
+    }
 #endif
 
-        ResourceRequest isolatedCopy() const { return *ResourceRequest::adopt(copyData()); }
-
-        WEBCORE_EXPORT void updateFromDelegatePreservingOldProperties(const ResourceRequest&);
+    WEBCORE_EXPORT void updateFromDelegatePreservingOldProperties(const ResourceRequest&);
 
 #if PLATFORM(MAC)
-        void applyWebArchiveHackForMail();
+    void applyWebArchiveHackForMail();
 #endif
 #if PLATFORM(COCOA)
 #if USE(CFNETWORK)
-        bool encodingRequiresPlatformData() const { return m_httpBody || m_cfRequest; }
+    bool encodingRequiresPlatformData() const { return m_httpBody || m_cfRequest; }
 #else
-        bool encodingRequiresPlatformData() const { return m_httpBody || m_nsRequest; }
+    bool encodingRequiresPlatformData() const { return m_httpBody || m_nsRequest; }
 #endif
-        WEBCORE_EXPORT NSURLRequest *nsURLRequest(HTTPBodyUpdatePolicy) const;
+    WEBCORE_EXPORT NSURLRequest *nsURLRequest(HTTPBodyUpdatePolicy) const;
 
-        WEBCORE_EXPORT static CFStringRef isUserInitiatedKey();
+    WEBCORE_EXPORT static CFStringRef isUserInitiatedKey();
 #endif
 
 #if ENABLE(CACHE_PARTITIONING)
-        WEBCORE_EXPORT static String partitionName(const String& domain);
-        const String& cachePartition() const { return m_cachePartition.isNull() ? emptyString() : m_cachePartition; }
-        void setCachePartition(const String& cachePartition)
-        {
-            ASSERT(cachePartition == partitionName(cachePartition));
-            m_cachePartition = cachePartition;
-        }
-        void setDomainForCachePartition(const String& domain) { m_cachePartition = partitionName(domain); }
+    WEBCORE_EXPORT static String partitionName(const String& domain);
+    const String& cachePartition() const { return m_cachePartition.isNull() ? emptyString() : m_cachePartition; }
+    void setCachePartition(const String& cachePartition)
+    {
+        ASSERT(cachePartition == partitionName(cachePartition));
+        m_cachePartition = cachePartition;
+    }
+    void setDomainForCachePartition(const String& domain) { m_cachePartition = partitionName(domain); }
 #endif
 
 #if PLATFORM(COCOA) || USE(CFNETWORK)
-        WEBCORE_EXPORT CFURLRequestRef cfURLRequest(HTTPBodyUpdatePolicy) const;
-        void setStorageSession(CFURLStorageSessionRef);
+    WEBCORE_EXPORT CFURLRequestRef cfURLRequest(HTTPBodyUpdatePolicy) const;
+    void setStorageSession(CFURLStorageSessionRef);
 #endif
 
-        WEBCORE_EXPORT static bool httpPipeliningEnabled();
-        WEBCORE_EXPORT static void setHTTPPipeliningEnabled(bool);
+    WEBCORE_EXPORT static bool httpPipeliningEnabled();
+    WEBCORE_EXPORT static void setHTTPPipeliningEnabled(bool);
 
-        static bool resourcePrioritiesEnabled();
+    static bool resourcePrioritiesEnabled();
 
-    private:
-        friend class ResourceRequestBase;
+private:
+    friend class ResourceRequestBase;
 
-        void doUpdatePlatformRequest();
-        void doUpdateResourceRequest();
-        void doUpdatePlatformHTTPBody();
-        void doUpdateResourceHTTPBody();
+    void doUpdatePlatformRequest();
+    void doUpdateResourceRequest();
+    void doUpdatePlatformHTTPBody();
+    void doUpdateResourceHTTPBody();
 
-        std::unique_ptr<CrossThreadResourceRequestData> doPlatformCopyData(std::unique_ptr<CrossThreadResourceRequestData>) const;
-        void doPlatformAdopt(std::unique_ptr<CrossThreadResourceRequestData>);
+    std::unique_ptr<CrossThreadResourceRequestData> doPlatformCopyData(std::unique_ptr<CrossThreadResourceRequestData>) const;
+    void doPlatformAdopt(std::unique_ptr<CrossThreadResourceRequestData>);
 
 #if USE(CFNETWORK)
-        RetainPtr<CFURLRequestRef> m_cfRequest;
+    RetainPtr<CFURLRequestRef> m_cfRequest;
 #endif
 #if PLATFORM(COCOA)
-        RetainPtr<NSURLRequest> m_nsRequest;
+    RetainPtr<NSURLRequest> m_nsRequest;
 #endif
 #if ENABLE(CACHE_PARTITIONING)
-        String m_cachePartition;
+    String m_cachePartition;
 #endif
 
-        static bool s_httpPipeliningEnabled;
-    };
+    static bool s_httpPipeliningEnabled;
+};
 
-    struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase {
+struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase {
 #if ENABLE(CACHE_PARTITIONING)
-        String m_cachePartition;
+    String m_cachePartition;
 #endif
-    };
+};
 
-    inline bool ResourceRequest::resourcePrioritiesEnabled()
-    {
+inline bool ResourceRequest::resourcePrioritiesEnabled()
+{
 #if PLATFORM(MAC)
     return true;
 #elif PLATFORM(IOS)
@@ -159,7 +157,6 @@ namespace WebCore {
 #elif PLATFORM(WIN)
     return false;
 #endif
-    }
-
+}
 
 } // namespace WebCore
index a0f7d2d..83946cf 100644 (file)
@@ -72,8 +72,6 @@ public:
     {
     }
 
-    ResourceResponse isolatedCopy() const { return *ResourceResponse::adopt(copyData()); }
-
     unsigned memoryUsage() const
     {
         // FIXME: Find some programmatic lighweight way to calculate ResourceResponse and associated classes.
index 62ec91f..b89452a 100644 (file)
@@ -1,3 +1,13 @@
+2016-06-02  Brady Eidson  <beidson@apple.com>
+
+        Overhaul cross-thread use of ResourceRequest, ResourceResponse, and ResourceError.
+        https://bugs.webkit.org/show_bug.cgi?id=158293
+
+        Reviewed by Darin Adler.
+
+        * NetworkProcess/cache/NetworkCacheEntry.cpp:
+        (WebKit::NetworkCache::Entry::Entry):
+
 2016-06-02  Chris Dumez  <cdumez@apple.com>
 
         Modernize various lambda captures
index f74cecf..b978b99 100644 (file)
@@ -54,10 +54,12 @@ Entry::Entry(const Key& key, const WebCore::ResourceResponse& response, const We
     , m_timeStamp(std::chrono::system_clock::now())
     , m_response(response)
     , m_varyingRequestHeaders(varyingRequestHeaders)
-    , m_redirectRequest(WebCore::ResourceRequest::adopt(redirectRequest.copyData())) // Don't include the underlying platform request object.
 {
     ASSERT(m_key.type() == "resource");
     // Redirect body is not needed even if exists.
+
+    m_redirectRequest = std::make_unique<WebCore::ResourceRequest>();
+    m_redirectRequest->setAsIsolatedCopy(redirectRequest);
     m_redirectRequest->setHTTPBody(nullptr);
 }