Title: [223730] trunk/Source/WebKit
Revision
223730
Author
achristen...@apple.com
Date
2017-10-19 17:09:38 -0700 (Thu, 19 Oct 2017)

Log Message

Modernize API::DownloadClient
https://bugs.webkit.org/show_bug.cgi?id=178547

Reviewed by Andy Estes.

Use more C++ references instead of pointers because they're never null.

Remove canAuthenticateAgainstProtectionSpace because there are no implementations
except the default implementation which always returns true and we don't intend to
add this to the SPI because that's just a legacy call anyways from when NSURLConnection
hadn't fully evolved, and we're moving away from NSURLConnection, especially in our API design.

Separate the NetworkSession-only and pre-NetworkSession-only callbacks.  All the synchronous
IPC messages are only used in the pre-NetworkSession code, so once we remove it we can remove them!

Make API::DownloadClient calls that NetworkSession uses use a completion handler so we will be able to
design an asynchronous API.

* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::continueCanAuthenticateAgainstProtectionSpace): Deleted.
* NetworkProcess/Downloads/DownloadManager.h:
* NetworkProcess/Downloads/PendingDownload.cpp:
(WebKit::PendingDownload::canAuthenticateAgainstProtectionSpaceAsync):
(WebKit::PendingDownload::continueCanAuthenticateAgainstProtectionSpace): Deleted.
* NetworkProcess/Downloads/PendingDownload.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::continueCanAuthenticateAgainstProtectionSpaceDownload): Deleted.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* UIProcess/API/APIDownloadClient.h:
(API::DownloadClient::didStart):
(API::DownloadClient::didReceiveAuthenticationChallenge):
(API::DownloadClient::didReceiveResponse):
(API::DownloadClient::didReceiveData):
(API::DownloadClient::shouldDecodeSourceDataOfMIMEType):
(API::DownloadClient::decideDestinationWithSuggestedFilename):
(API::DownloadClient::didCreateDestination):
(API::DownloadClient::didFinish):
(API::DownloadClient::didFail):
(API::DownloadClient::didCancel):
(API::DownloadClient::processDidCrash):
(API::DownloadClient::willSendRequest):
(API::DownloadClient::canAuthenticateAgainstProtectionSpace): Deleted.
* UIProcess/API/C/WKContext.cpp:
(WKContextSetDownloadClient):
* UIProcess/API/glib/WebKitDownloadClient.cpp:
* UIProcess/Cocoa/DownloadClient.h:
* UIProcess/Cocoa/DownloadClient.mm:
(WebKit::DownloadClient::didStart):
(WebKit::DownloadClient::didReceiveResponse):
(WebKit::DownloadClient::didReceiveData):
(WebKit::DownloadClient::decideDestinationWithSuggestedFilename):
(WebKit::DownloadClient::didFinish):
(WebKit::DownloadClient::didFail):
(WebKit::DownloadClient::didCancel):
(WebKit::DownloadClient::willSendRequest):
* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::processDidClose):
(WebKit::DownloadProxy::didStart):
(WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
(WebKit::DownloadProxy::willSendRequest):
(WebKit::DownloadProxy::didReceiveResponse):
(WebKit::DownloadProxy::didReceiveData):
(WebKit::DownloadProxy::shouldDecodeSourceDataOfMIMEType):
(WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
(WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
(WebKit::DownloadProxy::didCreateDestination):
(WebKit::DownloadProxy::didFinish):
(WebKit::DownloadProxy::didFail):
(WebKit::DownloadProxy::didCancel):
(WebKit::DownloadProxy::canAuthenticateAgainstProtectionSpace): Deleted.
* UIProcess/Downloads/DownloadProxy.h:
* UIProcess/Downloads/DownloadProxy.messages.in:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (223729 => 223730)


--- trunk/Source/WebKit/ChangeLog	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/ChangeLog	2017-10-20 00:09:38 UTC (rev 223730)
@@ -1,3 +1,79 @@
+2017-10-19  Alex Christensen  <achristen...@webkit.org>
+
+        Modernize API::DownloadClient
+        https://bugs.webkit.org/show_bug.cgi?id=178547
+
+        Reviewed by Andy Estes.
+
+        Use more C++ references instead of pointers because they're never null.
+
+        Remove canAuthenticateAgainstProtectionSpace because there are no implementations
+        except the default implementation which always returns true and we don't intend to
+        add this to the SPI because that's just a legacy call anyways from when NSURLConnection
+        hadn't fully evolved, and we're moving away from NSURLConnection, especially in our API design.
+
+        Separate the NetworkSession-only and pre-NetworkSession-only callbacks.  All the synchronous
+        IPC messages are only used in the pre-NetworkSession code, so once we remove it we can remove them!
+
+        Make API::DownloadClient calls that NetworkSession uses use a completion handler so we will be able to
+        design an asynchronous API.
+
+        * NetworkProcess/Downloads/DownloadManager.cpp:
+        (WebKit::DownloadManager::continueCanAuthenticateAgainstProtectionSpace): Deleted.
+        * NetworkProcess/Downloads/DownloadManager.h:
+        * NetworkProcess/Downloads/PendingDownload.cpp:
+        (WebKit::PendingDownload::canAuthenticateAgainstProtectionSpaceAsync):
+        (WebKit::PendingDownload::continueCanAuthenticateAgainstProtectionSpace): Deleted.
+        * NetworkProcess/Downloads/PendingDownload.h:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::continueCanAuthenticateAgainstProtectionSpaceDownload): Deleted.
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * UIProcess/API/APIDownloadClient.h:
+        (API::DownloadClient::didStart):
+        (API::DownloadClient::didReceiveAuthenticationChallenge):
+        (API::DownloadClient::didReceiveResponse):
+        (API::DownloadClient::didReceiveData):
+        (API::DownloadClient::shouldDecodeSourceDataOfMIMEType):
+        (API::DownloadClient::decideDestinationWithSuggestedFilename):
+        (API::DownloadClient::didCreateDestination):
+        (API::DownloadClient::didFinish):
+        (API::DownloadClient::didFail):
+        (API::DownloadClient::didCancel):
+        (API::DownloadClient::processDidCrash):
+        (API::DownloadClient::willSendRequest):
+        (API::DownloadClient::canAuthenticateAgainstProtectionSpace): Deleted.
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetDownloadClient):
+        * UIProcess/API/glib/WebKitDownloadClient.cpp:
+        * UIProcess/Cocoa/DownloadClient.h:
+        * UIProcess/Cocoa/DownloadClient.mm:
+        (WebKit::DownloadClient::didStart):
+        (WebKit::DownloadClient::didReceiveResponse):
+        (WebKit::DownloadClient::didReceiveData):
+        (WebKit::DownloadClient::decideDestinationWithSuggestedFilename):
+        (WebKit::DownloadClient::didFinish):
+        (WebKit::DownloadClient::didFail):
+        (WebKit::DownloadClient::didCancel):
+        (WebKit::DownloadClient::willSendRequest):
+        * UIProcess/Downloads/DownloadProxy.cpp:
+        (WebKit::DownloadProxy::processDidClose):
+        (WebKit::DownloadProxy::didStart):
+        (WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
+        (WebKit::DownloadProxy::willSendRequest):
+        (WebKit::DownloadProxy::didReceiveResponse):
+        (WebKit::DownloadProxy::didReceiveData):
+        (WebKit::DownloadProxy::shouldDecodeSourceDataOfMIMEType):
+        (WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
+        (WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
+        (WebKit::DownloadProxy::didCreateDestination):
+        (WebKit::DownloadProxy::didFinish):
+        (WebKit::DownloadProxy::didFail):
+        (WebKit::DownloadProxy::didCancel):
+        (WebKit::DownloadProxy::canAuthenticateAgainstProtectionSpace): Deleted.
+        * UIProcess/Downloads/DownloadProxy.h:
+        * UIProcess/Downloads/DownloadProxy.messages.in:
+
 2017-10-19  Nan Wang  <n_w...@apple.com>
 
         AX: Provide a way for Accessibility to cache the selection while retrieving rects for speak selection

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/Download.cpp (223729 => 223730)


--- trunk/Source/WebKit/NetworkProcess/Downloads/Download.cpp	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/Download.cpp	2017-10-20 00:09:38 UTC (rev 223730)
@@ -160,31 +160,8 @@
         return;
     }
 
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-    m_challenge = challenge;
-    m_challengeCompletionHandler = WTFMove(completionHandler);
-    send(Messages::DownloadProxy::CanAuthenticateAgainstProtectionSpace(challenge.protectionSpace()));
-#else
     NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(*this, challenge, WTFMove(completionHandler));
-#endif
 }
-
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-void Download::continueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate)
-{
-    ASSERT(m_challengeCompletionHandler);
-    auto completionHandler = std::exchange(m_challengeCompletionHandler, nullptr);
-    if (!canAuthenticate) {
-        if (NetworkSession::allowsSpecificHTTPSCertificateForHost(*m_challenge))
-            completionHandler(AuthenticationChallengeDisposition::UseCredential, serverTrustCredential(*m_challenge));
-        else
-            completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, { });
-        return;
-    }
-
-    NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(*this, *m_challenge, WTFMove(completionHandler));
-}
-#endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
 #endif // USE(NETWORK_SESSION)
 
 #if !USE(NETWORK_SESSION)

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/Download.h (223729 => 223730)


