Changeset 250292 in webkit


Ignore:
Timestamp:
Sep 24, 2019, 6:58:40 AM (6 years ago)
Author:
achristensen@apple.com
Message:

Require a WebsiteDataStore when creating or resuming downloads
https://bugs.webkit.org/show_bug.cgi?id=202081

Reviewed by Youenn Fablet.

Source/WebKit:

No change in behavior, but I'll have to move Safari to the new SPI.
This makes it so there are no cases where we guess we need to use the default session,
and it allows downloads to function correctly once there is a NetworkProcess singleton.
Removing the unused WebProcessPool& in the callbacks will allow us to eventually have
downloads only associated with a WebsiteDataStore and not a WebProcessPool.

  • UIProcess/API/APIDownloadClient.h:

(API::DownloadClient::didStart):
(API::DownloadClient::didReceiveAuthenticationChallenge):
(API::DownloadClient::didReceiveResponse):
(API::DownloadClient::didReceiveData):
(API::DownloadClient::decideDestinationWithSuggestedFilename):
(API::DownloadClient::didCreateDestination):
(API::DownloadClient::didFinish):
(API::DownloadClient::didFail):
(API::DownloadClient::didCancel):
(API::DownloadClient::processDidCrash):
(API::DownloadClient::willSendRequest):

  • UIProcess/API/C/WKContext.cpp:

(WKContextSetDownloadClient):
(WKContextDownloadURLRequest):
(WKContextResumeDownload):

  • UIProcess/API/C/WKContext.h:
  • UIProcess/API/Cocoa/WKProcessPool.mm:

(-[WKProcessPool _setDownloadDelegate:]):
(-[WKProcessPool _downloadURLRequest:originatingWebView:]):
(-[WKProcessPool _resumeDownloadFromData:path:originatingWebView:]):
(-[WKProcessPool _downloadURLRequest:websiteDataStore:originatingWebView:]):
(-[WKProcessPool _resumeDownloadFromData:websiteDataStore:path:originatingWebView:]):

  • UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
  • UIProcess/API/glib/WebKitDownloadClient.cpp:
  • UIProcess/API/glib/WebKitWebContext.cpp:

(webkitWebContextDispose):
(webkitWebContextStartDownload):

  • UIProcess/Cocoa/DownloadClient.h:
  • UIProcess/Cocoa/DownloadClient.mm:

(WebKit::DownloadClient::didStart):
(WebKit::DownloadClient::didReceiveResponse):
(WebKit::DownloadClient::didReceiveData):
(WebKit::DownloadClient::didReceiveAuthenticationChallenge):
(WebKit::DownloadClient::didCreateDestination):
(WebKit::DownloadClient::processDidCrash):
(WebKit::DownloadClient::decideDestinationWithSuggestedFilename):
(WebKit::DownloadClient::didFinish):
(WebKit::DownloadClient::didFail):
(WebKit::DownloadClient::didCancel):
(WebKit::DownloadClient::willSendRequest):

  • UIProcess/Downloads/DownloadProxy.cpp:

(WebKit::DownloadProxy::create):
(WebKit::DownloadProxy::DownloadProxy):
(WebKit::DownloadProxy::invalidate):
(WebKit::DownloadProxy::processDidClose):
(WebKit::DownloadProxy::didStart):
(WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
(WebKit::DownloadProxy::willSendRequest):
(WebKit::DownloadProxy::didReceiveResponse):
(WebKit::DownloadProxy::didReceiveData):
(WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
(WebKit::DownloadProxy::didCreateDestination):
(WebKit::DownloadProxy::didFinish):
(WebKit::DownloadProxy::didFail):
(WebKit::DownloadProxy::didCancel):

  • UIProcess/Downloads/DownloadProxy.h:
  • UIProcess/Downloads/DownloadProxyMap.cpp:

(WebKit::DownloadProxyMap::createDownloadProxy):

  • UIProcess/Downloads/DownloadProxyMap.h:
  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::createDownloadProxy):

  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::contextMenuItemSelected):

  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::WebProcessPool):
(WebKit::WebProcessPool::setDownloadClient):
(WebKit::WebProcessPool::download):
(WebKit::WebProcessPool::resumeDownload):
(WebKit::WebProcessPool::createDownloadProxy):

  • UIProcess/WebProcessPool.h:

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/DownloadProgress.mm:

