Merge ResourceHandleClient::willCacheResponseAsync with ResourceHandleClient::willCac...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Mar 2018 17:38:49 +0000 (17:38 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Mar 2018 17:38:49 +0000 (17:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183965

Reviewed by Chris Dumez.

Source/WebCore:

It turns out that ResourceHandleClient::willCacheResponseAsync didn't do anything and the logic in
ResourceHandleClient::willCacheResponse was not being called.  This makes it so there is one code
path and it executes the logic in ResourceHandleClient::willCacheResponse.

* loader/EmptyFrameLoaderClient.h:
* loader/FrameLoaderClient.h:
* loader/ResourceLoader.h:
* loader/SubresourceLoader.h:
* loader/cocoa/SubresourceLoaderCocoa.mm:
(WebCore::SubresourceLoader::willCacheResponseAsync):
(WebCore::SubresourceLoader::willCacheResponse): Deleted.
* loader/mac/ResourceLoaderMac.mm:
(WebCore::ResourceLoader::willCacheResponseAsync):
(WebCore::ResourceLoader::willCacheResponse): Deleted.
* platform/network/ResourceHandle.h:
* platform/network/ResourceHandleClient.cpp:
(WebCore::ResourceHandleClient::willCacheResponseAsync): Deleted.
* platform/network/ResourceHandleClient.h:
(WebCore::ResourceHandleClient::willCacheResponseAsync):
(WebCore::ResourceHandleClient::shouldCacheResponse):
(WebCore::ResourceHandleClient::willCacheResponse): Deleted.
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::ResourceHandle::continueWillCacheResponse): Deleted.
* platform/network/cf/ResourceHandleCFURLConnectionDelegate.h:
* platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::willCacheResponse):
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueWillCacheResponse): Deleted.
* platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.h:
* platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::continueWillCacheResponse): Deleted.
* platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h:
* platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:willCacheResponse:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate continueWillCacheResponse:]): Deleted.

Source/WebKit:

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::willCacheResponse const):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

Source/WebKitLegacy/mac:

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::willCacheResponse const):

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

23 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/EmptyFrameLoaderClient.h
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/loader/ResourceLoader.h
Source/WebCore/loader/SubresourceLoader.h
Source/WebCore/loader/cocoa/SubresourceLoaderCocoa.mm
Source/WebCore/loader/mac/ResourceLoaderMac.mm
Source/WebCore/platform/network/ResourceHandle.h
Source/WebCore/platform/network/ResourceHandleClient.cpp
Source/WebCore/platform/network/ResourceHandleClient.h
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegate.h
Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp
Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.h
Source/WebCore/platform/network/mac/ResourceHandleMac.mm
Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h
Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm

index d384258..38ad1b9 100644 (file)
@@ -1,3 +1,45 @@
+2018-03-26  Alex Christensen  <achristensen@webkit.org>
+
+        Merge ResourceHandleClient::willCacheResponseAsync with ResourceHandleClient::willCacheResponse
+        https://bugs.webkit.org/show_bug.cgi?id=183965
+
+        Reviewed by Chris Dumez.
+
+        It turns out that ResourceHandleClient::willCacheResponseAsync didn't do anything and the logic in
+        ResourceHandleClient::willCacheResponse was not being called.  This makes it so there is one code
+        path and it executes the logic in ResourceHandleClient::willCacheResponse.
+
+        * loader/EmptyFrameLoaderClient.h:
+        * loader/FrameLoaderClient.h:
+        * loader/ResourceLoader.h:
+        * loader/SubresourceLoader.h:
+        * loader/cocoa/SubresourceLoaderCocoa.mm:
+        (WebCore::SubresourceLoader::willCacheResponseAsync):
+        (WebCore::SubresourceLoader::willCacheResponse): Deleted.
+        * loader/mac/ResourceLoaderMac.mm:
+        (WebCore::ResourceLoader::willCacheResponseAsync):
+        (WebCore::ResourceLoader::willCacheResponse): Deleted.
+        * platform/network/ResourceHandle.h:
+        * platform/network/ResourceHandleClient.cpp:
+        (WebCore::ResourceHandleClient::willCacheResponseAsync): Deleted.
+        * platform/network/ResourceHandleClient.h:
+        (WebCore::ResourceHandleClient::willCacheResponseAsync):
+        (WebCore::ResourceHandleClient::shouldCacheResponse):
+        (WebCore::ResourceHandleClient::willCacheResponse): Deleted.
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::ResourceHandle::continueWillCacheResponse): Deleted.
+        * platform/network/cf/ResourceHandleCFURLConnectionDelegate.h:
+        * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
+        (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::willCacheResponse):
+        (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueWillCacheResponse): Deleted.
+        * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.h:
+        * platform/network/mac/ResourceHandleMac.mm:
+        (WebCore::ResourceHandle::continueWillCacheResponse): Deleted.
+        * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h:
+        * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
+        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willCacheResponse:]):
+        (-[WebCoreResourceHandleAsOperationQueueDelegate continueWillCacheResponse:]): Deleted.
+
 2018-03-26  Miguel Gomez  <magomez@igalia.com>
 
         [GTK][WPE] Upload correct buffer in BitmapTextureGL::updateContents()
index ef38fa4..07c32b8 100644 (file)
@@ -185,7 +185,7 @@ class WEBCORE_EXPORT EmptyFrameLoaderClient : public FrameLoaderClient {
 
 #if PLATFORM(COCOA)
     RemoteAXObjectRef accessibilityRemoteObject() final { return nullptr; }
-    NSCachedURLResponse *willCacheResponse(DocumentLoader*, unsigned long, NSCachedURLResponse *response) const final { return response; }
+    void willCacheResponse(DocumentLoader*, unsigned long, NSCachedURLResponse *response, CompletionHandler<void(NSCachedURLResponse *)>&& completionHandler) const final { completionHandler(response); }
 #endif
 
 #if USE(CFURLCONNECTION)
index 77c54d2..d941d26 100644 (file)
@@ -303,7 +303,7 @@ public:
 #if PLATFORM(COCOA)
     // Allow an accessibility object to retrieve a Frame parent if there's no PlatformWidget.
     virtual RemoteAXObjectRef accessibilityRemoteObject() = 0;
-    virtual NSCachedURLResponse* willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const = 0;
+    virtual void willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse*, CompletionHandler<void(NSCachedURLResponse *)>&&) const = 0;
     virtual NSDictionary *dataDetectionContext() { return nullptr; }
 #endif
 
index b0648ca..52a42f5 100644 (file)
@@ -161,7 +161,7 @@ protected:
     void didReceiveDataOrBuffer(const char*, unsigned, RefPtr<SharedBuffer>&&, long long encodedDataLength, DataPayloadType);
 
 #if PLATFORM(COCOA)
-    NSCachedURLResponse* willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override;
+    void willCacheResponseAsync(ResourceHandle*, NSCachedURLResponse*, CompletionHandler<void(NSCachedURLResponse *)>&&) override;
 #endif
 
     virtual void willSendRequestInternal(ResourceRequest&&, const ResourceResponse& redirectResponse, CompletionHandler<void(ResourceRequest&&)>&&);
index 08dfdfd..39a5743 100644 (file)
@@ -81,7 +81,7 @@ private:
     void didRetrieveDerivedDataFromCache(const String& type, SharedBuffer&) override;
 
 #if PLATFORM(COCOA)
-    NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override;
+    void willCacheResponseAsync(ResourceHandle*, NSCachedURLResponse*, CompletionHandler<void(NSCachedURLResponse *)>&&) override;
 #endif
 
     void releaseResources() override;