--- trunk/Source/WebKit/NetworkProcess/Downloads/Download.h	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/Download.h	2017-10-20 00:09:38 UTC (rev 223730)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef Download_h
-#define Download_h
+#pragma once
 
 #include "DownloadID.h"
 #include "MessageSender.h"
@@ -104,9 +103,6 @@
 #if USE(NETWORK_SESSION)
     void setSandboxExtension(RefPtr<SandboxExtension>&& sandboxExtension) { m_sandboxExtension = WTFMove(sandboxExtension); }
     void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-    void continueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate);
-#endif
 #else
     const WebCore::ResourceRequest& request() const { return m_request; }
     void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&);
@@ -152,10 +148,6 @@
     RetainPtr<NSURLSessionDownloadTask> m_downloadTask;
 #endif
     PAL::SessionID m_sessionID;
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-    std::optional<WebCore::AuthenticationChallenge> m_challenge;
-    ChallengeCompletionHandler m_challengeCompletionHandler;
-#endif
 #else // USE(NETWORK_SESSION)
     WebCore::ResourceRequest m_request;
     String m_responseMIMEType;
@@ -174,5 +166,3 @@
 };
 
 } // namespace WebKit
-
-#endif // Download_h

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp (223729 => 223730)


--- trunk/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp	2017-10-20 00:09:38 UTC (rev 223730)
@@ -86,21 +86,6 @@
     m_downloads.add(downloadID, WTFMove(download));
 }
 
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-void DownloadManager::continueCanAuthenticateAgainstProtectionSpace(DownloadID downloadID, bool canAuthenticate)
-{
-    if (auto* pendingDownload = m_pendingDownloads.get(downloadID)) {
-        pendingDownload->continueCanAuthenticateAgainstProtectionSpace(canAuthenticate);
-        return;
-    }
-    if (auto* download = m_downloads.get(downloadID)) {
-        download->continueCanAuthenticateAgainstProtectionSpace(canAuthenticate);
-        return;
-    }
-    ASSERT_NOT_REACHED();
-}
-#endif
-
 void DownloadManager::continueWillSendRequest(DownloadID downloadID, WebCore::ResourceRequest&& request)
 {
     auto* pendingDownload = m_pendingDownloads.get(downloadID);

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h (223729 => 223730)


--- trunk/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h	2017-10-20 00:09:38 UTC (rev 223730)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DownloadManager_h
-#define DownloadManager_h
+#pragma once
 
 #include "DownloadID.h"
 #include "NetworkDataTask.h"
@@ -81,9 +80,6 @@
     void startDownload(NetworkConnectionToWebProcess*, PAL::SessionID, DownloadID, const WebCore::ResourceRequest&, const String& suggestedName = { });
 #if USE(NETWORK_SESSION)
     void dataTaskBecameDownloadTask(DownloadID, std::unique_ptr<Download>&&);
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-    void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate);
-#endif
     void continueWillSendRequest(DownloadID, WebCore::ResourceRequest&&);
     void willDecidePendingDownloadDestination(NetworkDataTask&, ResponseCompletionHandler&&);
 #endif