(-[DownloadProgressTestRunner startDownload:expectedLength:]):

Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r250291 r250292  
     12019-09-24  Alex Christensen  <achristensen@webkit.org>
     2
     3        Require a WebsiteDataStore when creating or resuming downloads
     4        https://bugs.webkit.org/show_bug.cgi?id=202081
     5
     6        Reviewed by Youenn Fablet.
     7
     8        No change in behavior, but I'll have to move Safari to the new SPI.
     9        This makes it so there are no cases where we guess we need to use the default session,
     10        and it allows downloads to function correctly once there is a NetworkProcess singleton.
     11        Removing the unused WebProcessPool& in the callbacks will allow us to eventually have
     12        downloads only associated with a WebsiteDataStore and not a WebProcessPool.
     13
     14        * UIProcess/API/APIDownloadClient.h:
     15        (API::DownloadClient::didStart):
     16        (API::DownloadClient::didReceiveAuthenticationChallenge):
     17        (API::DownloadClient::didReceiveResponse):
     18        (API::DownloadClient::didReceiveData):
     19        (API::DownloadClient::decideDestinationWithSuggestedFilename):
     20        (API::DownloadClient::didCreateDestination):
     21        (API::DownloadClient::didFinish):
     22        (API::DownloadClient::didFail):
     23        (API::DownloadClient::didCancel):
     24        (API::DownloadClient::processDidCrash):
     25        (API::DownloadClient::willSendRequest):
     26        * UIProcess/API/C/WKContext.cpp:
     27        (WKContextSetDownloadClient):
     28        (WKContextDownloadURLRequest):
     29        (WKContextResumeDownload):
     30        * UIProcess/API/C/WKContext.h:
     31        * UIProcess/API/Cocoa/WKProcessPool.mm:
     32        (-[WKProcessPool _setDownloadDelegate:]):
     33        (-[WKProcessPool _downloadURLRequest:originatingWebView:]):
     34        (-[WKProcessPool _resumeDownloadFromData:path:originatingWebView:]):
     35        (-[WKProcessPool _downloadURLRequest:websiteDataStore:originatingWebView:]):
     36        (-[WKProcessPool _resumeDownloadFromData:websiteDataStore:path:originatingWebView:]):
     37        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
     38        * UIProcess/API/glib/WebKitDownloadClient.cpp:
     39        * UIProcess/API/glib/WebKitWebContext.cpp:
     40        (webkitWebContextDispose):
     41        (webkitWebContextStartDownload):
     42        * UIProcess/Cocoa/DownloadClient.h:
     43        * UIProcess/Cocoa/DownloadClient.mm:
     44        (WebKit::DownloadClient::didStart):
     45        (WebKit::DownloadClient::didReceiveResponse):
     46        (WebKit::DownloadClient::didReceiveData):
     47        (WebKit::DownloadClient::didReceiveAuthenticationChallenge):
     48        (WebKit::DownloadClient::didCreateDestination):
     49        (WebKit::DownloadClient::processDidCrash):
     50        (WebKit::DownloadClient::decideDestinationWithSuggestedFilename):
     51        (WebKit::DownloadClient::didFinish):
     52        (WebKit::DownloadClient::didFail):
     53        (WebKit::DownloadClient::didCancel):
     54        (WebKit::DownloadClient::willSendRequest):
     55        * UIProcess/Downloads/DownloadProxy.cpp:
     56        (WebKit::DownloadProxy::create):
     57        (WebKit::DownloadProxy::DownloadProxy):
     58        (WebKit::DownloadProxy::invalidate):
     59        (WebKit::DownloadProxy::processDidClose):
     60        (WebKit::DownloadProxy::didStart):
     61        (WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
     62        (WebKit::DownloadProxy::willSendRequest):
     63        (WebKit::DownloadProxy::didReceiveResponse):
     64        (WebKit::DownloadProxy::didReceiveData):
     65        (WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
     66        (WebKit::DownloadProxy::didCreateDestination):
     67        (WebKit::DownloadProxy::didFinish):
     68        (WebKit::DownloadProxy::didFail):
     69        (WebKit::DownloadProxy::didCancel):
     70        * UIProcess/Downloads/DownloadProxy.h:
     71        * UIProcess/Downloads/DownloadProxyMap.cpp:
     72        (WebKit::DownloadProxyMap::createDownloadProxy):
     73        * UIProcess/Downloads/DownloadProxyMap.h:
     74        * UIProcess/Network/NetworkProcessProxy.cpp:
     75        (WebKit::NetworkProcessProxy::createDownloadProxy):
     76        * UIProcess/Network/NetworkProcessProxy.h:
     77        * UIProcess/WebPageProxy.cpp:
     78        (WebKit::WebPageProxy::receivedPolicyDecision):
     79        (WebKit::WebPageProxy::contextMenuItemSelected):
     80        * UIProcess/WebProcessPool.cpp:
     81        (WebKit::WebProcessPool::WebProcessPool):
     82        (WebKit::WebProcessPool::setDownloadClient):
     83        (WebKit::WebProcessPool::download):
     84        (WebKit::WebProcessPool::resumeDownload):
     85        (WebKit::WebProcessPool::createDownloadProxy):
     86        * UIProcess/WebProcessPool.h:
     87
    1882019-09-24  Youenn Fablet  <youenn@apple.com>
    289
  • trunk/Source/WebKit/UIProcess/API/APIDownloadClient.h

    r248762 r250292  
    2626#pragma once
    2727
     28#include "AuthenticationChallengeDisposition.h"
     29#include "AuthenticationChallengeProxy.h"
     30#include "AuthenticationDecisionListener.h"
    2831#include <wtf/CompletionHandler.h>
    2932#include <wtf/text/WTFString.h>
     
    3841class AuthenticationChallengeProxy;
    3942class DownloadProxy;
    40 class WebProcessPool;
     43class WebsiteDataStore;
    4144class WebProtectionSpace;
    4245
     
    5154    virtual ~DownloadClient() { }
    5255
    53     virtual void didStart(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
    54     virtual void didReceiveAuthenticationChallenge(WebKit::WebProcessPool&, WebKit::DownloadProxy&, WebKit::AuthenticationChallengeProxy&) { }
    55     virtual void didReceiveResponse(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WebCore::ResourceResponse&) { }
    56     virtual void didReceiveData(WebKit::WebProcessPool&, WebKit::DownloadProxy&, uint64_t) { }
    57     virtual void decideDestinationWithSuggestedFilename(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&, Function<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) { completionHandler(WebKit::AllowOverwrite::No, { }); }
    58     virtual void didCreateDestination(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&) { }
    59     virtual void didFinish(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
    60     virtual void didFail(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WebCore::ResourceError&) { }
    61     virtual void didCancel(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
    62     virtual void processDidCrash(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { }
    63     virtual void willSendRequest(WebKit::WebProcessPool&, WebKit::DownloadProxy&, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&& completionHandler) { completionHandler(WTFMove(request)); }
     56    virtual void didStart(WebKit::DownloadProxy&) { }
     57    virtual void didReceiveAuthenticationChallenge(WebKit::DownloadProxy&, WebKit::AuthenticationChallengeProxy& challenge) { challenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::Cancel); }
     58    virtual void didReceiveResponse(WebKit::DownloadProxy&, const WebCore::ResourceResponse&) { }
     59    virtual void didReceiveData(WebKit::DownloadProxy&, uint64_t) { }
     60    virtual void decideDestinationWithSuggestedFilename(WebKit::DownloadProxy&, const WTF::String&, Function<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) { completionHandler(WebKit::AllowOverwrite::No, { }); }
     61    virtual void didCreateDestination(WebKit::DownloadProxy&, const WTF::String&) { }
     62    virtual void didFinish(WebKit::DownloadProxy&) { }
     63    virtual void didFail(WebKit::DownloadProxy&, const WebCore::ResourceError&) { }
     64    virtual void didCancel(WebKit::DownloadProxy&) { }
     65    virtual void processDidCrash(WebKit::DownloadProxy&) { }
     66    virtual void willSendRequest(WebKit::DownloadProxy&, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&& completionHandler) { completionHandler(WTFMove(request)); }
    6467};
    6568
  • trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp

    r250169 r250292  
    169169}
    170170
    171 void WKContextSetDownloadClient(WKContextRef contextRef, const WKContextDownloadClientBase* wkClient)
     171void WKContextSetDownloadClient(WKContextRef context, const WKContextDownloadClientBase* wkClient)
    172172{
    173173    class DownloadClient final : public API::Client<WKContextDownloadClientBase>, public API::DownloadClient {
    174174    public:
    175         explicit DownloadClient(const WKContextDownloadClientBase* client)
     175        explicit DownloadClient(const WKContextDownloadClientBase* client, WKContextRef context)
     176            : m_context(context)
    176177        {
    177178            initialize(client);
    178179        }
    179180    private:
    180         void didStart(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy) final
     181        void didStart(WebKit::DownloadProxy& downloadProxy) final
    181182        {
    182183            if (!m_client.didStart)
    183184                return;
    184 
    185             m_client.didStart(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), m_client.base.clientInfo);
    186         }
    187 
    188         void didReceiveAuthenticationChallenge(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy, WebKit::AuthenticationChallengeProxy& authenticationChallengeProxy) final
     185            m_client.didStart(m_context, WebKit::toAPI(&downloadProxy), m_client.base.clientInfo);
     186        }
     187        void didReceiveAuthenticationChallenge(WebKit::DownloadProxy& downloadProxy, WebKit::AuthenticationChallengeProxy& authenticationChallengeProxy) final
    189188        {
    190189            if (!m_client.didReceiveAuthenticationChallenge)
    191190                return;
    192 
    193             m_client.didReceiveAuthenticationChallenge(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), WebKit::toAPI(&authenticationChallengeProxy), m_client.base.clientInfo);
    194         }
    195 
    196         void didReceiveResponse(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response) final
     191            m_client.didReceiveAuthenticationChallenge(m_context, WebKit::toAPI(&downloadProxy), WebKit::toAPI(&authenticationChallengeProxy), m_client.base.clientInfo);
     192        }
     193        void didReceiveResponse(WebKit::DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response) final
    197194        {
    198195            if (!m_client.didReceiveResponse)
    199196                return;
    200 
    201             m_client.didReceiveResponse(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), WebKit::toAPI(API::URLResponse::create(response).ptr()), m_client.base.clientInfo);
    202         }
    203 
    204         void didReceiveData(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy, uint64_t length) final
     197            m_client.didReceiveResponse(m_context, WebKit::toAPI(&downloadProxy), WebKit::toAPI(API::URLResponse::create(response).ptr()), m_client.base.clientInfo);
     198        }
     199        void didReceiveData(WebKit::DownloadProxy& downloadProxy, uint64_t length) final
    205200        {
    206201            if (!m_client.didReceiveData)
    207202                return;
    208 
    209             m_client.didReceiveData(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), length, m_client.base.clientInfo);
    210         }
    211 
    212         void decideDestinationWithSuggestedFilename(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy, const String& filename, Function<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) final
     203            m_client.didReceiveData(m_context, WebKit::toAPI(&downloadProxy), length, m_client.base.clientInfo);
     204        }
     205        void decideDestinationWithSuggestedFilename(WebKit::DownloadProxy& downloadProxy, const String& filename, Function<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) final
    213206        {
    214207            if (!m_client.decideDestinationWithSuggestedFilename)
    215208                return completionHandler(WebKit::AllowOverwrite::No, { });
    216 
    217209            bool allowOverwrite = false;
    218             auto destination = adoptWK(m_client.decideDestinationWithSuggestedFilename(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), WebKit::toAPI(filename.impl()), &allowOverwrite, m_client.base.clientInfo));
     210            auto destination = adoptWK(m_client.decideDestinationWithSuggestedFilename(m_context, WebKit::toAPI(&downloadProxy), WebKit::toAPI(filename.impl()), &allowOverwrite, m_client.base.clientInfo));
    219211            completionHandler(allowOverwrite ? WebKit::AllowOverwrite::Yes : WebKit::AllowOverwrite::No, WebKit::toWTFString(destination.get()));
    220212        }
    221 
    222         void didCreateDestination(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy, const String& path) final
     213        void didCreateDestination(WebKit::DownloadProxy& downloadProxy, const String& path) final
    223214        {
    224215            if (!m_client.didCreateDestination)
    225216                return;
    226 
    227             m_client.didCreateDestination(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), WebKit::toAPI(path.impl()), m_client.base.clientInfo);
    228         }
    229 
    230         void didFinish(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy) final
     217            m_client.didCreateDestination(m_context, WebKit::toAPI(&downloadProxy), WebKit::toAPI(path.impl()), m_client.base.clientInfo);
     218        }
     219        void didFinish(WebKit::DownloadProxy& downloadProxy) final
    231220        {
    232221            if (!m_client.didFinish)
    233222                return;
    234 
    235             m_client.didFinish(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), m_client.base.clientInfo);
    236         }
    237 
    238         void didFail(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy, const WebCore::ResourceError& error) final
     223            m_client.didFinish(m_context, WebKit::toAPI(&downloadProxy), m_client.base.clientInfo);
     224        }
     225        void didFail(WebKit::DownloadProxy& downloadProxy, const WebCore::ResourceError& error) final
    239226        {
    240227            if (!m_client.didFail)
    241228                return;
    242 
    243             m_client.didFail(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), WebKit::toAPI(error), m_client.base.clientInfo);
    244         }
    245        
    246         void didCancel(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy) final
     229            m_client.didFail(m_context, WebKit::toAPI(&downloadProxy), WebKit::toAPI(error), m_client.base.clientInfo);
     230        }
     231        void didCancel(WebKit::DownloadProxy& downloadProxy) final
    247232        {
    248233            if (!m_client.didCancel)
    249234                return;
    250            
    251             m_client.didCancel(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), m_client.base.clientInfo);
    252         }
    253        
    254         void processDidCrash(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy) final
     235            m_client.didCancel(m_context, WebKit::toAPI(&downloadProxy), m_client.base.clientInfo);
     236        }
     237        void processDidCrash(WebKit::DownloadProxy& downloadProxy) final
    255238        {
    256239            if (!m_client.processDidCrash)
    257240                return;
    258            
    259             m_client.processDidCrash(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), m_client.base.clientInfo);
    260         }
    261 
    262         void willSendRequest(WebKit::WebProcessPool& processPool, WebKit::DownloadProxy& downloadProxy, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&& completionHandler) final
     241            m_client.processDidCrash(m_context, WebKit::toAPI(&downloadProxy), m_client.base.clientInfo);
     242        }
     243        void willSendRequest(WebKit::DownloadProxy& downloadProxy, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&& completionHandler) final
    263244        {
    264245            if (m_client.didReceiveServerRedirect)
    265                 m_client.didReceiveServerRedirect(WebKit::toAPI(&processPool), WebKit::toAPI(&downloadProxy), WebKit::toURLRef(request.url().string().impl()), m_client.base.clientInfo);
    266 
     246                m_client.didReceiveServerRedirect(m_context, WebKit::toAPI(&downloadProxy), WebKit::toURLRef(request.url().string().impl()), m_client.base.clientInfo);
    267247            completionHandler(WTFMove(request));
    268248        }
     249        WKContextRef m_context;
    269250    };
    270 
    271     WebKit::toImpl(contextRef)->setDownloadClient(makeUnique<DownloadClient>(wkClient));
     251    WebKit::toImpl(context)->setDownloadClient(makeUniqueRef<DownloadClient>(wkClient, context));
    272252}
    273253
     
    277257}
    278258
    279 WKDownloadRef WKContextDownloadURLRequest(WKContextRef contextRef, WKURLRequestRef requestRef)
    280 {
    281     return WebKit::toAPI(&WebKit::toImpl(contextRef)->download(0, WebKit::toImpl(requestRef)->resourceRequest()));
    282 }
    283 
    284 WKDownloadRef WKContextResumeDownload(WKContextRef contextRef, WKDataRef resumeData, WKStringRef path)
    285 {
    286     return WebKit::toAPI(&WebKit::toImpl(contextRef)->resumeDownload(nullptr, WebKit::toImpl(resumeData), WebKit::toWTFString(path)));
     259WKDownloadRef WKContextDownloadURLRequest(WKContextRef, WKURLRequestRef)
     260{
     261    return nullptr;
     262}
     263
     264WKDownloadRef WKContextResumeDownload(WKContextRef, WKDataRef, WKStringRef)
     265{
     266    return nullptr;
    287267}
    288268
  • trunk/Source/WebKit/UIProcess/API/C/WKContext.h

    r249614 r250292  
    117117WK_EXPORT void WKContextSetConnectionClient(WKContextRef context, const WKContextConnectionClientBase* client);
    118118
    119 WK_EXPORT WKDownloadRef WKContextDownloadURLRequest(WKContextRef context, WKURLRequestRef request);
    120 WK_EXPORT WKDownloadRef WKContextResumeDownload(WKContextRef context, WKDataRef resumeData, WKStringRef path);
     119WK_EXPORT WKDownloadRef WKContextDownloadURLRequest(WKContextRef context, WKURLRequestRef request) WK_C_API_DEPRECATED;
     120WK_EXPORT WKDownloadRef WKContextResumeDownload(WKContextRef context, WKDataRef resumeData, WKStringRef path) WK_C_API_DEPRECATED;
    121121
    122122WK_EXPORT void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef context, WKTypeRef userData);
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm

    r249853 r250292  
    3636#import "WKObject.h"
    3737#import "WKWebViewInternal.h"
     38#import "WKWebsiteDataStoreInternal.h"
    3839#import "WebCertificateInfo.h"
    3940#import "WebCookieManagerProxy.h"
     
    374375{
    375376    _downloadDelegate = downloadDelegate;
    376     _processPool->setDownloadClient(makeUnique<WebKit::DownloadClient>(downloadDelegate));
     377    _processPool->setDownloadClient(makeUniqueRef<WebKit::DownloadClient>(downloadDelegate));
    377378}
    378379
     
    616617- (_WKDownload *)_downloadURLRequest:(NSURLRequest *)request originatingWebView:(WKWebView *)webView
    617618{
    618     return (_WKDownload *)_processPool->download([webView _page], request).wrapper();
     619    return nil;
    619620}
    620621
    621622- (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData path:(NSString *)path originatingWebView:(WKWebView *)webView
    622623{
    623     return wrapper(_processPool->resumeDownload([webView _page], API::Data::createWithoutCopying(resumeData).ptr(), path));
     624    return nil;
     625}
     626
     627- (_WKDownload *)_downloadURLRequest:(NSURLRequest *)request websiteDataStore:(WKWebsiteDataStore *)dataStore originatingWebView:(WKWebView *)webView
     628{
     629    return wrapper(_processPool->download(*dataStore->_websiteDataStore, [webView _page], request));
     630}
     631
     632- (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData websiteDataStore:(WKWebsiteDataStore *)dataStore  path:(NSString *)path originatingWebView:(WKWebView *)webView
     633{
     634    return wrapper(_processPool->resumeDownload(*dataStore->_websiteDataStore, [webView _page], API::Data::createWithoutCopying(resumeData).get(), path));
    624635}
    625636
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h

    r249684 r250292  
    2828
    2929@class WKWebView;
     30@class WKWebsiteDataStore;
    3031@class _WKAutomationSession;
    3132@class _WKDownload;
     
    8283- (void)_registerURLSchemeAsCanDisplayOnlyIfCanRequest:(NSString *)scheme WK_API_AVAILABLE(macos(10.14), ios(12.0));
    8384
    84 - (_WKDownload *)_downloadURLRequest:(NSURLRequest *)request originatingWebView:(WKWebView *)webView WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
    85 - (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData path:(NSString *)path originatingWebView:(WKWebView *)webView WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
     85- (_WKDownload *)_downloadURLRequest:(NSURLRequest *)request originatingWebView:(WKWebView *)webView WK_API_DEPRECATED_WITH_REPLACEMENT("_downloadURLRequest:websiteDataStore:originatingWebView:", macos(10.14.4, WK_MAC_TBA), ios(12.2, WK_IOS_TBA));
     86- (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData path:(NSString *)path originatingWebView:(WKWebView *)webView WK_API_DEPRECATED_WITH_REPLACEMENT("_resumeDownloadFromData:websiteDataStore:path:originatingWebView:", macos(10.14.4, WK_MAC_TBA), ios(12.2, WK_IOS_TBA));
     87
     88- (_WKDownload *)_downloadURLRequest:(NSURLRequest *)request websiteDataStore:(WKWebsiteDataStore *)dataStore originatingWebView:(WKWebView *)webView WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
     89- (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData websiteDataStore:(WKWebsiteDataStore *)dataStore  path:(NSString *)path originatingWebView:(WKWebView *)webView WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
    8690
    8791// Test only. Should be called only while no web content processes are running.
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp

    r248846 r250292  
    2626#include "WebKitWebContextPrivate.h"
    2727#include "WebKitWebViewPrivate.h"
    28 #include "WebProcessPool.h"
     28#include "WebsiteDataStore.h"
    2929#include <wtf/glib/GRefPtr.h>
    3030#include <wtf/text/CString.h>
     
    4141
    4242private:
    43     void didStart(WebProcessPool&, DownloadProxy& downloadProxy) override
     43    void didStart(DownloadProxy& downloadProxy) override
    4444    {
    4545        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    4848    }
    4949
    50     void didReceiveAuthenticationChallenge(WebProcessPool&, DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallenge) override
     50    void didReceiveAuthenticationChallenge(DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallenge) override
    5151    {
    5252        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    5959    }
    6060
    61     void didReceiveResponse(WebProcessPool&, DownloadProxy& downloadProxy, const ResourceResponse& resourceResponse) override
     61    void didReceiveResponse(DownloadProxy& downloadProxy, const ResourceResponse& resourceResponse) override
    6262    {
    6363        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    6969    }
    7070
    71     void didReceiveData(WebProcessPool&, DownloadProxy& downloadProxy, uint64_t length) override
     71    void didReceiveData(DownloadProxy& downloadProxy, uint64_t length) override
    7272    {
    7373        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    7575    }
    7676
    77     void decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler) override
     77    void decideDestinationWithSuggestedFilename(DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler) override
    7878    {
    7979        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    8383    }
    8484
    85     void didCreateDestination(WebProcessPool&, DownloadProxy& downloadProxy, const String& path) override
     85    void didCreateDestination(DownloadProxy& downloadProxy, const String& path) override
    8686    {
    8787        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    8989    }
    9090
    91     void didFail(WebProcessPool&, DownloadProxy& downloadProxy, const ResourceError& error) override
     91    void didFail(DownloadProxy& downloadProxy, const ResourceError& error) override
    9292    {
    9393        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    100100    }
    101101
    102     void didCancel(WebProcessPool&, DownloadProxy& downloadProxy) override
     102    void didCancel(DownloadProxy& downloadProxy) override
    103103    {
    104104        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    107107    }
    108108
    109     void didFinish(WebProcessPool&, DownloadProxy& downloadProxy) override
     109    void didFinish(DownloadProxy& downloadProxy) override
    110110    {
    111111        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    119119void attachDownloadClientToContext(WebKitWebContext* webContext)
    120120{
    121     webkitWebContextGetProcessPool(webContext).setDownloadClient(makeUnique<DownloadClient>(webContext));
     121    webkitWebContextGetProcessPool(webContext).setDownloadClient(makeUniqueRef<DownloadClient>(webContext));
    122122}
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp

    r250169 r250292  
    363363        priv->clientsDetached = true;
    364364        priv->processPool->setInjectedBundleClient(nullptr);
    365         priv->processPool->setDownloadClient(nullptr);
     365        priv->processPool->setDownloadClient(makeUniqueRef<API::DownloadClient>());
    366366        priv->processPool->setLegacyCustomProtocolManagerClient(nullptr);
    367367    }
     
    16591659{
    16601660    WebCore::ResourceRequest request(String::fromUTF8(uri));
    1661     return webkitWebContextGetOrCreateDownload(&context->priv->processPool->download(initiatingPage, request));
     1661    return webkitWebContextGetOrCreateDownload(&context->priv->processPool->download(WebKit::WebsiteDataStore::defaultDataStore().get(), initiatingPage, request));
    16621662}
    16631663
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h

    r242339 r250292  
    4848private:
    4949    // From API::DownloadClient
    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&, CompletionHandler<void(WebCore::ResourceRequest&&)>&&) final;
    58     void didReceiveAuthenticationChallenge(WebProcessPool&, DownloadProxy&, AuthenticationChallengeProxy&) final;
    59     void didCreateDestination(WebProcessPool&, DownloadProxy&, const String&) final;
    60     void processDidCrash(WebProcessPool&, DownloadProxy&) final;
     50    void didStart(DownloadProxy&) final;
     51    void didReceiveResponse(DownloadProxy&, const WebCore::ResourceResponse&) final;
     52    void didReceiveData(DownloadProxy&, uint64_t length) final;
     53    void decideDestinationWithSuggestedFilename(DownloadProxy&, const String& suggestedFilename, Function<void(AllowOverwrite, String)>&&) final;
     54    void didFinish(DownloadProxy&) final;
     55    void didFail(DownloadProxy&, const WebCore::ResourceError&) final;
     56    void didCancel(DownloadProxy&) final;
     57    void willSendRequest(DownloadProxy&, WebCore::ResourceRequest&&, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&&) final;
     58    void didReceiveAuthenticationChallenge(DownloadProxy&, AuthenticationChallengeProxy&) final;
     59    void didCreateDestination(DownloadProxy&, const String&) final;
     60    void processDidCrash(DownloadProxy&) final;
    6161
    6262#if USE(SYSTEM_PREVIEW)
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

    r249855 r250292  
    6666}
    6767
    68 void DownloadClient::didStart(WebProcessPool&, DownloadProxy& downloadProxy)
     68void DownloadClient::didStart(DownloadProxy& downloadProxy)
    6969{
    7070#if USE(SYSTEM_PREVIEW)
     
    8383}
    8484
    85 void DownloadClient::didReceiveResponse(WebProcessPool&, DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response)
     85void DownloadClient::didReceiveResponse(DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response)
    8686{
    8787#if USE(SYSTEM_PREVIEW)
     
    9999}
    100100
    101 void DownloadClient::didReceiveData(WebProcessPool&, DownloadProxy& downloadProxy, uint64_t length)
     101void DownloadClient::didReceiveData(DownloadProxy& downloadProxy, uint64_t length)
    102102{
    103103#if USE(SYSTEM_PREVIEW)
     
    114114}
    115115
    116 void DownloadClient::didReceiveAuthenticationChallenge(WebProcessPool&, DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallenge)
     116void DownloadClient::didReceiveAuthenticationChallenge(DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallenge)
    117117{
    118118    // FIXME: System Preview needs code here.
     
    148148}
    149149
    150 void DownloadClient::didCreateDestination(WebProcessPool&, DownloadProxy& downloadProxy, const String& destination)
     150void DownloadClient::didCreateDestination(DownloadProxy& downloadProxy, const String& destination)
    151151{
    152152#if USE(SYSTEM_PREVIEW)
     
    161161}
    162162
    163 void DownloadClient::processDidCrash(WebProcessPool&, DownloadProxy& downloadProxy)
     163void DownloadClient::processDidCrash(DownloadProxy& downloadProxy)
    164164{
    165165#if USE(SYSTEM_PREVIEW)
     
    176176}
    177177
    178 void DownloadClient::decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler)
     178void DownloadClient::decideDestinationWithSuggestedFilename(DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler)
    179179{
    180180#if USE(SYSTEM_PREVIEW)
     
    206206}
    207207
    208 void DownloadClient::didFinish(WebProcessPool&, DownloadProxy& downloadProxy)
     208void DownloadClient::didFinish(DownloadProxy& downloadProxy)
    209209{
    210210#if USE(SYSTEM_PREVIEW)
     
    225225}
    226226
    227 void DownloadClient::didFail(WebProcessPool&, DownloadProxy& downloadProxy, const WebCore::ResourceError& error)
     227void DownloadClient::didFail(DownloadProxy& downloadProxy, const WebCore::ResourceError& error)
    228228{
    229229#if USE(SYSTEM_PREVIEW)
     
    240240}
    241241
    242 void DownloadClient::didCancel(WebProcessPool&, DownloadProxy& downloadProxy)
     242void DownloadClient::didCancel(DownloadProxy& downloadProxy)
    243243{
    244244#if USE(SYSTEM_PREVIEW)
     
    255255}
    256256
    257 void DownloadClient::willSendRequest(WebProcessPool&, DownloadProxy& downloadProxy, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&& completionHandler)
     257void DownloadClient::willSendRequest(DownloadProxy& downloadProxy, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&& completionHandler)
    258258{
    259259    if (m_delegateMethods.downloadDidReceiveServerRedirectToURL)
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp

    r247705 r250292  
    5252}
    5353   
    54 Ref<DownloadProxy> DownloadProxy::create(DownloadProxyMap& downloadProxyMap, WebProcessPool& processPool, const ResourceRequest& resourceRequest)
    55 {
    56     return adoptRef(*new DownloadProxy(downloadProxyMap, processPool, resourceRequest));
    57 }
    58 
    59 DownloadProxy::DownloadProxy(DownloadProxyMap& downloadProxyMap, WebProcessPool& processPool, const ResourceRequest& resourceRequest)
     54Ref<DownloadProxy> DownloadProxy::create(DownloadProxyMap& downloadProxyMap, WebsiteDataStore& dataStore, WebProcessPool& processPool, const ResourceRequest& resourceRequest)
     55{
     56    return adoptRef(*new DownloadProxy(downloadProxyMap, dataStore, processPool, resourceRequest));
     57}
     58
     59DownloadProxy::DownloadProxy(DownloadProxyMap& downloadProxyMap, WebsiteDataStore& dataStore, WebProcessPool& processPool, const ResourceRequest& resourceRequest)
    6060    : m_downloadProxyMap(downloadProxyMap)
     61    , m_dataStore(&dataStore)
    6162    , m_processPool(&processPool)
    6263    , m_downloadID(generateDownloadID())
     
    8384    ASSERT(m_processPool);
    8485    m_processPool = nullptr;
     86    ASSERT(m_dataStore);
     87    m_dataStore = nullptr;
    8588}
    8689
     
    9093        return;
    9194
    92     m_processPool->downloadClient().processDidCrash(*m_processPool, *this);
     95    m_processPool->downloadClient().processDidCrash(*this);
    9396}
    9497
     
    129132        return;
    130133
    131     m_processPool->downloadClient().didStart(*m_processPool, *this);
     134    m_processPool->downloadClient().didStart(*this);
    132135}
    133136
     
    139142    auto authenticationChallengeProxy = AuthenticationChallengeProxy::create(WTFMove(authenticationChallenge), challengeID, makeRef(*m_processPool->networkingProcessConnection()), nullptr);
    140143
    141     m_processPool->downloadClient().didReceiveAuthenticationChallenge(*m_processPool, *this, authenticationChallengeProxy.get());
     144    m_processPool->downloadClient().didReceiveAuthenticationChallenge(*this, authenticationChallengeProxy.get());
    142145}
    143146
     
    147150        return;
    148151
    149     m_processPool->downloadClient().willSendRequest(*m_processPool, *this, WTFMove(proposedRequest), redirectResponse, [this, protectedThis = makeRef(*this)](ResourceRequest&& newRequest) {
     152    m_processPool->downloadClient().willSendRequest(*this, WTFMove(proposedRequest), redirectResponse, [this, protectedThis = makeRef(*this)](ResourceRequest&& newRequest) {
    150153        m_redirectChain.append(newRequest.url());
    151154
     
    166169        return;
    167170
    168     m_processPool->downloadClient().didReceiveResponse(*m_processPool, *this, response);
     171    m_processPool->downloadClient().didReceiveResponse(*this, response);
    169172}
    170173
     
    174177        return;
    175178
    176     m_processPool->downloadClient().didReceiveData(*m_processPool, *this, length);
     179    m_processPool->downloadClient().didReceiveData(*this, length);
    177180}
    178181
     
    182185        return;
    183186   
    184     m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*m_processPool, *this, suggestedFilename, [this, protectedThis = makeRef(*this), downloadID = downloadID] (AllowOverwrite allowOverwrite, String destination) {
     187    m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*this, suggestedFilename, [this, protectedThis = makeRef(*this), downloadID = downloadID] (AllowOverwrite allowOverwrite, String destination) {
    185188        SandboxExtension::Handle sandboxExtensionHandle;
    186189        if (!destination.isNull())
     
    200203        return;
    201204
    202     m_processPool->downloadClient().didCreateDestination(*m_processPool, *this, path);
     205    m_processPool->downloadClient().didCreateDestination(*this, path);
    203206}
    204207
     
    208211        return;
    209212
    210     m_processPool->downloadClient().didFinish(*m_processPool, *this);
     213    m_processPool->downloadClient().didFinish(*this);
    211214
    212215    // This can cause the DownloadProxy object to be deleted.
     
    229232    m_resumeData = createData(resumeData);
    230233
    231     m_processPool->downloadClient().didFail(*m_processPool, *this, error);
     234    m_processPool->downloadClient().didFail(*this, error);
    232235
    233236    // This can cause the DownloadProxy object to be deleted.
     
    239242    m_resumeData = createData(resumeData);
    240243
    241     m_processPool->downloadClient().didCancel(*m_processPool, *this);
     244    m_processPool->downloadClient().didCancel(*this);
    242245
    243246    // This can cause the DownloadProxy object to be deleted.
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.h

    r249855 r250292  
    5454class WebPageProxy;
    5555class WebProcessPool;
     56class WebsiteDataStore;
    5657
    5758class DownloadProxy : public API::ObjectImpl<API::Object::Type::Download>, public IPC::MessageReceiver {
    5859public:
    59     static Ref<DownloadProxy> create(DownloadProxyMap&, WebProcessPool&, const WebCore::ResourceRequest&);
     60    static Ref<DownloadProxy> create(DownloadProxyMap&, WebsiteDataStore&, WebProcessPool&, const WebCore::ResourceRequest&);
    6061    ~DownloadProxy();
    6162
     
    100101
    101102private:
    102     explicit DownloadProxy(DownloadProxyMap&, WebProcessPool&, const WebCore::ResourceRequest&);
     103    explicit DownloadProxy(DownloadProxyMap&, WebsiteDataStore&, WebProcessPool&, const WebCore::ResourceRequest&);
    103104
    104105    // IPC::MessageReceiver
     
    119120
    120121    DownloadProxyMap& m_downloadProxyMap;
     122    RefPtr<WebsiteDataStore> m_dataStore;
    121123    RefPtr<WebProcessPool> m_processPool;
    122124    DownloadID m_downloadID;
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp

    r249479 r250292  
    8181}
    8282
    83 DownloadProxy& DownloadProxyMap::createDownloadProxy(WebProcessPool& processPool, const WebCore::ResourceRequest& resourceRequest)
     83DownloadProxy& DownloadProxyMap::createDownloadProxy(WebsiteDataStore& dataStore, WebProcessPool& processPool, const WebCore::ResourceRequest& resourceRequest)
    8484{
    85     auto downloadProxy = DownloadProxy::create(*this, processPool, resourceRequest);
     85    auto downloadProxy = DownloadProxy::create(*this, dataStore, processPool, resourceRequest);
    8686    m_downloads.set(downloadProxy->downloadID(), downloadProxy.copyRef());
    8787
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxyMap.h

    r245480 r250292  
    4646class ProcessAssertion;
    4747class WebProcessPool;
     48class WebsiteDataStore;
    4849
    4950class DownloadProxyMap : public CanMakeWeakPtr<DownloadProxyMap> {
     
    5556    ~DownloadProxyMap();
    5657
    57     DownloadProxy& createDownloadProxy(WebProcessPool&, const WebCore::ResourceRequest&);
     58    DownloadProxy& createDownloadProxy(WebsiteDataStore&, WebProcessPool&, const WebCore::ResourceRequest&);
    5859    void downloadFinished(DownloadProxy&);
    5960
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r250169 r250292  
    2929#include "APIContentRuleList.h"
    3030#include "AuthenticationChallengeProxy.h"
     31#include "DownloadProxyMap.h"
    3132#include "DownloadProxyMessages.h"
    3233#if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER)
     
    177178}
    178179
    179 DownloadProxy& NetworkProcessProxy::createDownloadProxy(const ResourceRequest& resourceRequest)
     180DownloadProxy& NetworkProcessProxy::createDownloadProxy(WebsiteDataStore& dataStore, const ResourceRequest& resourceRequest)
    180181{
    181182    if (!m_downloadProxyMap)
    182183        m_downloadProxyMap = makeUnique<DownloadProxyMap>(*this);
    183184
    184     return m_downloadProxyMap->createDownloadProxy(m_processPool, resourceRequest);
     185    return m_downloadProxyMap->createDownloadProxy(dataStore, m_processPool, resourceRequest);
    185186}
    186187
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r250169 r250292  
    9090    void getNetworkProcessConnection(WebProcessProxy&, Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply&&);
    9191
    92     DownloadProxy& createDownloadProxy(const WebCore::ResourceRequest&);
     92    DownloadProxy& createDownloadProxy(WebsiteDataStore&, const WebCore::ResourceRequest&);
    9393
    9494    void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, CompletionHandler<void(WebsiteData)>&&);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r250169 r250292  
    29542954    if (action == PolicyAction::Download) {
    29552955        // Create a download proxy.
    2956         auto& download = m_process->processPool().createDownloadProxy(m_decidePolicyForResponseRequest, this);
     2956        auto& download = m_process->processPool().createDownloadProxy(m_websiteDataStore, m_decidePolicyForResponseRequest, this);
    29572957        if (navigation) {
    29582958            download.setWasUserInitiated(navigation->wasUserInitiated());
     
    61296129#endif
    61306130    if (item.action() == ContextMenuItemTagDownloadImageToDisk) {
    6131         m_process->processPool().download(this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteImageURL));
     6131        m_process->processPool().download(m_websiteDataStore, this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteImageURL));
    61326132        return;   
    61336133    }
    61346134    if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
    61356135        auto& hitTestResult = m_activeContextMenuContextData.webHitTestResultData();
    6136         m_process->processPool().download(this, URL(URL(), hitTestResult.absoluteLinkURL), hitTestResult.linkSuggestedFilename);
     6136        m_process->processPool().download(m_websiteDataStore, this, URL(URL(), hitTestResult.absoluteLinkURL), hitTestResult.linkSuggestedFilename);
    61376137        return;
    61386138    }
    61396139    if (item.action() == ContextMenuItemTagDownloadMediaToDisk) {
    6140         m_process->processPool().download(this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteMediaURL));
     6140        m_process->processPool().download(m_websiteDataStore, this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteMediaURL));
    61416141        return;
    61426142    }
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r250254 r250292  
    217217    , m_injectedBundleClient(makeUnique<API::InjectedBundleClient>())
    218218    , m_automationClient(makeUnique<API::AutomationClient>())
    219     , m_downloadClient(makeUnique<API::DownloadClient>())
     219    , m_downloadClient(makeUniqueRef<API::DownloadClient>())
    220220    , m_historyClient(makeUnique<API::LegacyContextHistoryClient>())
    221221    , m_customProtocolManagerClient(makeUnique<API::CustomProtocolManagerClient>())
     
    361361}
    362362
    363 void WebProcessPool::setDownloadClient(std::unique_ptr<API::DownloadClient>&& downloadClient)
    364 {
    365     if (!downloadClient)
    366         m_downloadClient = makeUnique<API::DownloadClient>();
    367     else
    368         m_downloadClient = WTFMove(downloadClient);
     363void WebProcessPool::setDownloadClient(UniqueRef<API::DownloadClient>&& downloadClient)
     364{
     365    m_downloadClient = WTFMove(downloadClient);
    369366}
    370367
     
    13281325}
    13291326
    1330 DownloadProxy& WebProcessPool::download(WebPageProxy* initiatingPage, const ResourceRequest& request, const String& suggestedFilename)
    1331 {
    1332     auto& downloadProxy = createDownloadProxy(request, initiatingPage);
    1333     PAL::SessionID sessionID = initiatingPage ? initiatingPage->sessionID() : PAL::SessionID::defaultSessionID();
     1327DownloadProxy& WebProcessPool::download(WebsiteDataStore& dataStore, WebPageProxy* initiatingPage, const ResourceRequest& request, const String& suggestedFilename)
     1328{
     1329    auto& downloadProxy = createDownloadProxy(dataStore, request, initiatingPage);
     1330    PAL::SessionID sessionID = dataStore.sessionID();
    13341331
    13351332    if (initiatingPage)
     
    13601357}
    13611358
    1362 DownloadProxy& WebProcessPool::resumeDownload(WebPageProxy* initiatingPage, const API::Data* resumeData, const String& path)
    1363 {
    1364     auto& downloadProxy = createDownloadProxy(ResourceRequest(), initiatingPage);
    1365     PAL::SessionID sessionID = initiatingPage ? initiatingPage->sessionID() : PAL::SessionID::defaultSessionID();
     1359DownloadProxy& WebProcessPool::resumeDownload(WebsiteDataStore& dataStore, WebPageProxy* initiatingPage, const API::Data& resumeData, const String& path)
     1360{
     1361    auto& downloadProxy = createDownloadProxy(dataStore, ResourceRequest(), initiatingPage);
     1362    PAL::SessionID sessionID = dataStore.sessionID();
    13661363
    13671364    SandboxExtension::Handle sandboxExtensionHandle;
     
    13701367
    13711368    if (networkProcess()) {
    1372         networkProcess()->send(Messages::NetworkProcess::ResumeDownload(sessionID, downloadProxy.downloadID(), resumeData->dataReference(), path, sandboxExtensionHandle), 0);
     1369        networkProcess()->send(Messages::NetworkProcess::ResumeDownload(sessionID, downloadProxy.downloadID(), resumeData.dataReference(), path, sandboxExtensionHandle), 0);
    13731370        return downloadProxy;
    13741371    }
     
    16211618}
    16221619
    1623 DownloadProxy& WebProcessPool::createDownloadProxy(const ResourceRequest& request, WebPageProxy* originatingPage)
    1624 {
    1625     auto& downloadProxy = ensureNetworkProcess().createDownloadProxy(request);
     1620DownloadProxy& WebProcessPool::createDownloadProxy(WebsiteDataStore& dataStore, const ResourceRequest& request, WebPageProxy* originatingPage)
     1621{
     1622    auto& downloadProxy = ensureNetworkProcess().createDownloadProxy(dataStore, request);
    16261623    downloadProxy.setOriginatingPage(originatingPage);
    16271624    return downloadProxy;
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r250169 r250292  
    2929#include "APIObject.h"
    3030#include "APIProcessPoolConfiguration.h"
    31 #include "DownloadProxyMap.h"
    3231#include "GenericCallback.h"
    3332#include "HiddenPageThrottlingAutoIncreasesCounter.h"
     
    9796namespace WebKit {
    9897
    99 class DownloadProxy;
    10098class HighPerformanceGraphicsUsageSampler;
    10199class UIGamepad;
     
    172170    void initializeConnectionClient(const WKContextConnectionClientBase*);
    173171    void setHistoryClient(std::unique_ptr<API::LegacyContextHistoryClient>&&);
    174     void setDownloadClient(std::unique_ptr<API::DownloadClient>&&);
     172    void setDownloadClient(UniqueRef<API::DownloadClient>&&);
    175173    void setAutomationClient(std::unique_ptr<API::AutomationClient>&&);
    176174    void setLegacyCustomProtocolManagerClient(std::unique_ptr<API::CustomProtocolManagerClient>&&);
     
    220218#endif
    221219
    222     DownloadProxy& download(WebPageProxy* initiatingPage, const WebCore::ResourceRequest&, const String& suggestedFilename = { });
    223     DownloadProxy& resumeDownload(WebPageProxy* initiatingPage, const API::Data* resumeData, const String& path);
     220    DownloadProxy& download(WebsiteDataStore&, WebPageProxy* initiatingPage, const WebCore::ResourceRequest&, const String& suggestedFilename = { });
     221    DownloadProxy& resumeDownload(WebsiteDataStore&, WebPageProxy* initiatingPage, const API::Data& resumeData, const String& path);
    224222
    225223    void setInjectedBundleInitializationUserData(RefPtr<API::Object>&& userData) { m_injectedBundleInitializationUserData = WTFMove(userData); }
     
    295293   
    296294    // Downloads.
    297     DownloadProxy& createDownloadProxy(const WebCore::ResourceRequest&, WebPageProxy* originatingPage);
    298     API::DownloadClient& downloadClient() { return *m_downloadClient; }
     295    DownloadProxy& createDownloadProxy(WebsiteDataStore&, const WebCore::ResourceRequest&, WebPageProxy* originatingPage);
     296    API::DownloadClient& downloadClient() { return m_downloadClient.get(); }
    299297
    300298    API::LegacyContextHistoryClient& historyClient() { return *m_historyClient; }
     
    639637    WebContextConnectionClient m_connectionClient;
    640638    std::unique_ptr<API::AutomationClient> m_automationClient;
    641     std::unique_ptr<API::DownloadClient> m_downloadClient;
     639    UniqueRef<API::DownloadClient> m_downloadClient;
    642640    std::unique_ptr<API::LegacyContextHistoryClient> m_historyClient;
    643641    std::unique_ptr<API::CustomProtocolManagerClient> m_customProtocolManagerClient;
  • trunk/Tools/ChangeLog

    r250286 r250292  
     12019-09-24  Alex Christensen  <achristensen@webkit.org>
     2
     3        Require a WebsiteDataStore when creating or resuming downloads
     4        https://bugs.webkit.org/show_bug.cgi?id=202081
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * TestWebKitAPI/Tests/WebKitCocoa/DownloadProgress.mm:
     9        (-[DownloadProgressTestRunner startDownload:expectedLength:]):
     10
    1112019-09-23  Zan Dobersek  <zdobersek@igalia.com>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DownloadProgress.mm

    r242339 r250292  
    249249        break;
    250250    case DownloadStartType::StartInProcessPool:
    251         [m_webView.get().configuration.processPool _downloadURLRequest:request.get() originatingWebView:nullptr];
     251        [m_webView.get().configuration.processPool _downloadURLRequest:request.get() websiteDataStore:[WKWebsiteDataStore defaultDataStore] originatingWebView:nullptr];
    252252        break;
    253253    }
Note: See TracChangeset for help on using the changeset viewer.