index f60360b..6e503ca 100644 (file)
 
 namespace WebCore {
 
-NSCachedURLResponse* SubresourceLoader::willCacheResponse(ResourceHandle* handle, NSCachedURLResponse* response)
+void SubresourceLoader::willCacheResponseAsync(ResourceHandle* handle, NSCachedURLResponse* response, CompletionHandler<void(NSCachedURLResponse *)>&& completionHandler)
 {
     DiskCacheMonitor::monitorFileBackingStoreCreation(request(), m_resource->sessionID(), [response _CFCachedURLResponse]);
     if (!m_resource->shouldCacheResponse(response.response))
-        return nullptr;
-    return ResourceLoader::willCacheResponse(handle, response);
+        return completionHandler(nullptr);
+    ResourceLoader::willCacheResponseAsync(handle, response, WTFMove(completionHandler));
 }
 
 }
index 018ec4e..274dac5 100644 (file)
 
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
+#include <wtf/CompletionHandler.h>
 
 namespace WebCore {
 
-NSCachedURLResponse* ResourceLoader::willCacheResponse(ResourceHandle*, NSCachedURLResponse* response)
+void ResourceLoader::willCacheResponseAsync(ResourceHandle*, NSCachedURLResponse* response, CompletionHandler<void(NSCachedURLResponse *)>&& completionHandler)
 {
     if (m_options.sendLoadCallbacks == DoNotSendCallbacks)
-        return nullptr;
-    return frameLoader()->client().willCacheResponse(documentLoader(), identifier(), response);
+        return completionHandler(nullptr);
+    frameLoader()->client().willCacheResponse(documentLoader(), identifier(), response, WTFMove(completionHandler));
 }
 
 }
index c3302fe..2a59272 100644 (file)
@@ -211,14 +211,6 @@ public:
     WEBCORE_EXPORT ResourceHandleClient* client() const;
     WEBCORE_EXPORT void clearClient();
 
-    // Called in response to ResourceHandleClient::willCacheResponseAsync().
-#if USE(CFURLCONNECTION)
-    WEBCORE_EXPORT void continueWillCacheResponse(CFCachedURLResponseRef);
-#endif
-#if PLATFORM(COCOA)
-    WEBCORE_EXPORT void continueWillCacheResponse(NSCachedURLResponse *);
-#endif
-
     WEBCORE_EXPORT void setDefersLoading(bool);
 
     WEBCORE_EXPORT ResourceRequest& firstRequest();
index af5c418..6e65bb8 100644 (file)
@@ -36,18 +36,6 @@ ResourceHandleClient::ResourceHandleClient() = default;
 
 ResourceHandleClient::~ResourceHandleClient() = default;
 
-#if USE(CFURLCONNECTION)
-void ResourceHandleClient::willCacheResponseAsync(ResourceHandle* handle, CFCachedURLResponseRef response)
-{
-    handle->continueWillCacheResponse(response);
-}
-#elif PLATFORM(COCOA)
-void ResourceHandleClient::willCacheResponseAsync(ResourceHandle* handle, NSCachedURLResponse *response)
-{
-    handle->continueWillCacheResponse(response);
-}
-#endif
-
 void ResourceHandleClient::didReceiveBuffer(ResourceHandle* handle, Ref<SharedBuffer>&& buffer, int encodedDataLength)
 {
     didReceiveData(handle, buffer->data(), buffer->size(), encodedDataLength);
index d5ae51d..676e74e 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include <wtf/CompletionHandler.h>
 #include <wtf/Forward.h>
 #include <wtf/Ref.h>
 
@@ -81,11 +82,11 @@ public:
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     WEBCORE_EXPORT virtual void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&, CompletionHandler<void(bool)>&&) = 0;
 #endif
-    // Client will pass an updated request using ResourceHandle::continueWillCacheResponse() when ready.
+
 #if USE(CFURLCONNECTION)