@@ -117,5 +113,3 @@
 };
 
 } // namespace WebKit
-
-#endif // DownloadManager_h

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp (223729 => 223730)


--- trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp	2017-10-20 00:09:38 UTC (rev 223730)
@@ -77,13 +77,8 @@
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
 void PendingDownload::canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace& protectionSpace)
 {
-    send(Messages::DownloadProxy::CanAuthenticateAgainstProtectionSpace(protectionSpace));
+    m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(true);
 }
-
-void PendingDownload::continueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate)
-{
-    m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(canAuthenticate);
-}
 #endif
 
 void PendingDownload::didFailLoading(const WebCore::ResourceError& error)

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h (223729 => 223730)


--- trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h	2017-10-20 00:09:38 UTC (rev 223730)
@@ -49,9 +49,6 @@
     PendingDownload(std::unique_ptr<NetworkLoad>&&, DownloadID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
 
     void continueWillSendRequest(WebCore::ResourceRequest&&);
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-    void continueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate);
-#endif
     void cancel();
 
 private:    

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (223729 => 223730)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2017-10-20 00:09:38 UTC (rev 223730)
@@ -549,13 +549,6 @@
 #endif
 
 #if USE(NETWORK_SESSION)
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-void NetworkProcess::continueCanAuthenticateAgainstProtectionSpaceDownload(DownloadID downloadID, bool canAuthenticate)
-{
-    downloadManager().continueCanAuthenticateAgainstProtectionSpace(downloadID, canAuthenticate);
-}
-#endif
-
 void NetworkProcess::continueWillSendRequest(DownloadID downloadID, WebCore::ResourceRequest&& request)
 {
     downloadManager().continueWillSendRequest(downloadID, WTFMove(request));

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (223729 => 223730)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2017-10-20 00:09:38 UTC (rev 223730)
@@ -206,9 +206,6 @@
     void continueCanAuthenticateAgainstProtectionSpace(uint64_t resourceLoadIdentifier, bool canAuthenticate);
 #endif
 #if USE(NETWORK_SESSION)
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-    void continueCanAuthenticateAgainstProtectionSpaceDownload(DownloadID, bool canAuthenticate);
-#endif
     void continueWillSendRequest(DownloadID, WebCore::ResourceRequest&&);
 #endif
     void continueDecidePendingDownloadDestination(DownloadID, String destination, const SandboxExtension::Handle& sandboxExtensionHandle, bool allowOverwrite);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (223729 => 223730)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2017-10-20 00:09:38 UTC (rev 223730)
@@ -51,9 +51,6 @@
     ContinueCanAuthenticateAgainstProtectionSpace(uint64_t loaderID, bool canAuthenticate)
 #endif
 #if USE(NETWORK_SESSION)
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-    ContinueCanAuthenticateAgainstProtectionSpaceDownload(WebKit::DownloadID downloadID, bool canAuthenticate)
-#endif
     ContinueWillSendRequest(WebKit::DownloadID downloadID, WebCore::ResourceRequest request)
 #endif
     ContinueDecidePendingDownloadDestination(WebKit::DownloadID downloadID, String destination, WebKit::SandboxExtension::Handle sandboxExtensionHandle, bool allowOverwrite)

Modified: trunk/Source/WebKit/UIProcess/API/APIDownloadClient.h (223729 => 223730)


--- trunk/Source/WebKit/UIProcess/API/APIDownloadClient.h	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/UIProcess/API/APIDownloadClient.h	2017-10-20 00:09:38 UTC (rev 223730)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef APIDownloadClient_h
-#define APIDownloadClient_h
+#pragma once
 
 #include <wtf/Function.h>
 #include <wtf/text/WTFString.h>
@@ -40,6 +39,8 @@
 class DownloadProxy;
 class WebProcessPool;
 class WebProtectionSpace;
+
+enum class AllowOverwrite { No, Yes };
 }
 
 namespace API {
@@ -48,21 +49,20 @@
 public:
     virtual ~DownloadClient() { }
 
-    virtual void didStart(WebKit::WebProcessPool*, WebKit::DownloadProxy*) { }
-    virtual void didReceiveAuthenticationChallenge(WebKit::WebProcessPool*, WebKit::DownloadProxy*, WebKit::AuthenticationChallengeProxy*) { }
-    virtual void didReceiveResponse(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WebCore::ResourceResponse&) { }
-    virtual void didReceiveData(WebKit::WebProcessPool*, WebKit::DownloadProxy*, uint64_t) { }
-    virtual bool shouldDecodeSourceDataOfMIMEType(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WTF::String&) { return true; }
-    virtual WTF::String decideDestinationWithSuggestedFilename(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WTF::String&, bool&) { return { }; }
-    virtual void didCreateDestination(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WTF::String&) { }
-    virtual void didFinish(WebKit::WebProcessPool*, WebKit::DownloadProxy*) { }
-    virtual void didFail(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WebCore::ResourceError&) { }
-    virtual void didCancel(WebKit::WebProcessPool*, WebKit::DownloadProxy*) { }
-    virtual void processDidCrash(WebKit::WebProcessPool*, WebKit::DownloadProxy*) { }
-    virtual bool canAuthenticateAgainstProtectionSpace(WebKit::WebProtectionSpace*) { return true; }
-    virtual void willSendRequest(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WebCore::ResourceRequest& request, const WebCore::ResourceResponse&, WTF::Function<void(const WebCore::ResourceRequest&)>&& callback) { callback(request); }
+    virtual void didStart(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
+    virtual void didReceiveAuthenticationChallenge(WebKit::WebProcessPool&, WebKit::DownloadProxy&, WebKit::AuthenticationChallengeProxy&) { }
+    virtual void didReceiveResponse(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WebCore::ResourceResponse&) { }
+    virtual void didReceiveData(WebKit::WebProcessPool&, WebKit::DownloadProxy&, uint64_t) { }
+#if !USE(NETWORK_SESSION)
+    virtual bool shouldDecodeSourceDataOfMIMEType(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&) { return true; }
+#endif
+    virtual void decideDestinationWithSuggestedFilename(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&, Function<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) { completionHandler(WebKit::AllowOverwrite::No, { }); }
+    virtual void didCreateDestination(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&) { }
+    virtual void didFinish(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
+    virtual void didFail(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WebCore::ResourceError&) { }
+    virtual void didCancel(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
+    virtual void processDidCrash(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
+    virtual void willSendRequest(WebKit::WebProcessPool&, WebKit::DownloadProxy&, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, Function<void(WebCore::ResourceRequest&&)>&& completionHandler) { completionHandler(WTFMove(request)); }
 };
 
 } // namespace API
-
-#endif // APIDownloadClient_h

Modified: trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp (223729 => 223730)


--- trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp	2017-10-20 00:09:38 UTC (rev 223730)
@@ -172,101 +172,104 @@
             initialize(client);
         }
     private:
-        void didStart(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
+        void didStart(WebProcessPool& processPool, DownloadProxy& downloadProxy) final
         {
             if (!m_client.didStart)
                 return;
 
-            m_client.didStart(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
+            m_client.didStart(toAPI(&processPool), toAPI(&downloadProxy), m_client.base.clientInfo);
         }
 
-        void didReceiveAuthenticationChallenge(WebProcessPool* processPool, DownloadProxy* downloadProxy, AuthenticationChallengeProxy* authenticationChallengeProxy) override
+        void didReceiveAuthenticationChallenge(WebProcessPool& processPool, DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallengeProxy) final
         {
             if (!m_client.didReceiveAuthenticationChallenge)
                 return;
 
-            m_client.didReceiveAuthenticationChallenge(toAPI(processPool), toAPI(downloadProxy), toAPI(authenticationChallengeProxy), m_client.base.clientInfo);
+            m_client.didReceiveAuthenticationChallenge(toAPI(&processPool), toAPI(&downloadProxy), toAPI(&authenticationChallengeProxy), m_client.base.clientInfo);
         }
 
-        void didReceiveResponse(WebProcessPool* processPool, DownloadProxy* downloadProxy, const ResourceResponse& response) override
+        void didReceiveResponse(WebProcessPool& processPool, DownloadProxy& downloadProxy, const ResourceResponse& response) final
         {
             if (!m_client.didReceiveResponse)
                 return;
 
-            m_client.didReceiveResponse(toAPI(processPool), toAPI(downloadProxy), toAPI(API::URLResponse::create(response).ptr()), m_client.base.clientInfo);
+            m_client.didReceiveResponse(toAPI(&processPool), toAPI(&downloadProxy), toAPI(API::URLResponse::create(response).ptr()), m_client.base.clientInfo);
         }
 
-        void didReceiveData(WebProcessPool* processPool, DownloadProxy* downloadProxy, uint64_t length) override
+        void didReceiveData(WebProcessPool& processPool, DownloadProxy& downloadProxy, uint64_t length) final
         {
             if (!m_client.didReceiveData)
                 return;
 
-            m_client.didReceiveData(toAPI(processPool), toAPI(downloadProxy), length, m_client.base.clientInfo);
+            m_client.didReceiveData(toAPI(&processPool), toAPI(&downloadProxy), length, m_client.base.clientInfo);
         }
 
-        bool shouldDecodeSourceDataOfMIMEType(WebProcessPool* processPool, DownloadProxy* downloadProxy, const String& mimeType) override
+#if !USE(NETWORK_SESSION)
+        bool shouldDecodeSourceDataOfMIMEType(WebProcessPool& processPool, DownloadProxy& downloadProxy, const String& mimeType) final
         {
             if (!m_client.shouldDecodeSourceDataOfMIMEType)
                 return true;
 
-            return m_client.shouldDecodeSourceDataOfMIMEType(toAPI(processPool), toAPI(downloadProxy), toAPI(mimeType.impl()), m_client.base.clientInfo);
+            return m_client.shouldDecodeSourceDataOfMIMEType(toAPI(&processPool), toAPI(&downloadProxy), toAPI(mimeType.impl()), m_client.base.clientInfo);
         }
+#endif
 
-        String decideDestinationWithSuggestedFilename(WebProcessPool* processPool, DownloadProxy* downloadProxy, const String& filename, bool& allowOverwrite) override
+        void decideDestinationWithSuggestedFilename(WebProcessPool& processPool, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, WTF::String)>&& completionHandler) final
         {
             if (!m_client.decideDestinationWithSuggestedFilename)
-                return String();
+                return completionHandler(AllowOverwrite::No, { });
 
-            WKRetainPtr<WKStringRef> destination(AdoptWK, m_client.decideDestinationWithSuggestedFilename(toAPI(processPool), toAPI(downloadProxy), toAPI(filename.impl()), &allowOverwrite, m_client.base.clientInfo));
-            return toWTFString(destination.get());
+            bool allowOverwrite = false;
+            WKRetainPtr<WKStringRef> destination(AdoptWK, m_client.decideDestinationWithSuggestedFilename(toAPI(&processPool), toAPI(&downloadProxy), toAPI(filename.impl()), &allowOverwrite, m_client.base.clientInfo));
+            completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, toWTFString(destination.get()));
         }
 
-        void didCreateDestination(WebProcessPool* processPool, DownloadProxy* downloadProxy, const String& path) override
+        void didCreateDestination(WebProcessPool& processPool, DownloadProxy& downloadProxy, const String& path) final
         {
             if (!m_client.didCreateDestination)
                 return;
 
-            m_client.didCreateDestination(toAPI(processPool), toAPI(downloadProxy), toAPI(path.impl()), m_client.base.clientInfo);
+            m_client.didCreateDestination(toAPI(&processPool), toAPI(&downloadProxy), toAPI(path.impl()), m_client.base.clientInfo);
         }
 
-        void didFinish(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
+        void didFinish(WebProcessPool& processPool, DownloadProxy& downloadProxy) final
         {
             if (!m_client.didFinish)
                 return;
 
-            m_client.didFinish(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
+            m_client.didFinish(toAPI(&processPool), toAPI(&downloadProxy), m_client.base.clientInfo);
         }
 
-        void didFail(WebProcessPool* processPool, DownloadProxy* downloadProxy, const ResourceError& error) override
+        void didFail(WebProcessPool& processPool, DownloadProxy& downloadProxy, const ResourceError& error) final
         {
             if (!m_client.didFail)
                 return;
 
-            m_client.didFail(toAPI(processPool), toAPI(downloadProxy), toAPI(error), m_client.base.clientInfo);
+            m_client.didFail(toAPI(&processPool), toAPI(&downloadProxy), toAPI(error), m_client.base.clientInfo);
         }
         
-        void didCancel(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
+        void didCancel(WebProcessPool& processPool, DownloadProxy& downloadProxy) final
         {
             if (!m_client.didCancel)
                 return;
             
-            m_client.didCancel(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
+            m_client.didCancel(toAPI(&processPool), toAPI(&downloadProxy), m_client.base.clientInfo);
         }
         
-        void processDidCrash(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
+        void processDidCrash(WebProcessPool& processPool, DownloadProxy& downloadProxy) final
         {
             if (!m_client.processDidCrash)
                 return;
             
-            m_client.processDidCrash(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
+            m_client.processDidCrash(toAPI(&processPool), toAPI(&downloadProxy), m_client.base.clientInfo);
         }
 
-        void willSendRequest(WebProcessPool* processPool, DownloadProxy* downloadProxy, const ResourceRequest& request, const ResourceResponse&, WTF::Function<void(const ResourceRequest&)>&& callback) override
+        void willSendRequest(WebProcessPool& processPool, DownloadProxy& downloadProxy, ResourceRequest&& request, const ResourceResponse&, Function<void(ResourceRequest&&)>&& callback) final
         {
             if (m_client.didReceiveServerRedirect)
-                m_client.didReceiveServerRedirect(toAPI(processPool), toAPI(downloadProxy), toURLRef(request.url().string().impl()), m_client.base.clientInfo);
+                m_client.didReceiveServerRedirect(toAPI(&processPool), toAPI(&downloadProxy), toURLRef(request.url().string().impl()), m_client.base.clientInfo);
 
-            callback(request);
+            callback(WTFMove(request));
         }
 
 

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp (223729 => 223730)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp	2017-10-20 00:09:38 UTC (rev 223730)
@@ -40,26 +40,26 @@
     }
 
 private:
-    void didStart(WebProcessPool*, DownloadProxy* downloadProxy) override
+    void didStart(WebProcessPool&, DownloadProxy& downloadProxy) override
     {
-        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
+        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
         webkitWebContextDownloadStarted(m_webContext, download.get());
     }
 
-    void didReceiveAuthenticationChallenge(WebProcessPool*, DownloadProxy* downloadProxy, AuthenticationChallengeProxy* authenticationChallenge) override
+    void didReceiveAuthenticationChallenge(WebProcessPool&, DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallenge) override
     {
-        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
+        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
         if (webkitDownloadIsCancelled(download.get()))
             return;
 
         // FIXME: Add API to handle authentication of downloads without a web view associted.
         if (auto* webView = webkit_download_get_web_view(download.get()))
-            webkitWebViewHandleAuthenticationChallenge(webView, authenticationChallenge);
+            webkitWebViewHandleAuthenticationChallenge(webView, &authenticationChallenge);
     }
 
-    void didReceiveResponse(WebProcessPool*, DownloadProxy* downloadProxy, const ResourceResponse& resourceResponse) override
+    void didReceiveResponse(WebProcessPool&, DownloadProxy& downloadProxy, const ResourceResponse& resourceResponse) override
     {
-        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
+        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
         if (webkitDownloadIsCancelled(download.get()))
             return;
 
@@ -67,47 +67,49 @@
         webkitDownloadSetResponse(download.get(), response.get());
     }
 
-    void didReceiveData(WebProcessPool*, DownloadProxy* downloadProxy, uint64_t length) override
+    void didReceiveData(WebProcessPool&, DownloadProxy& downloadProxy, uint64_t length) override
     {
-        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
+        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
         webkitDownloadNotifyProgress(download.get(), length);
     }
 
-    String decideDestinationWithSuggestedFilename(WebProcessPool*, DownloadProxy* downloadProxy, const String& filename, bool& allowOverwrite) override
+    void decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler) override
     {
-        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
-        return webkitDownloadDecideDestinationWithSuggestedFilename(download.get(), filename.utf8(), allowOverwrite);
+        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
+        bool allowOverwrite = false;
+        String destination = webkitDownloadDecideDestinationWithSuggestedFilename(download.get(), filename.utf8(), allowOverwrite);
+        completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, destination);
     }
 
-    void didCreateDestination(WebProcessPool*, DownloadProxy* downloadProxy, const String& path) override
+    void didCreateDestination(WebProcessPool&, DownloadProxy& downloadProxy, const String& path) override
     {
-        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
+        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
         webkitDownloadDestinationCreated(download.get(), path);
     }
 
-    void didFail(WebProcessPool*, DownloadProxy* downloadProxy, const ResourceError& error) override
+    void didFail(WebProcessPool&, DownloadProxy& downloadProxy, const ResourceError& error) override
     {
-        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
+        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
         if (webkitDownloadIsCancelled(download.get())) {
             // Cancellation takes precedence over other errors.
             webkitDownloadCancelled(download.get());
         } else
             webkitDownloadFailed(download.get(), error);
-        webkitWebContextRemoveDownload(downloadProxy);
+        webkitWebContextRemoveDownload(&downloadProxy);
     }
 
-    void didCancel(WebProcessPool*, DownloadProxy* downloadProxy) override
+    void didCancel(WebProcessPool&, DownloadProxy& downloadProxy) override
     {
-        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
+        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
         webkitDownloadCancelled(download.get());
-        webkitWebContextRemoveDownload(downloadProxy);
+        webkitWebContextRemoveDownload(&downloadProxy);
     }
 
-    void didFinish(WebProcessPool*, DownloadProxy* downloadProxy) override
+    void didFinish(WebProcessPool&, DownloadProxy& downloadProxy) override
     {
-        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
+        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
         webkitDownloadFinished(download.get());
-        webkitWebContextRemoveDownload(downloadProxy);
+        webkitWebContextRemoveDownload(&downloadProxy);
     }
 
     WebKitWebContext* m_webContext;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h (223729 => 223730)


--- trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h	2017-10-20 00:09:38 UTC (rev 223730)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DownloadClient_h
-#define DownloadClient_h
+#pragma once
 
 #import "WKFoundation.h"
 
@@ -41,7 +40,7 @@
 }
 
 namespace WebKit {
-    
+
 class DownloadClient final : public API::DownloadClient {
 public:
     explicit DownloadClient(id <_WKDownloadDelegate>);
@@ -48,14 +47,14 @@
     
 private:
     // From API::DownloadClient
-    void didStart(WebProcessPool*, DownloadProxy*) final;
-    void didReceiveResponse(WebProcessPool*, DownloadProxy*, const WebCore::ResourceResponse&) final;
-    void didReceiveData(WebProcessPool*, DownloadProxy*, uint64_t length) final;
-    String decideDestinationWithSuggestedFilename(WebProcessPool*, DownloadProxy*, const String& filename, bool& allowOverwriteParam) final;
-    void didFinish(WebProcessPool*, DownloadProxy*) final;
-    void didFail(WebProcessPool*, DownloadProxy*, const WebCore::ResourceError&) final;
-    void didCancel(WebProcessPool*, DownloadProxy*) final;
-    void willSendRequest(WebProcessPool*, DownloadProxy*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, WTF::Function<void(const WebCore::ResourceRequest&)>&&) final;
+    void didStart(WebProcessPool&, DownloadProxy&) final;
+    void didReceiveResponse(WebProcessPool&, DownloadProxy&, const WebCore::ResourceResponse&) final;
+    void didReceiveData(WebProcessPool&, DownloadProxy&, uint64_t length) final;
+    void decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy&, const String& suggestedFilename, Function<void(AllowOverwrite, String)>&&) final;
+    void didFinish(WebProcessPool&, DownloadProxy&) final;
+    void didFail(WebProcessPool&, DownloadProxy&, const WebCore::ResourceError&) final;
+    void didCancel(WebProcessPool&, DownloadProxy&) final;
+    void willSendRequest(WebProcessPool&, DownloadProxy&, WebCore::ResourceRequest&&, const WebCore::ResourceResponse&, Function<void(WebCore::ResourceRequest&&)>&&) final;
 
     WeakObjCPtr<id <_WKDownloadDelegate>> m_delegate;
 
@@ -74,5 +73,3 @@
 } // namespace WebKit
 
 #endif
-
-#endif // DownloadClient_h

Modified: trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm (223729 => 223730)


--- trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm	2017-10-20 00:09:38 UTC (rev 223730)
@@ -56,59 +56,58 @@
     m_delegateMethods.downloadDidReceiveServerRedirectToURL = [delegate respondsToSelector:@selector(_download:didReceiveServerRedirectToURL:)];
 }
 
-void DownloadClient::didStart(WebProcessPool*, DownloadProxy* downloadProxy)
+void DownloadClient::didStart(WebProcessPool&, DownloadProxy& downloadProxy)
 {
     if (m_delegateMethods.downloadDidStart)
-        [m_delegate.get() _downloadDidStart:wrapper(*downloadProxy)];
+        [m_delegate.get() _downloadDidStart:wrapper(downloadProxy)];
 }
 
-void DownloadClient::didReceiveResponse(WebProcessPool*, DownloadProxy* downloadProxy, const WebCore::ResourceResponse& response)
+void DownloadClient::didReceiveResponse(WebProcessPool&, DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response)
 {
     if (m_delegateMethods.downloadDidReceiveResponse)
-        [m_delegate.get() _download:wrapper(*downloadProxy) didReceiveResponse:response.nsURLResponse()];
+        [m_delegate.get() _download:wrapper(downloadProxy) didReceiveResponse:response.nsURLResponse()];
 }
 
-void DownloadClient::didReceiveData(WebProcessPool*, DownloadProxy* downloadProxy, uint64_t length)
+void DownloadClient::didReceiveData(WebProcessPool&, DownloadProxy& downloadProxy, uint64_t length)
 {
     if (m_delegateMethods.downloadDidReceiveData)
-        [m_delegate.get() _download:wrapper(*downloadProxy) didReceiveData:length];
+        [m_delegate.get() _download:wrapper(downloadProxy) didReceiveData:length];
 }
 
-String DownloadClient::decideDestinationWithSuggestedFilename(WebProcessPool*, DownloadProxy* downloadProxy, const String& filename, bool& allowOverwriteParam)
+void DownloadClient::decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler)
 {
     if (!m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameAllowOverwrite)
-        return String();
-    
+        return completionHandler(AllowOverwrite::No, { });
+
     BOOL allowOverwrite = NO;
-    NSString *destination = [m_delegate.get() _download:wrapper(*downloadProxy) decideDestinationWithSuggestedFilename:filename allowOverwrite:&allowOverwrite];
-    allowOverwriteParam = allowOverwrite;
-    return destination;
+    NSString *destination = [m_delegate.get() _download:wrapper(downloadProxy) decideDestinationWithSuggestedFilename:filename allowOverwrite:&allowOverwrite];
+    completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, destination);
 }
 
-void DownloadClient::didFinish(WebProcessPool*, DownloadProxy* downloadProxy)
+void DownloadClient::didFinish(WebProcessPool&, DownloadProxy& downloadProxy)
 {
     if (m_delegateMethods.downloadDidFinish)
-        [m_delegate.get() _downloadDidFinish:wrapper(*downloadProxy)];
+        [m_delegate.get() _downloadDidFinish:wrapper(downloadProxy)];
 }
 
-void DownloadClient::didFail(WebProcessPool*, DownloadProxy* downloadProxy, const WebCore::ResourceError& error)
+void DownloadClient::didFail(WebProcessPool&, DownloadProxy& downloadProxy, const WebCore::ResourceError& error)
 {
     if (m_delegateMethods.downloadDidFail)
-        [m_delegate.get() _download:wrapper(*downloadProxy) didFailWithError:error.nsError()];
+        [m_delegate.get() _download:wrapper(downloadProxy) didFailWithError:error.nsError()];
 }
 
-void DownloadClient::didCancel(WebProcessPool*, DownloadProxy* downloadProxy)
+void DownloadClient::didCancel(WebProcessPool&, DownloadProxy& downloadProxy)
 {
     if (m_delegateMethods.downloadDidCancel)
-        [m_delegate.get() _downloadDidCancel:wrapper(*downloadProxy)];
+        [m_delegate.get() _downloadDidCancel:wrapper(downloadProxy)];
 }
 
-void DownloadClient::willSendRequest(WebProcessPool*, DownloadProxy* downloadProxy, const WebCore::ResourceRequest& request, const WebCore::ResourceResponse&, WTF::Function<void(const WebCore::ResourceRequest&)>&& callback)
+void DownloadClient::willSendRequest(WebProcessPool&, DownloadProxy& downloadProxy, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, Function<void(WebCore::ResourceRequest&&)>&& callback)
 {
     if (m_delegateMethods.downloadDidReceiveServerRedirectToURL)
-        [m_delegate.get() _download:wrapper(*downloadProxy) didReceiveServerRedirectToURL:[NSURL _web_URLWithWTFString:request.url().string()]];
+        [m_delegate.get() _download:wrapper(downloadProxy) didReceiveServerRedirectToURL:[NSURL _web_URLWithWTFString:request.url().string()]];
 
-    callback(request);
+    callback(WTFMove(request));
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp (223729 => 223730)


--- trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp	2017-10-20 00:09:38 UTC (rev 223730)
@@ -89,7 +89,7 @@
     if (!m_processPool)
         return;
 
-    m_processPool->downloadClient().processDidCrash(m_processPool.get(), this);
+    m_processPool->downloadClient().processDidCrash(*m_processPool, *this);
 }
 
 WebPageProxy* DownloadProxy::originatingPage() const
@@ -113,7 +113,7 @@
     if (!m_processPool)
         return;
 
-    m_processPool->downloadClient().didStart(m_processPool.get(), this);
+    m_processPool->downloadClient().didStart(*m_processPool, *this);
 }
 
 void DownloadProxy::didReceiveAuthenticationChallenge(const AuthenticationChallenge& authenticationChallenge, uint64_t challengeID)
