Changeset 229959 in webkit


Ignore:
Timestamp:
Mar 24, 2018, 11:19:02 PM (7 years ago)
Author:
achristensen@apple.com
Message:

Use completion handlers for ResourceHandleClient::canAuthenticateAgainstProtectionSpaceAsync
https://bugs.webkit.org/show_bug.cgi?id=183966

Reviewed by Chris Dumez.

No change in behavior.

  • loader/ResourceLoader.cpp:

(WebCore::ResourceLoader::canAuthenticateAgainstProtectionSpaceAsync):

  • loader/ResourceLoader.h:
  • platform/network/BlobResourceHandle.cpp:
  • platform/network/PingHandle.h:
  • platform/network/ResourceHandle.h:
  • platform/network/ResourceHandleClient.h:
  • platform/network/SynchronousLoaderClient.cpp:

(WebCore::SynchronousLoaderClient::canAuthenticateAgainstProtectionSpaceAsync):

  • platform/network/SynchronousLoaderClient.h:
  • platform/network/cf/ResourceHandleCFURLConnectionDelegate.h:
  • platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:

(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::canRespondToProtectionSpace):

  • platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.h:
  • platform/network/mac/ResourceHandleMac.mm:

(WebCore::ResourceHandle::canAuthenticateAgainstProtectionSpace):
(WebCore::ResourceHandle::continueCanAuthenticateAgainstProtectionSpace): Deleted.

  • platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h:
  • platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:

(-[WebCoreResourceHandleAsOperationQueueDelegate connection:canAuthenticateAgainstProtectionSpace:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate continueCanAuthenticateAgainstProtectionSpace:]): Deleted.