-    WEBCORE_EXPORT virtual void willCacheResponseAsync(ResourceHandle*, CFCachedURLResponseRef);
+    WEBCORE_EXPORT virtual void willCacheResponseAsync(ResourceHandle*, CFCachedURLResponseRef response, CompletionHandler<void(CFCachedURLResponseRef)>&& completionHandler) { completionHandler(response); }
 #elif PLATFORM(COCOA)
-    WEBCORE_EXPORT virtual void willCacheResponseAsync(ResourceHandle*, NSCachedURLResponse *);
+    WEBCORE_EXPORT virtual void willCacheResponseAsync(ResourceHandle*, NSCachedURLResponse *response, CompletionHandler<void(NSCachedURLResponse *)>&& completionHandler) { completionHandler(response); }
 #endif
 
     virtual bool shouldUseCredentialStorage(ResourceHandle*) { return false; }
@@ -96,14 +97,8 @@ public:
     virtual RetainPtr<CFDictionaryRef> connectionProperties(ResourceHandle*) { return nullptr; }
 #endif
 
-#if USE(CFURLCONNECTION)
-    virtual CFCachedURLResponseRef willCacheResponse(ResourceHandle*, CFCachedURLResponseRef response) { return response; }
-#if PLATFORM(WIN)
+#if PLATFORM(WIN) && USE(CFURLCONNECTION)
     virtual bool shouldCacheResponse(ResourceHandle*, CFCachedURLResponseRef) { return true; }
-#endif // PLATFORM(WIN)
-
-#elif PLATFORM(COCOA)
-    virtual NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse *response) { return response; }
 #endif
 };
 
index 0ad7ba2..97864fe 100644 (file)
@@ -663,11 +663,6 @@ void ResourceHandle::continueCanAuthenticateAgainstProtectionSpace(bool canAuthe
     d->m_connectionDelegate->continueCanAuthenticateAgainstProtectionSpace(canAuthenticate);
 }
 #endif
-
-void ResourceHandle::continueWillCacheResponse(CFCachedURLResponseRef response)
-{
-    d->m_connectionDelegate->continueWillCacheResponse(response);
-}
 #endif // USE(CFURLCONNECTION)
 
 } // namespace WebCore
index 3afc597..4778c27 100644 (file)
@@ -46,8 +46,6 @@ public:
     virtual void setupConnectionScheduling(CFURLConnectionRef) = 0;
     virtual void releaseHandle();
 
-    virtual void continueWillCacheResponse(CFCachedURLResponseRef) = 0;
-
 protected:
     RetainPtr<CFURLResponseRef> synthesizeRedirectResponseIfNecessary(CFURLRequestRef, CFURLResponseRef);
     ResourceRequest createResourceRequest(CFURLRequestRef, CFURLResponseRef);
index bbd44a0..95e7ffd 100644 (file)
@@ -294,17 +294,20 @@ CFCachedURLResponseRef ResourceHandleCFURLConnectionDelegateWithOperationQueue::
     }
 
     auto protectedThis = makeRef(*this);
-    auto work = [protectedThis = makeRef(*this), cachedResponse = RetainPtr<CFCachedURLResponseRef>(cachedResponse)] () {
+    auto work = [protectedThis = makeRef(*this), cachedResponse = RetainPtr<CFCachedURLResponseRef>(cachedResponse)] () mutable {
         auto& handle = protectedThis->m_handle;
-        
-        if (!protectedThis->hasHandle() || !handle->client() || !handle->connection()) {
-            protectedThis->continueWillCacheResponse(nullptr);
-            return;
-        }
+
+        auto completionHandler = [protectedThis = WTFMove(protectedThis)] (CFCachedURLResponseRef response) mutable {
+            protectedThis->m_cachedResponseResult = response;
+            protectedThis->m_semaphore.signal();
+        };
+
+        if (!handle || !handle->client() || !handle->connection())
+            return completionHandler(nullptr);
 
         LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::willCacheResponse(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
 
-        handle->client()->willCacheResponseAsync(handle, cachedResponse.get());
+        handle->client()->willCacheResponseAsync(handle, cachedResponse.get(), WTFMove(completionHandler));
     };
     
     if (m_messageQueue)
@@ -391,12 +394,6 @@ void ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueCanAuthent
 }
 #endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
 
-void ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueWillCacheResponse(CFCachedURLResponseRef response)
-{
-    m_cachedResponseResult = response;
-    m_semaphore.signal();
-}
-
 } // namespace WebCore
 
 #endif // USE(CFURLCONNECTION)