@@ -121,33 +121,17 @@
     if (!m_processPool)
         return;
 
-    RefPtr<AuthenticationChallengeProxy> authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_processPool->networkingProcessConnection());
+    auto authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_processPool->networkingProcessConnection());
 
-    m_processPool->downloadClient().didReceiveAuthenticationChallenge(m_processPool.get(), this, authenticationChallengeProxy.get());
+    m_processPool->downloadClient().didReceiveAuthenticationChallenge(*m_processPool, *this, authenticationChallengeProxy.get());
 }
 
-#if USE(NETWORK_SESSION) && USE(PROTECTION_SPACE_AUTH_CALLBACK)
-void DownloadProxy::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
+void DownloadProxy::willSendRequest(ResourceRequest&& proposedRequest, const ResourceResponse& redirectResponse)
 {
     if (!m_processPool)
         return;
-    
-    auto* networkProcessProxy = m_processPool->networkProcess();
-    if (!networkProcessProxy)
-        return;
 
-    bool result = m_processPool->downloadClient().canAuthenticateAgainstProtectionSpace(getPtr(WebProtectionSpace::create(protectionSpace)));
-    
-    networkProcessProxy->send(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpaceDownload(m_downloadID, result), 0);
-}
-#endif
-
-void DownloadProxy::willSendRequest(const ResourceRequest& proposedRequest, const ResourceResponse& redirectResponse)
-{
-    if (!m_processPool)
-        return;
-
-    m_processPool->downloadClient().willSendRequest(m_processPool.get(), this, proposedRequest, redirectResponse, [this, protectedThis = makeRef(*this)](const ResourceRequest& newRequest) {
+    m_processPool->downloadClient().willSendRequest(*m_processPool, *this, WTFMove(proposedRequest), redirectResponse, [this, protectedThis = makeRef(*this)](ResourceRequest&& newRequest) {
         m_redirectChain.append(newRequest.url());
 
 #if USE(NETWORK_SESSION)
@@ -175,7 +159,7 @@
         m_suggestedFilename = String();
 #endif
 
-    m_processPool->downloadClient().didReceiveResponse(m_processPool.get(), this, response);
+    m_processPool->downloadClient().didReceiveResponse(*m_processPool, *this, response);
 }
 
 void DownloadProxy::didReceiveData(uint64_t length)
@@ -183,9 +167,10 @@
     if (!m_processPool)
         return;
 
-    m_processPool->downloadClient().didReceiveData(m_processPool.get(), this, length);
+    m_processPool->downloadClient().didReceiveData(*m_processPool, *this, length);
 }
 
+#if !USE(NETWORK_SESSION)
 void DownloadProxy::shouldDecodeSourceDataOfMIMEType(const String& mimeType, bool& result)
 {
     result = false;
@@ -193,40 +178,39 @@
     if (!m_processPool)
         return;
 
-    result = m_processPool->downloadClient().shouldDecodeSourceDataOfMIMEType(m_processPool.get(), this, mimeType);
+    result = m_processPool->downloadClient().shouldDecodeSourceDataOfMIMEType(*m_processPool, *this, mimeType);
 }
+#endif
 
 void DownloadProxy::decideDestinationWithSuggestedFilenameAsync(DownloadID downloadID, const String& suggestedFilename)
 {
-    bool allowOverwrite = false;
-    
     if (!m_processPool)
         return;
     
-    String destination = m_processPool->downloadClient().decideDestinationWithSuggestedFilename(m_processPool.get(), this, suggestedFilename, allowOverwrite);
-    
-    SandboxExtension::Handle sandboxExtensionHandle;
-    if (!destination.isNull())
-        SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
+    m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*m_processPool, *this, suggestedFilename, [this, protectedThis = makeRef(*this), downloadID = downloadID] (AllowOverwrite allowOverwrite, String destination) {
+        SandboxExtension::Handle sandboxExtensionHandle;
+        if (!destination.isNull())
+            SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
 
-    if (NetworkProcessProxy* networkProcess = m_processPool->networkProcess())
-        networkProcess->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite), 0);
+        if (auto* networkProcess = m_processPool->networkProcess())
+            networkProcess->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite == AllowOverwrite::Yes), 0);
+    });
 }
 
 #if !USE(NETWORK_SESSION)
 