Location:
trunk/Source/WebCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r229954 r229959  
     12018-03-23  Alex Christensen  <achristensen@webkit.org>
     2
     3        Use completion handlers for ResourceHandleClient::canAuthenticateAgainstProtectionSpaceAsync
     4        https://bugs.webkit.org/show_bug.cgi?id=183966
     5
     6        Reviewed by Chris Dumez.
     7
     8        No change in behavior.
     9
     10        * loader/ResourceLoader.cpp:
     11        (WebCore::ResourceLoader::canAuthenticateAgainstProtectionSpaceAsync):
     12        * loader/ResourceLoader.h:
     13        * platform/network/BlobResourceHandle.cpp:
     14        * platform/network/PingHandle.h:
     15        * platform/network/ResourceHandle.h:
     16        * platform/network/ResourceHandleClient.h:
     17        * platform/network/SynchronousLoaderClient.cpp:
     18        (WebCore::SynchronousLoaderClient::canAuthenticateAgainstProtectionSpaceAsync):
     19        * platform/network/SynchronousLoaderClient.h:
     20        * platform/network/cf/ResourceHandleCFURLConnectionDelegate.h:
     21        * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
     22        (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::canRespondToProtectionSpace):
     23        * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.h:
     24        * platform/network/mac/ResourceHandleMac.mm:
     25        (WebCore::ResourceHandle::canAuthenticateAgainstProtectionSpace):
     26        (WebCore::ResourceHandle::continueCanAuthenticateAgainstProtectionSpace): Deleted.
     27        * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h:
     28        * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
     29        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:canAuthenticateAgainstProtectionSpace:]):
     30        (-[WebCoreResourceHandleAsOperationQueueDelegate continueCanAuthenticateAgainstProtectionSpace:]): Deleted.
     31
    1322018-03-24  Chris Dumez  <cdumez@apple.com>
    233
  • trunk/Source/WebCore/loader/ResourceLoader.cpp

    r228901 r229959  
    737737
    738738#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    739 void ResourceLoader::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle* handle, const ProtectionSpace& protectionSpace)
    740 {
    741     handle->continueCanAuthenticateAgainstProtectionSpace(canAuthenticateAgainstProtectionSpace(protectionSpace));
     739void ResourceLoader::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace& protectionSpace, CompletionHandler<void(bool)>&& completionHandler)
     740{
     741    completionHandler(canAuthenticateAgainstProtectionSpace(protectionSpace));
    742742}
    743743
  • trunk/Source/WebCore/loader/ResourceLoader.h

    r228852 r229959  
    200200    void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) override;
    201201#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    202     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&) override;
     202    void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&, CompletionHandler<void(bool)>&&) override;
    203203#endif
    204204    void receivedCancellation(ResourceHandle*, const AuthenticationChallenge& challenge) override { receivedCancellation(challenge); }
  • trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp

    r227455 r229959  
    8080    void willSendRequestAsync(ResourceHandle*, ResourceRequest&&, ResourceResponse&&, CompletionHandler<void(ResourceRequest&&)>&&) final;
    8181#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    82     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&) final;
     82    void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&, CompletionHandler<void(bool)>&&) final;
    8383#endif
    8484
     
    103103
    104104#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    105 void BlobResourceSynchronousLoader::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle* handle, const ProtectionSpace&)
     105void BlobResourceSynchronousLoader::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&, CompletionHandler<void(bool)>&& completionHandler)
    106106{
    107107    ASSERT_NOT_REACHED();
    108     handle->continueCanAuthenticateAgainstProtectionSpace(false);
     108    completionHandler(false);
    109109}
    110110#endif
  • trunk/Source/WebCore/platform/network/PingHandle.h

    r227455 r229959  
    7979    void timeoutTimerFired() { pingLoadComplete(ResourceError { String(), 0, m_currentRequest.url(), ASCIILiteral("Load timed out"), ResourceError::Type::Timeout }); }
    8080#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    81     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&)
     81    void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&, CompletionHandler<void(bool)>&& completionHandler)
    8282    {
    83         m_handle->continueCanAuthenticateAgainstProtectionSpace(false);
     83        completionHandler(false);
    8484        pingLoadComplete(ResourceError { String { }, 0, m_currentRequest.url(), ASCIILiteral("Not allowed to authenticate"), ResourceError::Type::AccessControl });
    8585    }
  • trunk/Source/WebCore/platform/network/ResourceHandle.h

    r229347 r229959  
    132132
    133133#if PLATFORM(COCOA) && USE(PROTECTION_SPACE_AUTH_CALLBACK)
    134     bool canAuthenticateAgainstProtectionSpace(const ProtectionSpace&);
     134    void canAuthenticateAgainstProtectionSpace(const ProtectionSpace&, CompletionHandler<void(bool)>&&);
    135135#endif
    136136
     
    212212    WEBCORE_EXPORT void clearClient();
    213213
    214 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    215     // Called in response to ResourceHandleClient::canAuthenticateAgainstProtectionSpaceAsync().
    216     WEBCORE_EXPORT void continueCanAuthenticateAgainstProtectionSpace(bool);
    217 #endif
    218 
    219214    // Called in response to ResourceHandleClient::willCacheResponseAsync().
    220215#if USE(CFURLCONNECTION)
  • trunk/Source/WebCore/platform/network/ResourceHandleClient.h

    r228483 r229959  
    8080
    8181#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    82     // Client will pass an updated request using ResourceHandle::continueCanAuthenticateAgainstProtectionSpace() when ready.
    83     WEBCORE_EXPORT virtual void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&) = 0;
     82    WEBCORE_EXPORT virtual void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&, CompletionHandler<void(bool)>&&) = 0;
    8483#endif
    8584    // Client will pass an updated request using ResourceHandle::continueWillCacheResponse() when ready.
  • trunk/Source/WebCore/platform/network/SynchronousLoaderClient.cpp

    r227455 r229959  
    5656
    5757#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    58 void SynchronousLoaderClient::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle* handle, const ProtectionSpace&)
     58void SynchronousLoaderClient::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&, CompletionHandler<void(bool)>&& completionHandler)
    5959{
    6060    // FIXME: We should ask FrameLoaderClient. <http://webkit.org/b/65196>
    61     handle->continueCanAuthenticateAgainstProtectionSpace(true);
     61    completionHandler(true);
    6262}
    6363#endif
  • trunk/Source/WebCore/platform/network/SynchronousLoaderClient.h

    r227455 r229959  
    5555    void didFail(ResourceHandle*, const ResourceError&) override;
    5656#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    57     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&) override;
     57    void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&, CompletionHandler<void(bool)>&&) override;
    5858#endif
    5959
  • trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegate.h

    r227455 r229959  
    4848
    4949    virtual void continueWillCacheResponse(CFCachedURLResponseRef) = 0;
    50 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    51     virtual void continueCanAuthenticateAgainstProtectionSpace(bool) = 0;
    52 #endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
    5350
    5451protected:
  • trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp

    r227455 r229959  
    364364        auto& handle = protectedThis->m_handle;
    365365       
    366         if (!protectedThis->hasHandle()) {
    367             protectedThis->continueCanAuthenticateAgainstProtectionSpace(false);
    368             return;
    369         }
     366        auto completionHandler = [protectedThis = WTFMove(protectedThis)] (bool result) mutable {
     367            protectedThis->m_boolResult = canAuthenticate;
     368            protectedThis->m_semaphore.signal();
     369        }
     370       
     371        if (!handle)
     372            return completionHandler(false);
    370373
    371374        LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::canRespondToProtectionSpace(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
    372375
    373         ProtectionSpace coreProtectionSpace = ProtectionSpace(protectionSpace.get());
    374         handle->canAuthenticateAgainstProtectionSpace(coreProtectionSpace);
     376        handle->canAuthenticateAgainstProtectionSpace(ProtectionSpace(protectionSpace.get()), WTFMove(completionHandler));
    375377    };
    376378   
  • trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.h

    r227455 r229959  
    6262#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    6363    Boolean canRespondToProtectionSpace(CFURLProtectionSpaceRef) override;
    64     void continueCanAuthenticateAgainstProtectionSpace(bool) override;
    6564#endif
    6665
  • trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm

    r227455 r229959  
    565565
    566566#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    567 bool ResourceHandle::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
     567void ResourceHandle::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace, CompletionHandler<void(bool)>&& completionHandler)
    568568{
    569569    if (ResourceHandleClient* client = this->client())
    570         client->canAuthenticateAgainstProtectionSpaceAsync(this, protectionSpace);
     570        client->canAuthenticateAgainstProtectionSpaceAsync(this, protectionSpace, WTFMove(completionHandler));
    571571    else
    572         continueCanAuthenticateAgainstProtectionSpace(false);
    573     return false; // Ignored by caller.
    574 }
    575 
    576 void ResourceHandle::continueCanAuthenticateAgainstProtectionSpace(bool result)
    577 {
    578     [(id)delegate() continueCanAuthenticateAgainstProtectionSpace:result];
     572        completionHandler(false);
    579573}
    580574#endif
  • trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h

    r228545 r229959  
    5252- (void)detachHandle;
    5353- (id)initWithHandle:(WebCore::ResourceHandle*)handle messageQueue:(MessageQueue<Function<void()>>*)messageQueue;
    54 - (void)continueCanAuthenticateAgainstProtectionSpace:(BOOL)canAuthenticate;
    5554- (void)continueWillCacheResponse:(NSCachedURLResponse *)response;
    5655@end
  • trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm

    r228586 r229959  
    115115}
    116116
    117 - (void)continueCanAuthenticateAgainstProtectionSpace:(BOOL)canAuthenticate
    118 {
    119     m_boolResult = canAuthenticate;
    120     dispatch_semaphore_signal(m_semaphore);
    121 }
    122 
    123117- (void)continueWillCacheResponse:(NSCachedURLResponse *)response
    124118{
     
    207201            return;
    208202        }
    209         m_handle->canAuthenticateAgainstProtectionSpace(ProtectionSpace(protectionSpace.get()));
     203        m_handle->canAuthenticateAgainstProtectionSpace(ProtectionSpace(protectionSpace.get()), [self, protectedSelf = WTFMove(protectedSelf)] (bool result) mutable {
     204            m_boolResult = result;
     205            dispatch_semaphore_signal(m_semaphore);
     206        });
    210207    };
    211208
Note: See TracChangeset for help on using the changeset viewer.