Changeset 268269 in webkit


Ignore:
Timestamp:
Oct 9, 2020, 11:03:20 AM (5 years ago)
Author:
achristensen@apple.com
Message:

Merge DownloadProxy::DidReceiveResponse and DownloadProxy::DecideDestinationWithSuggestedFilename into one message
https://bugs.webkit.org/show_bug.cgi?id=217519

Reviewed by Youenn Fablet.

No change in behavior. The current API has them as separate callbacks so we can have them as separate messages,
but future API probably won't, so let's merge them.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::findPendingDownloadLocation):

  • UIProcess/API/APIDownloadClient.h:

(API::DownloadClient::didReceiveAuthenticationChallenge):
(API::DownloadClient::decideDestinationWithSuggestedFilename):
(API::DownloadClient::didReceiveResponse): Deleted.

  • UIProcess/API/C/WKContext.cpp:

(WKContextSetDownloadClient):

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

(WebKit::LegacyDownloadClient::decideDestinationWithSuggestedFilename):

  • UIProcess/Downloads/DownloadProxy.cpp:

(WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
(WebKit::DownloadProxy::didReceiveResponse): Deleted.

  • UIProcess/Downloads/DownloadProxy.h:
  • UIProcess/Downloads/DownloadProxy.messages.in:
Location:
trunk/Source/WebKit
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r268268 r268269  
     12020-10-09  Alex Christensen  <achristensen@webkit.org>
     2
     3        Merge DownloadProxy::DidReceiveResponse and DownloadProxy::DecideDestinationWithSuggestedFilename into one message
     4        https://bugs.webkit.org/show_bug.cgi?id=217519
     5
     6        Reviewed by Youenn Fablet.
     7
     8        No change in behavior.  The current API has them as separate callbacks so we can have them as separate messages,
     9        but future API probably won't, so let's merge them.
     10
     11        * NetworkProcess/NetworkProcess.cpp:
     12        (WebKit::NetworkProcess::findPendingDownloadLocation):
     13        * UIProcess/API/APIDownloadClient.h:
     14        (API::DownloadClient::didReceiveAuthenticationChallenge):
     15        (API::DownloadClient::decideDestinationWithSuggestedFilename):
     16        (API::DownloadClient::didReceiveResponse): Deleted.
     17        * UIProcess/API/C/WKContext.cpp:
     18        (WKContextSetDownloadClient):
     19        * UIProcess/Cocoa/LegacyDownloadClient.h:
     20        * UIProcess/Cocoa/LegacyDownloadClient.mm:
     21        (WebKit::LegacyDownloadClient::decideDestinationWithSuggestedFilename):
     22        * UIProcess/Downloads/DownloadProxy.cpp:
     23        (WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
     24        (WebKit::DownloadProxy::didReceiveResponse): Deleted.
     25        * UIProcess/Downloads/DownloadProxy.h:
     26        * UIProcess/Downloads/DownloadProxy.messages.in:
     27
    1282020-10-09  Kate Cheney  <katherine_cheney@apple.com>
    229
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r268261 r268269  
    20922092{
    20932093    uint64_t destinationID = networkDataTask.pendingDownloadID().toUInt64();
    2094     downloadProxyConnection()->send(Messages::DownloadProxy::DidReceiveResponse(response), destinationID);
    20952094
    20962095    // As per https://html.spec.whatwg.org/#as-a-download (step 2), the filename from the Content-Disposition header
     
    20992098    suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(suggestedFilename, response.mimeType());
    21002099
    2101     downloadProxyConnection()->sendWithAsyncReply(Messages::DownloadProxy::DecideDestinationWithSuggestedFilename(suggestedFilename), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler), networkDataTask = makeRef(networkDataTask)] (String&& destination, SandboxExtension::Handle&& sandboxExtensionHandle, AllowOverwrite allowOverwrite) mutable {
     2100    downloadProxyConnection()->sendWithAsyncReply(Messages::DownloadProxy::DecideDestinationWithSuggestedFilename(response, suggestedFilename), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler), networkDataTask = makeRef(networkDataTask)] (String&& destination, SandboxExtension::Handle&& sandboxExtensionHandle, AllowOverwrite allowOverwrite) mutable {
    21022101        auto downloadID = networkDataTask->pendingDownloadID();
    21032102        if (destination.isEmpty())
  • trunk/Source/WebKit/UIProcess/API/APIDownloadClient.h

    r268065 r268269  
    5757    virtual void didStart(WebKit::DownloadProxy&) { }
    5858    virtual void didReceiveAuthenticationChallenge(WebKit::DownloadProxy&, WebKit::AuthenticationChallengeProxy& challenge) { challenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::Cancel); }
    59     virtual void didReceiveResponse(WebKit::DownloadProxy&, const WebCore::ResourceResponse&) { }
    6059    virtual void didReceiveData(WebKit::DownloadProxy&, uint64_t, uint64_t, uint64_t) { }
    61     virtual void decideDestinationWithSuggestedFilename(WebKit::DownloadProxy&, const WTF::String&, Function<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) { completionHandler(WebKit::AllowOverwrite::No, { }); }
     60    virtual void decideDestinationWithSuggestedFilename(WebKit::DownloadProxy&, const WebCore::ResourceResponse&, const WTF::String&, CompletionHandler<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) { completionHandler(WebKit::AllowOverwrite::No, { }); }
    6261    virtual void didCreateDestination(WebKit::DownloadProxy&, const WTF::String&) { }
    6362    virtual void didFinish(WebKit::DownloadProxy&) { }
  • trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp

    r268065 r268269  
    191191            m_client.didReceiveAuthenticationChallenge(m_context, WebKit::toAPI(&downloadProxy), WebKit::toAPI(&authenticationChallengeProxy), m_client.base.clientInfo);
    192192        }
    193         void didReceiveResponse(WebKit::DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response) final
     193        void didReceiveResponse(WebKit::DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response)
    194194        {
    195195            if (!m_client.didReceiveResponse)
     
    203203            m_client.didReceiveData(m_context, WebKit::toAPI(&downloadProxy), length, m_client.base.clientInfo);
    204204        }
    205         void decideDestinationWithSuggestedFilename(WebKit::DownloadProxy& downloadProxy, const String& filename, Function<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) final
    206         {
     205        void decideDestinationWithSuggestedFilename(WebKit::DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response, const String& filename, CompletionHandler<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) final
     206        {
     207            didReceiveResponse(downloadProxy, response);
    207208            if (!m_client.decideDestinationWithSuggestedFilename)
    208209                return completionHandler(WebKit::AllowOverwrite::No, { });
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp

    r268065 r268269  
    7171    }
    7272
    73     void didReceiveResponse(DownloadProxy& downloadProxy, const ResourceResponse& resourceResponse) override
     73    void didReceiveResponse(DownloadProxy& downloadProxy, const ResourceResponse& resourceResponse)
    7474    {
    7575        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
     
    8787    }
    8888
    89     void decideDestinationWithSuggestedFilename(DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler) override
     89    void decideDestinationWithSuggestedFilename(DownloadProxy& downloadProxy, const ResourceResponse& resourceResponse, const String& filename, CompletionHandler<void(AllowOverwrite, String)>&& completionHandler) override
    9090    {
     91        didReceiveResponse(downloadProxy, resourceResponse);
    9192        GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy);
    9293        bool allowOverwrite = false;
  • trunk/Source/WebKit/UIProcess/Cocoa/LegacyDownloadClient.h

    r268065 r268269  
    4848    // From API::DownloadClient
    4949    void didStart(DownloadProxy&) final;
    50     void didReceiveResponse(DownloadProxy&, const WebCore::ResourceResponse&) final;
     50    void didReceiveResponse(DownloadProxy&, const WebCore::ResourceResponse&);
    5151    void didReceiveData(DownloadProxy&, uint64_t, uint64_t, uint64_t) final;
    52     void decideDestinationWithSuggestedFilename(DownloadProxy&, const String& suggestedFilename, Function<void(AllowOverwrite, String)>&&) final;
     52    void decideDestinationWithSuggestedFilename(DownloadProxy&, const WebCore::ResourceResponse&, const String& suggestedFilename, CompletionHandler<void(AllowOverwrite, String)>&&) final;
    5353    void didFinish(DownloadProxy&) final;
    5454    void didFail(DownloadProxy&, const WebCore::ResourceError&) final;
  • trunk/Source/WebKit/UIProcess/Cocoa/LegacyDownloadClient.mm

    r268065 r268269  
    186186}
    187187
    188 void LegacyDownloadClient::decideDestinationWithSuggestedFilename(DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler)
    189 {
     188void LegacyDownloadClient::decideDestinationWithSuggestedFilename(DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response, const String& filename, CompletionHandler<void(AllowOverwrite, String)>&& completionHandler)
     189{
     190    didReceiveResponse(downloadProxy, response);
     191
    190192#if USE(SYSTEM_PREVIEW)
    191193    if (downloadProxy.isSystemPreviewDownload()) {
     
    207209        completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, destination);
    208210    } else {
    209         [m_delegate _download:wrapper(downloadProxy) decideDestinationWithSuggestedFilename:filename completionHandler:makeBlockPtr([checker = CompletionHandlerCallChecker::create(m_delegate.get().get(), @selector(_download:decideDestinationWithSuggestedFilename:completionHandler:)), completionHandler = WTFMove(completionHandler)] (BOOL allowOverwrite, NSString *destination) {
     211        [m_delegate _download:wrapper(downloadProxy) decideDestinationWithSuggestedFilename:filename completionHandler:makeBlockPtr([checker = CompletionHandlerCallChecker::create(m_delegate.get().get(), @selector(_download:decideDestinationWithSuggestedFilename:completionHandler:)), completionHandler = WTFMove(completionHandler)] (BOOL allowOverwrite, NSString *destination) mutable {
    210212            if (checker->completionHandlerHasBeenCalled())
    211213                return;
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp

    r268261 r268269  
    140140}
    141141
    142 void DownloadProxy::didReceiveResponse(const ResourceResponse& response)
    143 {
    144     m_client->didReceiveResponse(*this, response);
    145 }
    146 
    147142void DownloadProxy::didReceiveData(uint64_t bytesWritten, uint64_t totalBytesWritten, uint64_t totalBytesExpectedToWrite)
    148143{
     
    150145}
    151146
    152 void DownloadProxy::decideDestinationWithSuggestedFilename(const String& suggestedFilename, CompletionHandler<void(String, SandboxExtension::Handle, AllowOverwrite)>&& completionHandler)
     147void DownloadProxy::decideDestinationWithSuggestedFilename(const WebCore::ResourceResponse& response, const String& suggestedFilename, CompletionHandler<void(String, SandboxExtension::Handle, AllowOverwrite)>&& completionHandler)
    153148{
    154     m_client->decideDestinationWithSuggestedFilename(*this, ResourceResponseBase::sanitizeSuggestedFilename(suggestedFilename), [completionHandler = WTFMove(completionHandler)] (AllowOverwrite allowOverwrite, String destination) mutable {
     149    m_client->decideDestinationWithSuggestedFilename(*this, response, ResourceResponseBase::sanitizeSuggestedFilename(suggestedFilename), [completionHandler = WTFMove(completionHandler)] (AllowOverwrite allowOverwrite, String destination) mutable {
    155150        SandboxExtension::Handle sandboxExtensionHandle;
    156151        if (!destination.isNull())
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.h

    r268261 r268269  
    111111    void didStart(const WebCore::ResourceRequest&, const String& suggestedFilename);
    112112    void didReceiveAuthenticationChallenge(WebCore::AuthenticationChallenge&&, uint64_t challengeID);
    113     void didReceiveResponse(const WebCore::ResourceResponse&);
    114113    void didReceiveData(uint64_t bytesWritten, uint64_t totalBytesWritten, uint64_t totalBytesExpectedToWrite);
    115114    void shouldDecodeSourceDataOfMIMEType(const String& mimeType, bool& result);
     
    118117    void didFail(const WebCore::ResourceError&, const IPC::DataReference& resumeData);
    119118    void willSendRequest(WebCore::ResourceRequest&& redirectRequest, const WebCore::ResourceResponse& redirectResponse);
    120     void decideDestinationWithSuggestedFilename(const String& suggestedFilename, CompletionHandler<void(String, SandboxExtension::Handle, AllowOverwrite)>&&);
     119    void decideDestinationWithSuggestedFilename(const WebCore::ResourceResponse&, const String& suggestedFilename, CompletionHandler<void(String, SandboxExtension::Handle, AllowOverwrite)>&&);
    121120
    122121    DownloadProxyMap& m_downloadProxyMap;
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.messages.in

    r268261 r268269  
    2525    DidReceiveAuthenticationChallenge(WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
    2626    WillSendRequest(WebCore::ResourceRequest redirectRequest, WebCore::ResourceResponse redirectResponse))
    27     DecideDestinationWithSuggestedFilename(String suggestedFilename) -> (String filename, WebKit::SandboxExtension::Handle handle, enum:bool WebKit::AllowOverwrite allowOverwrite) Async
     27    DecideDestinationWithSuggestedFilename(WebCore::ResourceResponse response, String suggestedFilename) -> (String filename, WebKit::SandboxExtension::Handle handle, enum:bool WebKit::AllowOverwrite allowOverwrite) Async
    2828
    29     DidReceiveResponse(WebCore::ResourceResponse response)
    3029    DidReceiveData(uint64_t bytesWritten, uint64_t totalBytesWritten, uint64_t totalBytesExpectedToWrite)
    3130    DidCreateDestination(String path)
Note: See TracChangeset for help on using the changeset viewer.