-void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle)
+void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, Ref<Messages::DownloadProxy::DecideDestinationWithSuggestedFilename::DelayedReply>&& reply)
 {
-    allowOverwrite = false;
-
     if (!m_processPool)
         return;
 
     String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(m_suggestedFilename.isEmpty() ? filename : m_suggestedFilename, mimeType);
-    destination = m_processPool->downloadClient().decideDestinationWithSuggestedFilename(m_processPool.get(), this, suggestedFilename, allowOverwrite);
-
-    if (!destination.isNull())
-        SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
+    m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*m_processPool, *this, filename, [reply = WTFMove(reply)] (AllowOverwrite allowOverwrite, String destination) {
+        SandboxExtension::Handle sandboxExtensionHandle;
+        if (!destination.isNull())
+            SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
+        reply->send(destination, allowOverwrite == AllowOverwrite::Yes, sandboxExtensionHandle);
+    });
 }
 
 #endif
@@ -236,7 +220,7 @@
     if (!m_processPool)
         return;
 
-    m_processPool->downloadClient().didCreateDestination(m_processPool.get(), this, path);
+    m_processPool->downloadClient().didCreateDestination(*m_processPool, *this, path);
 }
 
 void DownloadProxy::didFinish()
@@ -244,7 +228,7 @@
     if (!m_processPool)
         return;
 