index 072a851..1136896 100644 (file)
@@ -58,7 +58,6 @@ private:
     void didSendBodyData(CFIndex totalBytesWritten, CFIndex totalBytesExpectedToWrite) override;
     Boolean shouldUseCredentialStorage() override;
 
-    void continueWillCacheResponse(CFCachedURLResponseRef) override;
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     Boolean canRespondToProtectionSpace(CFURLProtectionSpaceRef) override;
 #endif
index 83f65a7..297d3f6 100644 (file)
@@ -652,11 +652,6 @@ void ResourceHandle::receivedChallengeRejection(const AuthenticationChallenge& c
     clearAuthentication();
 }
 
-void ResourceHandle::continueWillCacheResponse(NSCachedURLResponse *response)
-{
-    [(id)delegate() continueWillCacheResponse:response];
-}
-
 void ResourceHandle::getConnectionTimingData(NSURLConnection *connection, NetworkLoadMetrics& timing)
 {
     copyTimingData([connection _timingData], timing);
index 917dd84..4835426 100644 (file)
@@ -51,7 +51,6 @@ class ResourceHandle;
 
 - (void)detachHandle;
 - (id)initWithHandle:(WebCore::ResourceHandle*)handle messageQueue:(MessageQueue<Function<void()>>*)messageQueue;
-- (void)continueWillCacheResponse:(NSCachedURLResponse *)response;
 @end
 
 @interface WebCoreResourceHandleWithCredentialStorageAsOperationQueueDelegate : WebCoreResourceHandleAsOperationQueueDelegate
index fdfec9c..a5ab367 100644 (file)
@@ -114,12 +114,6 @@ static bool scheduledWithCustomRunLoopMode(const std::optional<SchedulePairHashS
     [super dealloc];
 }
 
-- (void)continueWillCacheResponse:(NSCachedURLResponse *)response
-{
-    m_cachedResponseResult = response;
-    dispatch_semaphore_signal(m_semaphore);
-}
-
 - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
 {
     ASSERT(!isMainThread());
@@ -361,7 +355,10 @@ static bool scheduledWithCustomRunLoopMode(const std::optional<SchedulePairHashS
             return;
         }
 
-        m_handle->client()->willCacheResponseAsync(m_handle, cachedResponse.get());
+        m_handle->client()->willCacheResponseAsync(m_handle, cachedResponse.get(), [self, protectedSelf = WTFMove(protectedSelf)] (NSCachedURLResponse * response) mutable {
+            m_cachedResponseResult = response;
+            dispatch_semaphore_signal(m_semaphore);
+        });
     };
 
     [self callFunctionOnMainThread:WTFMove(work)];
index 6b224d5..d6d2e73 100644 (file)
@@ -1,3 +1,14 @@
+2018-03-26  Alex Christensen  <achristensen@webkit.org>
+
+        Merge ResourceHandleClient::willCacheResponseAsync with ResourceHandleClient::willCacheResponse
+        https://bugs.webkit.org/show_bug.cgi?id=183965
+
+        Reviewed by Chris Dumez.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::willCacheResponse const):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+
 2018-03-25  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK][WPE] Add API to convert between DOM and JSCValue
