Changeset 233165 in webkit


Ignore:
Timestamp:
Jun 25, 2018 12:54:21 PM (6 years ago)
Author:
Chris Dumez
Message:

Make sure API::IconLoadingClient::getLoadDecisionForIcon()'s completion handler gets called
https://bugs.webkit.org/show_bug.cgi?id=187007
<rdar://problem/41293989>

Reviewed by Brady Eidson.

Make sure API::IconLoadingClient::getLoadDecisionForIcon()'s completion handler gets called by
switching its type to WTF::CompletionHandler instead of WTF::Function. This also has the benefit
of destroying our captured objects when the completion handler gets called by the client on the
main thread instead of whatever thread the ObjC block gets released on.

  • UIProcess/API/APIIconLoadingClient.h:

(API::IconLoadingClient::getLoadDecisionForIcon):

  • UIProcess/API/glib/WebKitIconLoadingClient.cpp:
  • UIProcess/API/mac/WKView.mm:

(-[WKView maybeInstallIconLoadingClient]):

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

(WebKit::IconLoadingDelegate::IconLoadingClient::getLoadDecisionForIcon):

Location:
trunk/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r233162 r233165  
     12018-06-25  Chris Dumez  <cdumez@apple.com>
     2
     3        Make sure API::IconLoadingClient::getLoadDecisionForIcon()'s completion handler gets called
     4        https://bugs.webkit.org/show_bug.cgi?id=187007
     5        <rdar://problem/41293989>
     6
     7        Reviewed by Brady Eidson.
     8
     9        Make sure API::IconLoadingClient::getLoadDecisionForIcon()'s completion handler gets called by
     10        switching its type to WTF::CompletionHandler instead of WTF::Function. This also has the benefit
     11        of destroying our captured objects when the completion handler gets called by the client on the
     12        main thread instead of whatever thread the ObjC block gets released on.
     13
     14        * UIProcess/API/APIIconLoadingClient.h:
     15        (API::IconLoadingClient::getLoadDecisionForIcon):
     16        * UIProcess/API/glib/WebKitIconLoadingClient.cpp:
     17        * UIProcess/API/mac/WKView.mm:
     18        (-[WKView maybeInstallIconLoadingClient]):
     19        * UIProcess/Cocoa/IconLoadingDelegate.h:
     20        * UIProcess/Cocoa/IconLoadingDelegate.mm:
     21        (WebKit::IconLoadingDelegate::IconLoadingClient::getLoadDecisionForIcon):
     22
    1232018-06-25  Youenn Fablet  <youenn@apple.com>
    224
  • trunk/Source/WebKit/UIProcess/API/APIIconLoadingClient.h

    r218457 r233165  
    2828#include "GenericCallback.h"
    2929#include <WebCore/LinkIcon.h>
     30#include <wtf/CompletionHandler.h>
    3031#include <wtf/Function.h>
    3132
     
    4041    virtual ~IconLoadingClient() { }
    4142
    42     virtual void getLoadDecisionForIcon(const WebCore::LinkIcon&, WTF::Function<void (WTF::Function<void (API::Data*, WebKit::CallbackBase::Error)>&&)>&& completionHandler) {
     43    virtual void getLoadDecisionForIcon(const WebCore::LinkIcon&, WTF::CompletionHandler<void(WTF::Function<void(API::Data*, WebKit::CallbackBase::Error)>&&)>&& completionHandler)
     44    {
    4345        completionHandler(nullptr);
    4446    }
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitIconLoadingClient.cpp

    r219905 r233165  
    3434
    3535private:
    36     void getLoadDecisionForIcon(const WebCore::LinkIcon& icon, Function<void (Function<void (API::Data*, CallbackBase::Error)>&&)>&& completionHandler) override
     36    void getLoadDecisionForIcon(const WebCore::LinkIcon& icon, CompletionHandler<void(Function<void(API::Data*, CallbackBase::Error)>&&)>&& completionHandler) override
    3737    {
    3838        // WebCore can send non HTTP icons.
  • trunk/Source/WebKit/UIProcess/API/mac/WKView.mm

    r232523 r233165  
    884884        typedef void (^IconLoadCompletionHandler)(NSData*);
    885885
    886         void getLoadDecisionForIcon(const WebCore::LinkIcon& linkIcon, WTF::Function<void (WTF::Function<void (API::Data*, WebKit::CallbackBase::Error)>&&)>&& completionHandler) override {
     886        void getLoadDecisionForIcon(const WebCore::LinkIcon& linkIcon, WTF::CompletionHandler<void(WTF::Function<void(API::Data*, WebKit::CallbackBase::Error)>&&)>&& completionHandler) override
     887        {
    887888            RetainPtr<_WKLinkIconParameters> parameters = adoptNS([[_WKLinkIconParameters alloc] _initWithLinkIcon:linkIcon]);
    888889
    889890            [m_wkView performSelector:delegateSelector() withObject:parameters.get() withObject:BlockPtr<void (IconLoadCompletionHandler)>::fromCallable([completionHandler = WTFMove(completionHandler)](IconLoadCompletionHandler loadCompletionHandler) {
     891                ASSERT(RunLoop::isMain());
    890892                if (loadCompletionHandler) {
    891893                    completionHandler([loadCompletionHandler = BlockPtr<void (NSData *)>(loadCompletionHandler)](API::Data* data, WebKit::CallbackBase::Error error) {
  • trunk/Source/WebKit/UIProcess/Cocoa/IconLoadingDelegate.h

    r232082 r233165  
    5656
    5757    private:
    58         void getLoadDecisionForIcon(const WebCore::LinkIcon&, WTF::Function<void (WTF::Function<void (API::Data*, WebKit::CallbackBase::Error)>&&)>&& completionHandler) override;
     58        void getLoadDecisionForIcon(const WebCore::LinkIcon&, WTF::CompletionHandler<void(WTF::Function<void(API::Data*, WebKit::CallbackBase::Error)>&&)>&&) override;
    5959
    6060        IconLoadingDelegate& m_iconLoadingDelegate;
  • trunk/Source/WebKit/UIProcess/Cocoa/IconLoadingDelegate.mm

    r218457 r233165  
    7373typedef void (^IconLoadCompletionHandler)(NSData*);
    7474
    75 void IconLoadingDelegate::IconLoadingClient::getLoadDecisionForIcon(const WebCore::LinkIcon& linkIcon, WTF::Function<void (WTF::Function<void (API::Data*, WebKit::CallbackBase::Error)>&&)>&& completionHandler)
     75void IconLoadingDelegate::IconLoadingClient::getLoadDecisionForIcon(const WebCore::LinkIcon& linkIcon, WTF::CompletionHandler<void(WTF::Function<void(API::Data*, WebKit::CallbackBase::Error)>&&)>&& completionHandler)
    7676{
    7777    if (!m_iconLoadingDelegate.m_delegateMethods.webViewShouldLoadIconWithParametersCompletionHandler) {
     
    8989
    9090    [delegate webView:m_iconLoadingDelegate.m_webView shouldLoadIconWithParameters:parameters.get() completionHandler:BlockPtr<void (IconLoadCompletionHandler loadCompletionHandler)>::fromCallable([completionHandler = WTFMove(completionHandler)] (IconLoadCompletionHandler loadCompletionHandler) {
     91        ASSERT(RunLoop::isMain());
    9192        if (loadCompletionHandler) {
    9293            completionHandler([loadCompletionHandler = Block_copy(loadCompletionHandler)](API::Data* data, WebKit::CallbackBase::Error error) {
Note: See TracChangeset for help on using the changeset viewer.