-    m_processPool->downloadClient().didFinish(m_processPool.get(), this);
+    m_processPool->downloadClient().didFinish(*m_processPool, *this);
 
     // This can cause the DownloadProxy object to be deleted.
     m_downloadProxyMap.downloadFinished(this);
@@ -265,7 +249,7 @@
 
     m_resumeData = createData(resumeData);
 
-    m_processPool->downloadClient().didFail(m_processPool.get(), this, error);
+    m_processPool->downloadClient().didFail(*m_processPool, *this, error);
 
     // This can cause the DownloadProxy object to be deleted.
     m_downloadProxyMap.downloadFinished(this);
@@ -275,7 +259,7 @@
 {
     m_resumeData = createData(resumeData);
 
-    m_processPool->downloadClient().didCancel(m_processPool.get(), this);
+    m_processPool->downloadClient().didCancel(*m_processPool, *this);
 
     // This can cause the DownloadProxy object to be deleted.
     m_downloadProxyMap.downloadFinished(this);

Modified: trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.h (223729 => 223730)


--- trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.h	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.h	2017-10-20 00:09:38 UTC (rev 223730)
@@ -23,12 +23,12 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DownloadProxy_h
-#define DownloadProxy_h
+#pragma once
 
 #include "APIObject.h"
 #include "Connection.h"
 #include "DownloadID.h"
+#include "DownloadProxyMessages.h"
 #include "SandboxExtension.h"
 #include <WebCore/ResourceRequest.h>
 #include <wtf/Forward.h>
@@ -97,14 +97,10 @@
     void didFinish();
     void didFail(const WebCore::ResourceError&, const IPC::DataReference& resumeData);
     void didCancel(const IPC::DataReference& resumeData);
-    void willSendRequest(const WebCore::ResourceRequest& redirectRequest, const WebCore::ResourceResponse& redirectResponse);
-#if USE(NETWORK_SESSION)
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-    void canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace&);
+    void willSendRequest(WebCore::ResourceRequest&& redirectRequest, const WebCore::ResourceResponse& redirectResponse);
+#if !USE(NETWORK_SESSION)
+    void decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, Ref<Messages::DownloadProxy::DecideDestinationWithSuggestedFilename::DelayedReply>&&);
 #endif
