Changeset 223730 in webkit


Ignore:
Timestamp:
Oct 19, 2017 5:09:38 PM (7 years ago)
Author:
achristensen@apple.com
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:
Location:
trunk/Source/WebKit
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r223726 r223730  
     12017-10-19  Alex Christensen  <achristensen@webkit.org>
     2
     3        Modernize API::DownloadClient
     4        https://bugs.webkit.org/show_bug.cgi?id=178547
     5
     6        Reviewed by Andy Estes.
     7
     8        Use more C++ references instead of pointers because they're never null.
     9
     10        Remove canAuthenticateAgainstProtectionSpace because there are no implementations
     11        except the default implementation which always returns true and we don't intend to
     12        add this to the SPI because that's just a legacy call anyways from when NSURLConnection
     13        hadn't fully evolved, and we're moving away from NSURLConnection, especially in our API design.
     14
     15        Separate the NetworkSession-only and pre-NetworkSession-only callbacks.  All the synchronous
     16        IPC messages are only used in the pre-NetworkSession code, so once we remove it we can remove them!
     17
     18        Make API::DownloadClient calls that NetworkSession uses use a completion handler so we will be able to
     19        design an asynchronous API.
     20
     21        * NetworkProcess/Downloads/DownloadManager.cpp:
     22        (WebKit::DownloadManager::continueCanAuthenticateAgainstProtectionSpace): Deleted.
     23        * NetworkProcess/Downloads/DownloadManager.h:
     24        * NetworkProcess/Downloads/PendingDownload.cpp:
     25        (WebKit::PendingDownload::canAuthenticateAgainstProtectionSpaceAsync):
     26        (WebKit::PendingDownload::continueCanAuthenticateAgainstProtectionSpace): Deleted.
     27        * NetworkProcess/Downloads/PendingDownload.h:
     28        * NetworkProcess/NetworkProcess.cpp:
     29        (WebKit::NetworkProcess::continueCanAuthenticateAgainstProtectionSpaceDownload): Deleted.
     30        * NetworkProcess/NetworkProcess.h:
     31        * NetworkProcess/NetworkProcess.messages.in:
     32        * UIProcess/API/APIDownloadClient.h:
     33        (API::DownloadClient::didStart):
     34        (API::DownloadClient::didReceiveAuthenticationChallenge):
     35        (API::DownloadClient::didReceiveResponse):
     36        (API::DownloadClient::didReceiveData):
     37        (API::DownloadClient::shouldDecodeSourceDataOfMIMEType):
     38        (API::DownloadClient::decideDestinationWithSuggestedFilename):
     39        (API::DownloadClient::didCreateDestination):
     40        (API::DownloadClient::didFinish):
     41        (API::DownloadClient::didFail):
     42        (API::DownloadClient::didCancel):
     43        (API::DownloadClient::processDidCrash):
     44        (API::DownloadClient::willSendRequest):
     45        (API::DownloadClient::canAuthenticateAgainstProtectionSpace): Deleted.
     46        * UIProcess/API/C/WKContext.cpp:
     47        (WKContextSetDownloadClient):
     48        * UIProcess/API/glib/WebKitDownloadClient.cpp:
     49        * UIProcess/Cocoa/DownloadClient.h:
     50        * UIProcess/Cocoa/DownloadClient.mm:
     51        (WebKit::DownloadClient::didStart):
     52        (WebKit::DownloadClient::didReceiveResponse):
     53        (WebKit::DownloadClient::didReceiveData):
     54        (WebKit::DownloadClient::decideDestinationWithSuggestedFilename):
     55        (WebKit::DownloadClient::didFinish):
     56        (WebKit::DownloadClient::didFail):
     57        (WebKit::DownloadClient::didCancel):
     58        (WebKit::DownloadClient::willSendRequest):
     59        * UIProcess/Downloads/DownloadProxy.cpp:
     60        (WebKit::DownloadProxy::processDidClose):
     61        (WebKit::DownloadProxy::didStart):
     62        (WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
     63        (WebKit::DownloadProxy::willSendRequest):
     64        (WebKit::DownloadProxy::didReceiveResponse):
     65        (WebKit::DownloadProxy::didReceiveData):
     66        (WebKit::DownloadProxy::shouldDecodeSourceDataOfMIMEType):
     67        (WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
     68        (WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
     69        (WebKit::DownloadProxy::didCreateDestination):
     70        (WebKit::DownloadProxy::didFinish):
     71        (WebKit::DownloadProxy::didFail):
     72        (WebKit::DownloadProxy::didCancel):
     73        (WebKit::DownloadProxy::canAuthenticateAgainstProtectionSpace): Deleted.
     74        * UIProcess/Downloads/DownloadProxy.h:
     75        * UIProcess/Downloads/DownloadProxy.messages.in:
     76
    1772017-10-19  Nan Wang  <n_wang@apple.com>
    278
  • trunk/Source/WebKit/NetworkProcess/Downloads/Download.cpp

    r223431 r223730  
    161161    }
    162162
    163 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    164     m_challenge = challenge;
    165     m_challengeCompletionHandler = WTFMove(completionHandler);
    166     send(Messages::DownloadProxy::CanAuthenticateAgainstProtectionSpace(challenge.protectionSpace()));
    167 #else
    168163    NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(*this, challenge, WTFMove(completionHandler));
    169 #endif
    170 }
    171 
    172 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    173 void Download::continueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate)
    174 {
    175     ASSERT(m_challengeCompletionHandler);
    176     auto completionHandler = std::exchange(m_challengeCompletionHandler, nullptr);
    177     if (!canAuthenticate) {
    178         if (NetworkSession::allowsSpecificHTTPSCertificateForHost(*m_challenge))
    179             completionHandler(AuthenticationChallengeDisposition::UseCredential, serverTrustCredential(*m_challenge));
    180         else
    181             completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, { });
    182         return;
    183     }
    184 
    185     NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(*this, *m_challenge, WTFMove(completionHandler));
    186 }
    187 #endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
     164}
    188165#endif // USE(NETWORK_SESSION)
    189166
  • trunk/Source/WebKit/NetworkProcess/Downloads/Download.h

    r223431 r223730  
    2424 */
    2525
    26 #ifndef Download_h
    27 #define Download_h
     26#pragma once
    2827
    2928#include "DownloadID.h"
     
    105104    void setSandboxExtension(RefPtr<SandboxExtension>&& sandboxExtension) { m_sandboxExtension = WTFMove(sandboxExtension); }
    106105    void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
    107 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    108     void continueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate);
    109 #endif
    110106#else
    111107    const WebCore::ResourceRequest& request() const { return m_request; }
     
    153149#endif
    154150    PAL::SessionID m_sessionID;
    155 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    156     std::optional<WebCore::AuthenticationChallenge> m_challenge;
    157     ChallengeCompletionHandler m_challengeCompletionHandler;
    158 #endif
    159151#else // USE(NETWORK_SESSION)
    160152    WebCore::ResourceRequest m_request;
     
    175167
    176168} // namespace WebKit
    177 
    178 #endif // Download_h
  • trunk/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp

    r223431 r223730  
    8787}
    8888
    89 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    90 void DownloadManager::continueCanAuthenticateAgainstProtectionSpace(DownloadID downloadID, bool canAuthenticate)
    91 {
    92     if (auto* pendingDownload = m_pendingDownloads.get(downloadID)) {
    93         pendingDownload->continueCanAuthenticateAgainstProtectionSpace(canAuthenticate);
    94         return;
    95     }
    96     if (auto* download = m_downloads.get(downloadID)) {
    97         download->continueCanAuthenticateAgainstProtectionSpace(canAuthenticate);
    98         return;
    99     }
    100     ASSERT_NOT_REACHED();
    101 }
    102 #endif
    103 
    10489void DownloadManager::continueWillSendRequest(DownloadID downloadID, WebCore::ResourceRequest&& request)
    10590{
  • trunk/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h

    r220857 r223730  
    2424 */
    2525
    26 #ifndef DownloadManager_h
    27 #define DownloadManager_h
     26#pragma once
    2827
    2928#include "DownloadID.h"
     
    8281#if USE(NETWORK_SESSION)
    8382    void dataTaskBecameDownloadTask(DownloadID, std::unique_ptr<Download>&&);
    84 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    85     void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate);
    86 #endif
    8783    void continueWillSendRequest(DownloadID, WebCore::ResourceRequest&&);
    8884    void willDecidePendingDownloadDestination(NetworkDataTask&, ResponseCompletionHandler&&);
     
    118114
    119115} // namespace WebKit
    120 
    121 #endif // DownloadManager_h
  • trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp

    r208521 r223730  
    7878void PendingDownload::canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace& protectionSpace)
    7979{
    80     send(Messages::DownloadProxy::CanAuthenticateAgainstProtectionSpace(protectionSpace));
    81 }
    82 
    83 void PendingDownload::continueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate)
    84 {
    85     m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(canAuthenticate);
     80    m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(true);
    8681}
    8782#endif
  • trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h

    r212993 r223730  
    5050
    5151    void continueWillSendRequest(WebCore::ResourceRequest&&);
    52 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    53     void continueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate);
    54 #endif
    5552    void cancel();
    5653
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r223720 r223730  
    550550
    551551#if USE(NETWORK_SESSION)
    552 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    553 void NetworkProcess::continueCanAuthenticateAgainstProtectionSpaceDownload(DownloadID downloadID, bool canAuthenticate)
    554 {
    555     downloadManager().continueCanAuthenticateAgainstProtectionSpace(downloadID, canAuthenticate);
    556 }
    557 #endif
    558 
    559552void NetworkProcess::continueWillSendRequest(DownloadID downloadID, WebCore::ResourceRequest&& request)
    560553{
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r223179 r223730  
    207207#endif
    208208#if USE(NETWORK_SESSION)
    209 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    210     void continueCanAuthenticateAgainstProtectionSpaceDownload(DownloadID, bool canAuthenticate);
    211 #endif
    212209    void continueWillSendRequest(DownloadID, WebCore::ResourceRequest&&);
    213210#endif
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r222613 r223730  
    5252#endif
    5353#if USE(NETWORK_SESSION)
    54 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    55     ContinueCanAuthenticateAgainstProtectionSpaceDownload(WebKit::DownloadID downloadID, bool canAuthenticate)
    56 #endif
    5754    ContinueWillSendRequest(WebKit::DownloadID downloadID, WebCore::ResourceRequest request)
    5855#endif
  • trunk/Source/WebKit/UIProcess/API/APIDownloadClient.h

    r221749 r223730  
    2424 */
    2525
    26 #ifndef APIDownloadClient_h
    27 #define APIDownloadClient_h
     26#pragma once
    2827
    2928#include <wtf/Function.h>
     
    4140class WebProcessPool;
    4241class WebProtectionSpace;
     42
     43enum class AllowOverwrite { No, Yes };
    4344}
    4445
     
    4950    virtual ~DownloadClient() { }
    5051
    51     virtual void didStart(WebKit::WebProcessPool*, WebKit::DownloadProxy*) { }
    52     virtual void didReceiveAuthenticationChallenge(WebKit::WebProcessPool*, WebKit::DownloadProxy*, WebKit::AuthenticationChallengeProxy*) { }
    53     virtual void didReceiveResponse(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WebCore::ResourceResponse&) { }
    54     virtual void didReceiveData(WebKit::WebProcessPool*, WebKit::DownloadProxy*, uint64_t) { }
    55     virtual bool shouldDecodeSourceDataOfMIMEType(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WTF::String&) { return true; }
    56     virtual WTF::String decideDestinationWithSuggestedFilename(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WTF::String&, bool&) { return { }; }
    57     virtual void didCreateDestination(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WTF::String&) { }
    58     virtual void didFinish(WebKit::WebProcessPool*, WebKit::DownloadProxy*) { }
    59     virtual void didFail(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WebCore::ResourceError&) { }
    60     virtual void didCancel(WebKit::WebProcessPool*, WebKit::DownloadProxy*) { }
    61     virtual void processDidCrash(WebKit::WebProcessPool*, WebKit::DownloadProxy*) { }
    62     virtual bool canAuthenticateAgainstProtectionSpace(WebKit::WebProtectionSpace*) { return true; }
    63     virtual void willSendRequest(WebKit::WebProcessPool*, WebKit::DownloadProxy*, const WebCore::ResourceRequest& request, const WebCore::ResourceResponse&, WTF::Function<void(const WebCore::ResourceRequest&)>&& callback) { callback(request); }
     52    virtual void didStart(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
     53    virtual void didReceiveAuthenticationChallenge(WebKit::WebProcessPool&, WebKit::DownloadProxy&, WebKit::AuthenticationChallengeProxy&) { }
     54    virtual void didReceiveResponse(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WebCore::ResourceResponse&) { }
     55    virtual void didReceiveData(WebKit::WebProcessPool&, WebKit::DownloadProxy&, uint64_t) { }
     56#if !USE(NETWORK_SESSION)
     57    virtual bool shouldDecodeSourceDataOfMIMEType(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&) { return true; }
     58#endif
     59    virtual void decideDestinationWithSuggestedFilename(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&, Function<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) { completionHandler(WebKit::AllowOverwrite::No, { }); }
     60    virtual void didCreateDestination(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&) { }
     61    virtual void didFinish(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
     62    virtual void didFail(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WebCore::ResourceError&) { }
     63    virtual void didCancel(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
     64    virtual void processDidCrash(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
     65    virtual void willSendRequest(WebKit::WebProcessPool&, WebKit::DownloadProxy&, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, Function<void(WebCore::ResourceRequest&&)>&& completionHandler) { completionHandler(WTFMove(request)); }
    6466};
    6567
    6668} // namespace API
    67 
    68 #endif // APIDownloadClient_h
  • trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp

    r222664 r223730  
    173173        }
    174174    private:
    175         void didStart(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
     175        void didStart(WebProcessPool& processPool, DownloadProxy& downloadProxy) final
    176176        {
    177177            if (!m_client.didStart)
    178178                return;
    179179
    180             m_client.didStart(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
    181         }
    182 
    183         void didReceiveAuthenticationChallenge(WebProcessPool* processPool, DownloadProxy* downloadProxy, AuthenticationChallengeProxy* authenticationChallengeProxy) override
     180            m_client.didStart(toAPI(&processPool), toAPI(&downloadProxy), m_client.base.clientInfo);
     181        }
     182
     183        void didReceiveAuthenticationChallenge(WebProcessPool& processPool, DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallengeProxy) final
    184184        {
    185185            if (!m_client.didReceiveAuthenticationChallenge)
    186186                return;
    187187
    188             m_client.didReceiveAuthenticationChallenge(toAPI(processPool), toAPI(downloadProxy), toAPI(authenticationChallengeProxy), m_client.base.clientInfo);
    189         }
    190 
    191         void didReceiveResponse(WebProcessPool* processPool, DownloadProxy* downloadProxy, const ResourceResponse& response) override
     188            m_client.didReceiveAuthenticationChallenge(toAPI(&processPool), toAPI(&downloadProxy), toAPI(&authenticationChallengeProxy), m_client.base.clientInfo);
     189        }
     190
     191        void didReceiveResponse(WebProcessPool& processPool, DownloadProxy& downloadProxy, const ResourceResponse& response) final
    192192        {
    193193            if (!m_client.didReceiveResponse)
    194194                return;
    195195
    196             m_client.didReceiveResponse(toAPI(processPool), toAPI(downloadProxy), toAPI(API::URLResponse::create(response).ptr()), m_client.base.clientInfo);
    197         }
    198 
    199         void didReceiveData(WebProcessPool* processPool, DownloadProxy* downloadProxy, uint64_t length) override
     196            m_client.didReceiveResponse(toAPI(&processPool), toAPI(&downloadProxy), toAPI(API::URLResponse::create(response).ptr()), m_client.base.clientInfo);
     197        }
     198
     199        void didReceiveData(WebProcessPool& processPool, DownloadProxy& downloadProxy, uint64_t length) final
    200200        {
    201201            if (!m_client.didReceiveData)
    202202                return;
    203203
    204             m_client.didReceiveData(toAPI(processPool), toAPI(downloadProxy), length, m_client.base.clientInfo);
    205         }
    206 
    207         bool shouldDecodeSourceDataOfMIMEType(WebProcessPool* processPool, DownloadProxy* downloadProxy, const String& mimeType) override
     204            m_client.didReceiveData(toAPI(&processPool), toAPI(&downloadProxy), length, m_client.base.clientInfo);
     205        }
     206
     207#if !USE(NETWORK_SESSION)
     208        bool shouldDecodeSourceDataOfMIMEType(WebProcessPool& processPool, DownloadProxy& downloadProxy, const String& mimeType) final
    208209        {
    209210            if (!m_client.shouldDecodeSourceDataOfMIMEType)
    210211                return true;
    211212
    212             return m_client.shouldDecodeSourceDataOfMIMEType(toAPI(processPool), toAPI(downloadProxy), toAPI(mimeType.impl()), m_client.base.clientInfo);
    213         }
    214 
    215         String decideDestinationWithSuggestedFilename(WebProcessPool* processPool, DownloadProxy* downloadProxy, const String& filename, bool& allowOverwrite) override
     213            return m_client.shouldDecodeSourceDataOfMIMEType(toAPI(&processPool), toAPI(&downloadProxy), toAPI(mimeType.impl()), m_client.base.clientInfo);
     214        }
     215#endif
     216
     217        void decideDestinationWithSuggestedFilename(WebProcessPool& processPool, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, WTF::String)>&& completionHandler) final
    216218        {
    217219            if (!m_client.decideDestinationWithSuggestedFilename)
    218                 return String();
    219 
    220             WKRetainPtr<WKStringRef> destination(AdoptWK, m_client.decideDestinationWithSuggestedFilename(toAPI(processPool), toAPI(downloadProxy), toAPI(filename.impl()), &allowOverwrite, m_client.base.clientInfo));
    221             return toWTFString(destination.get());
    222         }
    223 
    224         void didCreateDestination(WebProcessPool* processPool, DownloadProxy* downloadProxy, const String& path) override
     220                return completionHandler(AllowOverwrite::No, { });
     221
     222            bool allowOverwrite = false;
     223            WKRetainPtr<WKStringRef> destination(AdoptWK, m_client.decideDestinationWithSuggestedFilename(toAPI(&processPool), toAPI(&downloadProxy), toAPI(filename.impl()), &allowOverwrite, m_client.base.clientInfo));
     224            completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, toWTFString(destination.get()));
     225        }
     226
     227        void didCreateDestination(WebProcessPool& processPool, DownloadProxy& downloadProxy, const String& path) final
    225228        {
    226229            if (!m_client.didCreateDestination)
    227230                return;
    228231
    229             m_client.didCreateDestination(toAPI(processPool), toAPI(downloadProxy), toAPI(path.impl()), m_client.base.clientInfo);
    230         }
    231 
    232         void didFinish(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
     232            m_client.didCreateDestination(toAPI(&processPool), toAPI(&downloadProxy), toAPI(path.impl()), m_client.base.clientInfo);
     233        }
     234
     235        void didFinish(WebProcessPool& processPool, DownloadProxy& downloadProxy) final
    233236        {
    234237            if (!m_client.didFinish)
    235238                return;
    236239
    237             m_client.didFinish(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
    238         }
    239 
    240         void didFail(WebProcessPool* processPool, DownloadProxy* downloadProxy, const ResourceError& error) override
     240            m_client.didFinish(toAPI(&processPool), toAPI(&downloadProxy), m_client.base.clientInfo);
     241        }
     242
     243        void didFail(WebProcessPool& processPool, DownloadProxy& downloadProxy, const ResourceError& error) final
    241244        {
    242245            if (!m_client.didFail)
    243246                return;
    244247
    245             m_client.didFail(toAPI(processPool), toAPI(downloadProxy), toAPI(error), m_client.base.clientInfo);
     248            m_client.didFail(toAPI(&processPool), toAPI(&downloadProxy), toAPI(error), m_client.base.clientInfo);
    246249        }
    247250       
    248         void didCancel(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
     251        void didCancel(WebProcessPool& processPool, DownloadProxy& downloadProxy) final
    249252        {
    250253            if (!m_client.didCancel)
    251254                return;
    252255           
    253             m_client.didCancel(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
     256            m_client.didCancel(toAPI(&processPool), toAPI(&downloadProxy), m_client.base.clientInfo);
    254257        }
    255258       
    256         void processDidCrash(WebProcessPool* processPool, DownloadProxy* downloadProxy) override
     259        void processDidCrash(WebProcessPool& processPool, DownloadProxy& downloadProxy) final
    257260        {
    258261            if (!m_client.processDidCrash)
    259262                return;
    260263           
    261             m_client.processDidCrash(toAPI(processPool), toAPI(downloadProxy), m_client.base.clientInfo);
    262         }
    263 
    264         void willSendRequest(WebProcessPool* processPool, DownloadProxy* downloadProxy, const ResourceRequest& request, const ResourceResponse&, WTF::Function<void(const ResourceRequest&)>&& callback) override
     264            m_client.processDidCrash(toAPI(&processPool), toAPI(&downloadProxy), m_client.base.clientInfo);
     265        }
     266
     267        void willSendRequest(WebProcessPool& processPool, DownloadProxy& downloadProxy, ResourceRequest&& request, const ResourceResponse&, Function<void(ResourceRequest&&)>&& callback) final
    265268        {
    266269            if (m_client.didReceiveServerRedirect)
    267                 m_client.didReceiveServerRedirect(toAPI(processPool), toAPI(downloadProxy), toURLRef(request.url().string().impl()), m_client.base.clientInfo);
    268 
    269             callback(request);
     270                m_client.didReceiveServerRedirect(toAPI(&processPool), toAPI(&downloadProxy), toURLRef(request.url().string().impl()), m_client.base.clientInfo);
     271
     272            callback(WTFMove(request));
    270273        }
    271274
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp

    r218487 r223730  
    4141
    4242private:
    43     void didStart(WebProcessPool*, DownloadProxy* downloadProxy) override
     43    void didStart(WebProcessPool&, DownloadProxy& downloadProxy) override
    4444    {
    45         GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
     45        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
    4646        webkitWebContextDownloadStarted(m_webContext, download.get());
    4747    }
    4848
    49     void didReceiveAuthenticationChallenge(WebProcessPool*, DownloadProxy* downloadProxy, AuthenticationChallengeProxy* authenticationChallenge) override
     49    void didReceiveAuthenticationChallenge(WebProcessPool&, DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallenge) override
    5050    {
    51         GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
     51        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
    5252        if (webkitDownloadIsCancelled(download.get()))
    5353            return;
     
    5555        // FIXME: Add API to handle authentication of downloads without a web view associted.
    5656        if (auto* webView = webkit_download_get_web_view(download.get()))
    57             webkitWebViewHandleAuthenticationChallenge(webView, authenticationChallenge);
     57            webkitWebViewHandleAuthenticationChallenge(webView, &authenticationChallenge);
    5858    }
    5959
    60     void didReceiveResponse(WebProcessPool*, DownloadProxy* downloadProxy, const ResourceResponse& resourceResponse) override
     60    void didReceiveResponse(WebProcessPool&, DownloadProxy& downloadProxy, const ResourceResponse& resourceResponse) override
    6161    {
    62         GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
     62        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
    6363        if (webkitDownloadIsCancelled(download.get()))
    6464            return;
     
    6868    }
    6969
    70     void didReceiveData(WebProcessPool*, DownloadProxy* downloadProxy, uint64_t length) override
     70    void didReceiveData(WebProcessPool&, DownloadProxy& downloadProxy, uint64_t length) override
    7171    {
    72         GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
     72        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
    7373        webkitDownloadNotifyProgress(download.get(), length);
    7474    }
    7575
    76     String decideDestinationWithSuggestedFilename(WebProcessPool*, DownloadProxy* downloadProxy, const String& filename, bool& allowOverwrite) override
     76    void decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler) override
    7777    {
    78         GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
    79         return webkitDownloadDecideDestinationWithSuggestedFilename(download.get(), filename.utf8(), allowOverwrite);
     78        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     79        bool allowOverwrite = false;
     80        String destination = webkitDownloadDecideDestinationWithSuggestedFilename(download.get(), filename.utf8(), allowOverwrite);
     81        completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, destination);
    8082    }
    8183
    82     void didCreateDestination(WebProcessPool*, DownloadProxy* downloadProxy, const String& path) override
     84    void didCreateDestination(WebProcessPool&, DownloadProxy& downloadProxy, const String& path) override
    8385    {
    84         GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
     86        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
    8587        webkitDownloadDestinationCreated(download.get(), path);
    8688    }
    8789
    88     void didFail(WebProcessPool*, DownloadProxy* downloadProxy, const ResourceError& error) override
     90    void didFail(WebProcessPool&, DownloadProxy& downloadProxy, const ResourceError& error) override
    8991    {
    90         GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
     92        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
    9193        if (webkitDownloadIsCancelled(download.get())) {
    9294            // Cancellation takes precedence over other errors.
     
    9496        } else
    9597            webkitDownloadFailed(download.get(), error);
    96         webkitWebContextRemoveDownload(downloadProxy);
     98        webkitWebContextRemoveDownload(&downloadProxy);
    9799    }
    98100
    99     void didCancel(WebProcessPool*, DownloadProxy* downloadProxy) override
     101    void didCancel(WebProcessPool&, DownloadProxy& downloadProxy) override
    100102    {
    101         GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
     103        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
    102104        webkitDownloadCancelled(download.get());
    103         webkitWebContextRemoveDownload(downloadProxy);
     105        webkitWebContextRemoveDownload(&downloadProxy);
    104106    }
    105107
    106     void didFinish(WebProcessPool*, DownloadProxy* downloadProxy) override
     108    void didFinish(WebProcessPool&, DownloadProxy& downloadProxy) override
    107109    {
    108         GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
     110        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
    109111        webkitDownloadFinished(download.get());
    110         webkitWebContextRemoveDownload(downloadProxy);
     112        webkitWebContextRemoveDownload(&downloadProxy);
    111113    }
    112114
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h

    r221749 r223730  
    2424 */
    2525
    26 #ifndef DownloadClient_h
    27 #define DownloadClient_h
     26#pragma once
    2827
    2928#import "WKFoundation.h"
     
    4241
    4342namespace WebKit {
    44    
     43
    4544class DownloadClient final : public API::DownloadClient {
    4645public:
     
    4948private:
    5049    // From API::DownloadClient
    51     void didStart(WebProcessPool*, DownloadProxy*) final;
    52     void didReceiveResponse(WebProcessPool*, DownloadProxy*, const WebCore::ResourceResponse&) final;
    53     void didReceiveData(WebProcessPool*, DownloadProxy*, uint64_t length) final;
    54     String decideDestinationWithSuggestedFilename(WebProcessPool*, DownloadProxy*, const String& filename, bool& allowOverwriteParam) final;
    55     void didFinish(WebProcessPool*, DownloadProxy*) final;
    56     void didFail(WebProcessPool*, DownloadProxy*, const WebCore::ResourceError&) final;
    57     void didCancel(WebProcessPool*, DownloadProxy*) final;
    58     void willSendRequest(WebProcessPool*, DownloadProxy*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, WTF::Function<void(const WebCore::ResourceRequest&)>&&) final;
     50    void didStart(WebProcessPool&, DownloadProxy&) final;
     51    void didReceiveResponse(WebProcessPool&, DownloadProxy&, const WebCore::ResourceResponse&) final;
     52    void didReceiveData(WebProcessPool&, DownloadProxy&, uint64_t length) final;
     53    void decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy&, const String& suggestedFilename, Function<void(AllowOverwrite, String)>&&) final;
     54    void didFinish(WebProcessPool&, DownloadProxy&) final;
     55    void didFail(WebProcessPool&, DownloadProxy&, const WebCore::ResourceError&) final;
     56    void didCancel(WebProcessPool&, DownloadProxy&) final;
     57    void willSendRequest(WebProcessPool&, DownloadProxy&, WebCore::ResourceRequest&&, const WebCore::ResourceResponse&, Function<void(WebCore::ResourceRequest&&)>&&) final;
    5958
    6059    WeakObjCPtr<id <_WKDownloadDelegate>> m_delegate;
     
    7574
    7675#endif
    77 
    78 #endif // DownloadClient_h
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

    r221749 r223730  
    5757}
    5858
    59 void DownloadClient::didStart(WebProcessPool*, DownloadProxy* downloadProxy)
     59void DownloadClient::didStart(WebProcessPool&, DownloadProxy& downloadProxy)
    6060{
    6161    if (m_delegateMethods.downloadDidStart)
    62         [m_delegate.get() _downloadDidStart:wrapper(*downloadProxy)];
     62        [m_delegate.get() _downloadDidStart:wrapper(downloadProxy)];
    6363}
    6464
    65 void DownloadClient::didReceiveResponse(WebProcessPool*, DownloadProxy* downloadProxy, const WebCore::ResourceResponse& response)
     65void DownloadClient::didReceiveResponse(WebProcessPool&, DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response)
    6666{
    6767    if (m_delegateMethods.downloadDidReceiveResponse)
    68         [m_delegate.get() _download:wrapper(*downloadProxy) didReceiveResponse:response.nsURLResponse()];
     68        [m_delegate.get() _download:wrapper(downloadProxy) didReceiveResponse:response.nsURLResponse()];
    6969}
    7070
    71 void DownloadClient::didReceiveData(WebProcessPool*, DownloadProxy* downloadProxy, uint64_t length)
     71void DownloadClient::didReceiveData(WebProcessPool&, DownloadProxy& downloadProxy, uint64_t length)
    7272{
    7373    if (m_delegateMethods.downloadDidReceiveData)
    74         [m_delegate.get() _download:wrapper(*downloadProxy) didReceiveData:length];
     74        [m_delegate.get() _download:wrapper(downloadProxy) didReceiveData:length];
    7575}
    7676
    77 String DownloadClient::decideDestinationWithSuggestedFilename(WebProcessPool*, DownloadProxy* downloadProxy, const String& filename, bool& allowOverwriteParam)
     77void DownloadClient::decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler)
    7878{
    7979    if (!m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameAllowOverwrite)
    80         return String();
    81    
     80        return completionHandler(AllowOverwrite::No, { });
     81
    8282    BOOL allowOverwrite = NO;
    83     NSString *destination = [m_delegate.get() _download:wrapper(*downloadProxy) decideDestinationWithSuggestedFilename:filename allowOverwrite:&allowOverwrite];
    84     allowOverwriteParam = allowOverwrite;
    85     return destination;
     83    NSString *destination = [m_delegate.get() _download:wrapper(downloadProxy) decideDestinationWithSuggestedFilename:filename allowOverwrite:&allowOverwrite];
     84    completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, destination);
    8685}
    8786
    88 void DownloadClient::didFinish(WebProcessPool*, DownloadProxy* downloadProxy)
     87void DownloadClient::didFinish(WebProcessPool&, DownloadProxy& downloadProxy)
    8988{
    9089    if (m_delegateMethods.downloadDidFinish)
    91         [m_delegate.get() _downloadDidFinish:wrapper(*downloadProxy)];
     90        [m_delegate.get() _downloadDidFinish:wrapper(downloadProxy)];
    9291}
    9392
    94 void DownloadClient::didFail(WebProcessPool*, DownloadProxy* downloadProxy, const WebCore::ResourceError& error)
     93void DownloadClient::didFail(WebProcessPool&, DownloadProxy& downloadProxy, const WebCore::ResourceError& error)
    9594{
    9695    if (m_delegateMethods.downloadDidFail)
    97         [m_delegate.get() _download:wrapper(*downloadProxy) didFailWithError:error.nsError()];
     96        [m_delegate.get() _download:wrapper(downloadProxy) didFailWithError:error.nsError()];
    9897}
    9998
    100 void DownloadClient::didCancel(WebProcessPool*, DownloadProxy* downloadProxy)
     99void DownloadClient::didCancel(WebProcessPool&, DownloadProxy& downloadProxy)
    101100{
    102101    if (m_delegateMethods.downloadDidCancel)
    103         [m_delegate.get() _downloadDidCancel:wrapper(*downloadProxy)];
     102        [m_delegate.get() _downloadDidCancel:wrapper(downloadProxy)];
    104103}
    105104
    106 void DownloadClient::willSendRequest(WebProcessPool*, DownloadProxy* downloadProxy, const WebCore::ResourceRequest& request, const WebCore::ResourceResponse&, WTF::Function<void(const WebCore::ResourceRequest&)>&& callback)
     105void DownloadClient::willSendRequest(WebProcessPool&, DownloadProxy& downloadProxy, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, Function<void(WebCore::ResourceRequest&&)>&& callback)
    107106{
    108107    if (m_delegateMethods.downloadDidReceiveServerRedirectToURL)
    109         [m_delegate.get() _download:wrapper(*downloadProxy) didReceiveServerRedirectToURL:[NSURL _web_URLWithWTFString:request.url().string()]];
     108        [m_delegate.get() _download:wrapper(downloadProxy) didReceiveServerRedirectToURL:[NSURL _web_URLWithWTFString:request.url().string()]];
    110109
    111     callback(request);
     110    callback(WTFMove(request));
    112111}
    113112
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp

    r222308 r223730  
    9090        return;
    9191
    92     m_processPool->downloadClient().processDidCrash(m_processPool.get(), this);
     92    m_processPool->downloadClient().processDidCrash(*m_processPool, *this);
    9393}
    9494
     
    114114        return;
    115115
    116     m_processPool->downloadClient().didStart(m_processPool.get(), this);
     116    m_processPool->downloadClient().didStart(*m_processPool, *this);
    117117}
    118118
     
    122122        return;
    123123
    124     RefPtr<AuthenticationChallengeProxy> authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_processPool->networkingProcessConnection());
    125 
    126     m_processPool->downloadClient().didReceiveAuthenticationChallenge(m_processPool.get(), this, authenticationChallengeProxy.get());
    127 }
    128 
    129 #if USE(NETWORK_SESSION) && USE(PROTECTION_SPACE_AUTH_CALLBACK)
    130 void DownloadProxy::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
    131 {
    132     if (!m_processPool)
    133         return;
    134    
    135     auto* networkProcessProxy = m_processPool->networkProcess();
    136     if (!networkProcessProxy)
    137         return;
    138 
    139     bool result = m_processPool->downloadClient().canAuthenticateAgainstProtectionSpace(getPtr(WebProtectionSpace::create(protectionSpace)));
    140    
    141     networkProcessProxy->send(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpaceDownload(m_downloadID, result), 0);
    142 }
    143 #endif
    144 
    145 void DownloadProxy::willSendRequest(const ResourceRequest& proposedRequest, const ResourceResponse& redirectResponse)
    146 {
    147     if (!m_processPool)
    148         return;
    149 
    150     m_processPool->downloadClient().willSendRequest(m_processPool.get(), this, proposedRequest, redirectResponse, [this, protectedThis = makeRef(*this)](const ResourceRequest& newRequest) {
     124    auto authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_processPool->networkingProcessConnection());
     125
     126    m_processPool->downloadClient().didReceiveAuthenticationChallenge(*m_processPool, *this, authenticationChallengeProxy.get());
     127}
     128
     129void DownloadProxy::willSendRequest(ResourceRequest&& proposedRequest, const ResourceResponse& redirectResponse)
     130{
     131    if (!m_processPool)
     132        return;
     133
     134    m_processPool->downloadClient().willSendRequest(*m_processPool, *this, WTFMove(proposedRequest), redirectResponse, [this, protectedThis = makeRef(*this)](ResourceRequest&& newRequest) {
    151135        m_redirectChain.append(newRequest.url());
    152136
     
    176160#endif
    177161
    178     m_processPool->downloadClient().didReceiveResponse(m_processPool.get(), this, response);
     162    m_processPool->downloadClient().didReceiveResponse(*m_processPool, *this, response);
    179163}
    180164
     
    184168        return;
    185169
    186     m_processPool->downloadClient().didReceiveData(m_processPool.get(), this, length);
    187 }
    188 
     170    m_processPool->downloadClient().didReceiveData(*m_processPool, *this, length);
     171}
     172
     173#if !USE(NETWORK_SESSION)
    189174void DownloadProxy::shouldDecodeSourceDataOfMIMEType(const String& mimeType, bool& result)
    190175{
     
    194179        return;
    195180
    196     result = m_processPool->downloadClient().shouldDecodeSourceDataOfMIMEType(m_processPool.get(), this, mimeType);
    197 }
     181    result = m_processPool->downloadClient().shouldDecodeSourceDataOfMIMEType(*m_processPool, *this, mimeType);
     182}
     183#endif
    198184
    199185void DownloadProxy::decideDestinationWithSuggestedFilenameAsync(DownloadID downloadID, const String& suggestedFilename)
    200186{
    201     bool allowOverwrite = false;
     187    if (!m_processPool)
     188        return;
    202189   
    203     if (!m_processPool)
    204         return;
    205    
    206     String destination = m_processPool->downloadClient().decideDestinationWithSuggestedFilename(m_processPool.get(), this, suggestedFilename, allowOverwrite);
    207    
    208     SandboxExtension::Handle sandboxExtensionHandle;
    209     if (!destination.isNull())
    210         SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
    211 
    212     if (NetworkProcessProxy* networkProcess = m_processPool->networkProcess())
    213         networkProcess->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite), 0);
     190    m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*m_processPool, *this, suggestedFilename, [this, protectedThis = makeRef(*this), downloadID = downloadID] (AllowOverwrite allowOverwrite, String destination) {
     191        SandboxExtension::Handle sandboxExtensionHandle;
     192        if (!destination.isNull())
     193            SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
     194
     195        if (auto* networkProcess = m_processPool->networkProcess())
     196            networkProcess->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite == AllowOverwrite::Yes), 0);
     197    });
    214198}
    215199
    216200#if !USE(NETWORK_SESSION)
    217201
    218 void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle)
    219 {
    220     allowOverwrite = false;
    221 
     202void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, Ref<Messages::DownloadProxy::DecideDestinationWithSuggestedFilename::DelayedReply>&& reply)
     203{
    222204    if (!m_processPool)
    223205        return;
    224206
    225207    String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(m_suggestedFilename.isEmpty() ? filename : m_suggestedFilename, mimeType);
    226     destination = m_processPool->downloadClient().decideDestinationWithSuggestedFilename(m_processPool.get(), this, suggestedFilename, allowOverwrite);
    227 
    228     if (!destination.isNull())
    229         SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
     208    m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*m_processPool, *this, filename, [reply = WTFMove(reply)] (AllowOverwrite allowOverwrite, String destination) {
     209        SandboxExtension::Handle sandboxExtensionHandle;
     210        if (!destination.isNull())
     211            SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
     212        reply->send(destination, allowOverwrite == AllowOverwrite::Yes, sandboxExtensionHandle);
     213    });
    230214}
    231215
     
    237221        return;
    238222
    239     m_processPool->downloadClient().didCreateDestination(m_processPool.get(), this, path);
     223    m_processPool->downloadClient().didCreateDestination(*m_processPool, *this, path);
    240224}
    241225
     
    245229        return;
    246230
    247     m_processPool->downloadClient().didFinish(m_processPool.get(), this);
     231    m_processPool->downloadClient().didFinish(*m_processPool, *this);
    248232
    249233    // This can cause the DownloadProxy object to be deleted.
     
    266250    m_resumeData = createData(resumeData);
    267251
    268     m_processPool->downloadClient().didFail(m_processPool.get(), this, error);
     252    m_processPool->downloadClient().didFail(*m_processPool, *this, error);
    269253
    270254    // This can cause the DownloadProxy object to be deleted.
     
    276260    m_resumeData = createData(resumeData);
    277261
    278     m_processPool->downloadClient().didCancel(m_processPool.get(), this);
     262    m_processPool->downloadClient().didCancel(*m_processPool, *this);
    279263
    280264    // This can cause the DownloadProxy object to be deleted.
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.h

    r222468 r223730  
    2424 */
    2525
    26 #ifndef DownloadProxy_h
    27 #define DownloadProxy_h
     26#pragma once
    2827
    2928#include "APIObject.h"
    3029#include "Connection.h"
    3130#include "DownloadID.h"
     31#include "DownloadProxyMessages.h"
    3232#include "SandboxExtension.h"
    3333#include <WebCore/ResourceRequest.h>
     
    9898    void didFail(const WebCore::ResourceError&, const IPC::DataReference& resumeData);
    9999    void didCancel(const IPC::DataReference& resumeData);
    100     void willSendRequest(const WebCore::ResourceRequest& redirectRequest, const WebCore::ResourceResponse& redirectResponse);
    101 #if USE(NETWORK_SESSION)
    102 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    103     void canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace&);
    104 #endif
    105 #else
    106     void decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle);
     100    void willSendRequest(WebCore::ResourceRequest&& redirectRequest, const WebCore::ResourceResponse& redirectResponse);
     101#if !USE(NETWORK_SESSION)
     102    void decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, Ref<Messages::DownloadProxy::DecideDestinationWithSuggestedFilename::DelayedReply>&&);
    107103#endif
    108104    void decideDestinationWithSuggestedFilenameAsync(DownloadID, const String& suggestedFilename);
     
    122118
    123119} // namespace WebKit
    124 
    125 #endif // DownloadProxy_h
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.messages.in

    r221749 r223730  
    2525    DidReceiveAuthenticationChallenge(WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
    2626    WillSendRequest(WebCore::ResourceRequest redirectRequest, WebCore::ResourceResponse redirectResponse))
    27 #if USE(NETWORK_SESSION)
    28 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    29     CanAuthenticateAgainstProtectionSpace(WebCore::ProtectionSpace protectionSpace)
    30 #endif
    31 #endif
    3227    DecideDestinationWithSuggestedFilenameAsync(WebKit::DownloadID downloadID, String suggestedFilename)
    3328
    3429    DidReceiveResponse(WebCore::ResourceResponse response)
    3530    DidReceiveData(uint64_t length)
     31#if !USE(NETWORK_SESSION)
    3632    ShouldDecodeSourceDataOfMIMEType(String mimeType) -> (bool result)
    37 #if !USE(NETWORK_SESSION)
    38     DecideDestinationWithSuggestedFilename(String filename, String mimeType) -> (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
     33    DecideDestinationWithSuggestedFilename(String filename, String mimeType) -> (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle) Delayed
    3934#endif
    4035    DidCreateDestination(String path)
Note: See TracChangeset for help on using the changeset viewer.