Fix AtomicString regression caused by r201603.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Jun 2016 05:40:40 +0000 (05:40 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Jun 2016 05:40:40 +0000 (05:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158338

Reviewed by Chris Dumez.

No new tests (Refactor, plus already caught by existing test configs).

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

* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::crossThreadData): Re-introduce the cross thread data concept,
  but more modern and clean this time.
(WebCore::ResourceResponseBase::fromCrossThreadData):
(WebCore::ResourceResponseBase::isolatedCopy): Deleted.
* platform/network/ResourceResponseBase.h:

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

Source/WebCore/ChangeLog
Source/WebCore/loader/WorkerThreadableLoader.cpp
Source/WebCore/platform/network/ResourceResponseBase.cpp
Source/WebCore/platform/network/ResourceResponseBase.h

index 5032070..6be3a4b 100644 (file)
@@ -1,3 +1,22 @@
+2016-06-02  Brady Eidson  <beidson@apple.com>
+
+        Fix AtomicString regression caused by r201603.
+        https://bugs.webkit.org/show_bug.cgi?id=158338
+
+        Reviewed by Chris Dumez.
+
+        No new tests (Refactor, plus already caught by existing test configs).
+
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveResponse):
+        
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore::ResourceResponseBase::crossThreadData): Re-introduce the cross thread data concept,
+          but more modern and clean this time.
+        (WebCore::ResourceResponseBase::fromCrossThreadData):
+        (WebCore::ResourceResponseBase::isolatedCopy): Deleted.
+        * platform/network/ResourceResponseBase.h:
+
 2016-06-02  Chris Dumez  <cdumez@apple.com>
 
         Drop BlobRegistryContext class as it is no longer needed
index 97e02f8..7560c59 100644 (file)
@@ -162,9 +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, response = response.isolatedCopy()] (ScriptExecutionContext& context) mutable {
+    m_loaderProxy.postTaskForModeToWorkerGlobalScope([protectedWorkerClientWrapper = WTFMove(protectedWorkerClientWrapper), identifier, responseData = response.crossThreadData()] (ScriptExecutionContext& context) mutable {
         ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-        protectedWorkerClientWrapper->didReceiveResponse(identifier, response);
+        protectedWorkerClientWrapper->didReceiveResponse(identifier, ResourceResponse::fromCrossThreadData(WTFMove(responseData)));
     }, m_taskMode);
 }
 
index 5b52876..bfcdba6 100644 (file)
@@ -63,23 +63,42 @@ ResourceResponseBase::ResourceResponseBase(const URL& url, const String& mimeTyp
 {
 }
 
-ResourceResponse ResourceResponseBase::isolatedCopy() const
+std::unique_ptr<ResourceResponseBase::CrossThreadData> ResourceResponseBase::crossThreadData() const
+{
+    auto data = std::make_unique<CrossThreadData>();
+
+    data->url = url().isolatedCopy();
+    data->mimeType = mimeType().isolatedCopy();
+    data->expectedContentLength = expectedContentLength();
+    data->textEncodingName = textEncodingName().isolatedCopy();
+
+    data->httpStatusCode = httpStatusCode();
+    data->httpStatusText = httpStatusText().isolatedCopy();
+    data->httpVersion = httpVersion().isolatedCopy();
+
+    data->httpHeaderFields = httpHeaderFields().isolatedCopy();
+    data->resourceLoadTiming = m_resourceLoadTiming.isolatedCopy();
+    data->type = m_type;
+
+    return data;
+}
+
+ResourceResponse ResourceResponseBase::fromCrossThreadData(std::unique_ptr<CrossThreadData>&& data)
 {
     ResourceResponse response;
 
-    response.setURL(url().isolatedCopy());
-    response.setMimeType(mimeType().isolatedCopy());
-    response.setExpectedContentLength(expectedContentLength());
-    response.setTextEncodingName(textEncodingName().isolatedCopy());
+    response.setURL(data->url);
+    response.setMimeType(data->mimeType);
+    response.setExpectedContentLength(data->expectedContentLength);
+    response.setTextEncodingName(data->textEncodingName);
 
-    response.setHTTPStatusCode(httpStatusCode());
-    response.setHTTPStatusText(httpStatusText().isolatedCopy());
-    response.setHTTPVersion(httpVersion().isolatedCopy());
+    response.setHTTPStatusCode(data->httpStatusCode);
+    response.setHTTPStatusText(data->httpStatusText);
+    response.setHTTPVersion(data->httpVersion);
 
-    response.lazyInit(AllFields);
-    response.m_httpHeaderFields = httpHeaderFields().isolatedCopy();
-    response.m_resourceLoadTiming = m_resourceLoadTiming.isolatedCopy();
-    response.m_type = m_type;
+    response.m_httpHeaderFields = WTFMove(data->httpHeaderFields);
+    response.m_resourceLoadTiming = data->resourceLoadTiming;
+    response.m_type = data->type;
 
     return response;
 }
index ad5107f..660f358 100644 (file)
@@ -45,7 +45,23 @@ class ResourceResponse;
 class ResourceResponseBase {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    ResourceResponse isolatedCopy() const;
+    enum class Type;
+
+    struct CrossThreadData {
+        URL url;
+        String mimeType;
+        long long expectedContentLength;
+        String textEncodingName;
+        int httpStatusCode;
+        String httpStatusText;
+        String httpVersion;
+        HTTPHeaderMap httpHeaderFields;
+        ResourceLoadTiming resourceLoadTiming;
+        Type type;
+    };
+
+    std::unique_ptr<CrossThreadData> crossThreadData() const;
+    static ResourceResponse fromCrossThreadData(std::unique_ptr<CrossThreadData>&&);
 
     bool isNull() const { return m_isNull; }
     WEBCORE_EXPORT bool isHTTP() const;