-#else
-    void decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle);
-#endif
     void decideDestinationWithSuggestedFilenameAsync(DownloadID, const String& suggestedFilename);
 
     DownloadProxyMap& m_downloadProxyMap;
@@ -121,5 +117,3 @@
 };
 
 } // namespace WebKit
-
-#endif // DownloadProxy_h

Modified: trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.messages.in (223729 => 223730)


--- trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.messages.in	2017-10-19 23:49:23 UTC (rev 223729)
+++ trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.messages.in	2017-10-20 00:09:38 UTC (rev 223730)
@@ -24,18 +24,13 @@
     DidStart(WebCore::ResourceRequest request, AtomicString suggestedFilename)
     DidReceiveAuthenticationChallenge(WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
     WillSendRequest(WebCore::ResourceRequest redirectRequest, WebCore::ResourceResponse redirectResponse))
-#if USE(NETWORK_SESSION)
-#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-    CanAuthenticateAgainstProtectionSpace(WebCore::ProtectionSpace protectionSpace)
-#endif
-#endif
     DecideDestinationWithSuggestedFilenameAsync(WebKit::DownloadID downloadID, String suggestedFilename)
 
     DidReceiveResponse(WebCore::ResourceResponse response)
     DidReceiveData(uint64_t length)
+#if !USE(NETWORK_SESSION)
     ShouldDecodeSourceDataOfMIMEType(String mimeType) -> (bool result)
-#if !USE(NETWORK_SESSION)
-    DecideDestinationWithSuggestedFilename(String filename, String mimeType) -> (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
+    DecideDestinationWithSuggestedFilename(String filename, String mimeType) -> (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle) Delayed
 #endif
     DidCreateDestination(String path)
     DidFinish()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to