index 3fbb17d..c42166e 100644 (file)
@@ -1738,13 +1738,13 @@ RemoteAXObjectRef WebFrameLoaderClient::accessibilityRemoteObject()
     return webPage->accessibilityRemoteObject();
 }
     
-NSCachedURLResponse *WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const
+void WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response, CompletionHandler<void(NSCachedURLResponse *)>&& completionHandler) const
 {
     WebPage* webPage = m_frame->page();
     if (!webPage)
-        return response;
+        return completionHandler(response);
 
-    return webPage->injectedBundleResourceLoadClient().shouldCacheResponse(*webPage, *m_frame, identifier) ? response : nil;
+    return completionHandler(webPage->injectedBundleResourceLoadClient().shouldCacheResponse(*webPage, *m_frame, identifier) ? response : nil);
 }
 
 NSDictionary *WebFrameLoaderClient::dataDetectionContext()
index 9bd1c5f..d38b814 100644 (file)
@@ -237,7 +237,7 @@ private:
 #if PLATFORM(COCOA)
     RemoteAXObjectRef accessibilityRemoteObject() final;
     
-    NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const final;
+    void willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*, CompletionHandler<void(NSCachedURLResponse *)>&&) const final;
 
     NSDictionary *dataDetectionContext() final;
 #endif
index 2666138..0215d77 100644 (file)
@@ -1,3 +1,14 @@
+2018-03-26  Alex Christensen  <achristensen@webkit.org>
+
+        Merge ResourceHandleClient::willCacheResponseAsync with ResourceHandleClient::willCacheResponse
+        https://bugs.webkit.org/show_bug.cgi?id=183965
+
+        Reviewed by Chris Dumez.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::willCacheResponse const):
+
 2018-03-25  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r229954.
index 34c46ff..c3b499a 100644 (file)
@@ -101,7 +101,7 @@ private:
 #endif
     void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&) final;
 
-    NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const final;
+    void willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*, CompletionHandler<void(NSCachedURLResponse *)>&&) const final;
 
     void dispatchDidDispatchOnloadEvents() final;
     void dispatchDidReceiveServerRedirectForProvisionalLoad() final;
index 7f8564a..b0ca515 100644 (file)
@@ -487,7 +487,7 @@ void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, un
     }
 }
 
-NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader* loader, unsigned long identifier, NSCachedURLResponse* response) const
+void WebFrameLoaderClient::willCacheResponse(DocumentLoader* loader, unsigned long identifier, NSCachedURLResponse* response, CompletionHandler<void(NSCachedURLResponse *)>&& completionHandler) const
 {
     WebView *webView = getWebView(m_webFrame.get());
     WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView);
@@ -495,16 +495,16 @@ NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader* loa
 #if PLATFORM(IOS)
     if (implementations->webThreadWillCacheResponseFunc) {
         if (id resource = [webView _objectForIdentifier:identifier])
-            return CallResourceLoadDelegateInWebThread(implementations->webThreadWillCacheResponseFunc, webView, @selector(webThreadWebView:resource:willCacheResponse:fromDataSource:), resource, response, dataSource(loader));
+            return completionHandler(CallResourceLoadDelegateInWebThread(implementations->webThreadWillCacheResponseFunc, webView, @selector(webThreadWebView:resource:willCacheResponse:fromDataSource:), resource, response, dataSource(loader)));
         
     } else
 #endif
     if (implementations->willCacheResponseFunc) {
         if (id resource = [webView _objectForIdentifier:identifier])
-            return CallResourceLoadDelegate(implementations->willCacheResponseFunc, webView, @selector(webView:resource:willCacheResponse:fromDataSource:), resource, response, dataSource(loader));
+            return completionHandler(CallResourceLoadDelegate(implementations->willCacheResponseFunc, webView, @selector(webView:resource:willCacheResponse:fromDataSource:), resource, response, dataSource(loader)));
     }
 
-    return response;
+    completionHandler(response);
 }
 
 void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long identifier, int dataLength)