Changeset 223408 in webkit


Ignore:
Timestamp:
Oct 16, 2017 9:12:18 AM (7 years ago)
Author:
Ryan Haddad
Message:

Unreviewed, rolling out r223271.

This change introduced LayoutTest failures on WK1.

Reverted changeset:

"Use asynchronous ResourceHandleClient calls for WebKit1"
https://bugs.webkit.org/show_bug.cgi?id=160677
https://trac.webkit.org/changeset/223271

Location:
trunk
Files:
2 added
49 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r223407 r223408  
     12017-10-16  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r223271.
     4
     5        This change introduced LayoutTest failures on WK1.
     6
     7        Reverted changeset:
     8
     9        "Use asynchronous ResourceHandleClient calls for WebKit1"
     10        https://bugs.webkit.org/show_bug.cgi?id=160677
     11        https://trac.webkit.org/changeset/223271
     12
    1132017-10-16  Per Arne Vollan  <pvollan@apple.com>
    214
  • trunk/LayoutTests/TestExpectations

    r223340 r223408  
    4040# window.showModalDialog is only tested in DumpRenderTree on Mac.
    4141editing/execCommand/show-modal-dialog-during-execCommand.html [ Skip ]
    42 http/tests/security/cross-origin-modal-dialog-base.html [ Skip ]
    43 fast/events/scroll-event-during-modal-dialog.html [ Skip ]
    44 fast/harness/show-modal-dialog.html [ Skip ]
    4542
    4643fast/shadow-dom/touch-event-on-text-assigned-to-slot.html [ Skip ]
     
    441438webkit.org/b/169565 imported/w3c/web-platform-tests/cors/status-async.htm [ Failure ]
    442439webkit.org/b/169565 imported/w3c/web-platform-tests/cors/304.htm [ Failure ]
    443 
    444 # These tests used to have deterministic load delegate callback order before webkit.org/b/160677
    445 http/tests/svg/svg-use-external.html [ Pass Failure ]
    446 http/tests/loading/text-content-type-with-binary-extension.html [ Pass Failure ]
    447 http/tests/security/contentSecurityPolicy/block-all-mixed-content/insecure-iframe-in-main-frame.html [ Pass Failure ]
    448440
    449441# Tests that are flakey due to unhandled promise rejection error messages
     
    785777webkit.org/b/140043 js/dom/Promise.html [ Pass Failure ]
    786778
    787 webkit.org/b/134550 http/tests/cache/iframe-304-crash.html [ Failure Pass ]
    788779webkit.org/b/141267 http/tests/misc/detached-frame-console.html [ Pass Failure ]
    789780
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r223325 r223408  
    16361636webkit.org/b/36642 fast/replaced/border-radius-clip.html [ Failure Pass Crash ]
    16371637
     1638webkit.org/b/134550 http/tests/cache/iframe-304-crash.html [ Failure Pass ]
     1639
    16381640webkit.org/b/134573 media/track/audio-track.html [ Failure Timeout Pass ]
    16391641webkit.org/b/134576 media/track/audio/audio-track-mkv-vorbis-language.html [ Failure Timeout Pass ]
  • trunk/LayoutTests/platform/ios-wk2/TestExpectations

    r223271 r223408  
    447447
    448448# HTTP tests that are flaky:
     449http/tests/cache/iframe-304-crash.html [ Failure Pass ]
    449450http/tests/navigation/forward-and-cancel.html [ Failure Pass ]
    450451http/tests/security/xss-DENIED-xsl-external-entity-redirect.xml [ Failure Pass ]
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r223324 r223408  
    298298webkit.org/b/162999 accessibility/mac/wk1-set-selected-text-marker-range-input-element.html [ Skip ]
    299299
     300webkit.org/b/134550 http/tests/cache/iframe-304-crash.html [ Pass Failure ]
     301
    300302# testRunner.setUseDeferredFrameLoading is not implemented.
    301303webkit.org/b/93980 http/tests/appcache/load-from-appcache-defer-resume-crash.html [ Skip ]
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r223271 r223408  
    265265fast/events/scroll-event-during-modal-dialog.html
    266266fast/harness/show-modal-dialog.html
     267http/tests/security/cross-origin-modal-dialog-base.html [ Skip ]
    267268
    268269# WebKit2 needs to support synchronous creation of about:blank/data:url frames
  • trunk/LayoutTests/security/block-test.html

    r223271 r223408  
    6868        }
    6969    }
    70 
    71     function makeImage() {
    72         var image = document.createElement("img");
    73         image.onerror=nextBlockedPortTest;
    74         image.src="http://255.255.255.255:1/test.jpg";
    75         image.id="testIMG";
    76         document.body.appendChild(image);
    77     }
    7870</script>
    79 <body onload="makeImage()">
     71<body>
    8072<p>This test attempts to change the src of an IMG tag to all black listed ports to confirm that WebKit returns the
    8173correct error for them - blocked instead of cannot find.  It also tries the FTP ports for exemptions.  Due to the
    8274nature of this test, the results can only be processed automatically via DumpRenderTree
    8375</p>
     76<img id="testIMG" src="http://255.255.255.255:1/test.jpg" onError="nextBlockedPortTest();"></img>
    8477</body>
    8578</html>
  • trunk/LayoutTests/svg/in-html/by-reference.html

    r223271 r223408  
    55-->
    66<head>
    7     <script>
    8         if (window.testRunner)
    9             testRunner.waitUntilDone();
    10         var elementsLoaded = 0;
    11         function loaded() {
    12             if (window.testRunner && ++elementsLoaded == 5)
    13                 testRunner.notifyDone();
    14         }
    15     </script>
    167  <style type='text/css'>
    178    * {
     
    3122<body>
    3223  <div>
    33     <object onload="loaded()" type='image/svg+xml' width='50' height='50' data='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></object>
    34     <embed onload="loaded()" width='50' height='50' src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></embed>
    35     <iframe onload="loaded()" width='100' height='100' src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></iframe>
    36     <object onload="loaded()" type='text/xml' width='50' height='50' data='data:text/xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></object>
    37     <object onload="loaded()" type='application/xml' width='50' height='50' data='data:application/xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></object-->
     24    <object type='image/svg+xml' width='50' height='50' data='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></object>
     25    <embed width='50' height='50' src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></embed>
     26    <iframe width='100' height='100' src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></iframe>
     27    <object type='text/xml' width='50' height='50' data='data:text/xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></object>
     28    <object type='application/xml' width='50' height='50' data='data:application/xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUwIiBoZWlnaHQ9IjUwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciLz4='></object-->
    3829  </div>
    3930</body>
  • trunk/Source/WebCore/ChangeLog

    r223406 r223408  
     12017-10-16  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r223271.
     4
     5        This change introduced LayoutTest failures on WK1.
     6
     7        Reverted changeset:
     8
     9        "Use asynchronous ResourceHandleClient calls for WebKit1"
     10        https://bugs.webkit.org/show_bug.cgi?id=160677
     11        https://trac.webkit.org/changeset/223271
     12
    1132017-10-16  Alejandro G. Castro  <alex@igalia.com>
    214
  • trunk/Source/WebCore/PlatformAppleWin.cmake

    r223271 r223408  
    6161    platform/network/cf/ResourceHandleCFNet.cpp
    6262    platform/network/cf/ResourceHandleCFURLConnectionDelegate.cpp
    63     platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp
    6463    platform/network/cf/ResourceRequestCFNet.cpp
    6564    platform/network/cf/ResourceResponseCFNet.cpp
    6665    platform/network/cf/SocketStreamHandleImplCFNet.cpp
    6766    platform/network/cf/SynchronousLoaderClientCFNet.cpp
     67    platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp
    6868)
    6969
  • trunk/Source/WebCore/PlatformMac.cmake

    r223271 r223408  
    563563    platform/network/mac/SynchronousLoaderClient.mm
    564564    platform/network/mac/UTIUtilities.mm
     565    platform/network/mac/WebCoreResourceHandleAsDelegate.mm
    565566    platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm
    566567    platform/network/mac/WebCoreURLResponse.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r223406 r223408  
    10921092                26FAE4CC1852E3A5004C8C46 /* ResourceHandleCFURLConnectionDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26FAE4C81852E3A5004C8C46 /* ResourceHandleCFURLConnectionDelegate.cpp */; };
    10931093                26FAE4CD1852E3A5004C8C46 /* ResourceHandleCFURLConnectionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 26FAE4C91852E3A5004C8C46 /* ResourceHandleCFURLConnectionDelegate.h */; };
     1094                26FAE4CE1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26FAE4CA1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.cpp */; };
     1095                26FAE4CF1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 26FAE4CB1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.h */; };
    10941096                2914E3071CAB5A440049966F /* AccessibilityAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2914E3051CAB5A440049966F /* AccessibilityAttachment.cpp */; };
    10951097                2914E3081CAB5A440049966F /* AccessibilityAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 2914E3061CAB5A440049966F /* AccessibilityAttachment.h */; };
     
    67046706                E17B492116A9B8FF001C8839 /* JSTransitionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = E17B491F16A9B8FF001C8839 /* JSTransitionEvent.h */; };
    67056707                E17B492216A9B8FF001C8839 /* JSTransitionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E17B492016A9B8FF001C8839 /* JSTransitionEvent.cpp */; };
     6708                E180810E16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = E180810C16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.mm */; };
     6709                E180810F16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = E180810D16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.h */; };
    67066710                E180811216FCF42F00B80D07 /* SynchronousLoaderClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E180811016FCF42E00B80D07 /* SynchronousLoaderClient.cpp */; };
    67076711                E180811616FCF9CB00B80D07 /* SynchronousLoaderClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = E180811416FCF9CB00B80D07 /* SynchronousLoaderClient.mm */; };
     
    87398743                26FAE4C81852E3A5004C8C46 /* ResourceHandleCFURLConnectionDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceHandleCFURLConnectionDelegate.cpp; sourceTree = "<group>"; };
    87408744                26FAE4C91852E3A5004C8C46 /* ResourceHandleCFURLConnectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceHandleCFURLConnectionDelegate.h; sourceTree = "<group>"; };
     8745                26FAE4CA1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SynchronousResourceHandleCFURLConnectionDelegate.cpp; sourceTree = "<group>"; };
     8746                26FAE4CB1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SynchronousResourceHandleCFURLConnectionDelegate.h; sourceTree = "<group>"; };
    87418747                2914E3051CAB5A440049966F /* AccessibilityAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityAttachment.cpp; sourceTree = "<group>"; };
    87428748                2914E3061CAB5A440049966F /* AccessibilityAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityAttachment.h; sourceTree = "<group>"; };
     
    1552015526                E17B491F16A9B8FF001C8839 /* JSTransitionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTransitionEvent.h; sourceTree = "<group>"; };
    1552115527                E17B492016A9B8FF001C8839 /* JSTransitionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTransitionEvent.cpp; sourceTree = "<group>"; };
     15528                E180810C16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreResourceHandleAsDelegate.mm; sourceTree = "<group>"; };
     15529                E180810D16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreResourceHandleAsDelegate.h; sourceTree = "<group>"; };
    1552215530                E180811016FCF42E00B80D07 /* SynchronousLoaderClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SynchronousLoaderClient.cpp; sourceTree = "<group>"; };
    1552315531                E180811416FCF9CB00B80D07 /* SynchronousLoaderClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SynchronousLoaderClient.mm; sourceTree = "<group>"; };
     
    1958219590                                1FAFBF1615A5FA5200083A20 /* UTIUtilities.h */,
    1958319591                                1FAFBF1715A5FA5200083A20 /* UTIUtilities.mm */,
     19592                                E180810D16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.h */,
     19593                                E180810C16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.mm */,
    1958419594                                E152551316FD234F003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h */,
    1958519595                                E152551416FD234F003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.mm */,
     
    2410424114                                51ABAE1D103C1913008C5260 /* SocketStreamHandleImplCFNet.cpp */,
    2410524115                                442ABCD517D9262F00D30715 /* SynchronousLoaderClientCFNet.cpp */,
     24116                                26FAE4CA1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.cpp */,
     24117                                26FAE4CB1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.h */,
    2410624118                        );
    2410724119                        path = cf;
     
    3054930561                                517A53461F50C17F00DCDC0A /* SWServerWorker.h in Headers */,
    3055030562                                E180811716FCF9CB00B80D07 /* SynchronousLoaderClient.h in Headers */,
     30563                                26FAE4CF1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.h in Headers */,
    3055130564                                0F03C0741884695E00A5F8CA /* SystemMemory.h in Headers */,
    3055230565                                5D5975B319635F1100D00878 /* SystemVersion.h in Headers */,
     
    3078130794                                DD05FE0D0B8BA3C6009ACDFE /* WebCoreObjCExtras.h in Headers */,
    3078230795                                EDEC98030AED7E170059137F /* WebCorePrefix.h in Headers */,
     30796                                E180810F16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.h in Headers */,
    3078330797                                E152551516FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h in Headers */,
    3078430798                                A14832C7187F66C800DA63A6 /* WebCoreThread.h in Headers */,
     
    3435434368                                E180811616FCF9CB00B80D07 /* SynchronousLoaderClient.mm in Sources */,
    3435534369                                442ABCD617D9262F00D30715 /* SynchronousLoaderClientCFNet.cpp in Sources */,
     34370                                26FAE4CE1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.cpp in Sources */,
    3435634371                                E45390AE0EAFF4B5003695C8 /* SystemMemoryIOS.cpp in Sources */,
    3435734372                                5D5975B419635F1100D00878 /* SystemVersion.mm in Sources */,
     
    3456534580                                B50F5B810E96CD9900AD71A6 /* WebCoreObjCExtras.mm in Sources */,
    3456634581                                9BDD18271F7E05F400E8E577 /* WebCorePasteboardFileReader.cpp in Sources */,
     34582                                E180810E16FCECDF00B80D07 /* WebCoreResourceHandleAsDelegate.mm in Sources */,
    3456734583                                E152551616FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.mm in Sources */,
    3456834584                                A14832C8187F673F00DA63A6 /* WebCoreThread.mm in Sources */,
  • trunk/Source/WebCore/editing/cocoa/WebArchiveResourceFromNSAttributedString.mm

    r223271 r223408  
    4343    }
    4444
    45     resource = ArchiveResource::create(SharedBuffer::create(adoptNS([data copy]).get()), URL, MIMEType, textEncodingName, frameName, { });
     45    resource = ArchiveResource::create(SharedBuffer::create(adoptNS([data copy]).get()), URL, MIMEType, textEncodingName, frameName, nil);
    4646    if (!resource) {
    4747        [self release];
  • trunk/Source/WebCore/loader/ResourceLoader.cpp

    r223271 r223408  
    619619}
    620620
    621 void ResourceLoader::willSendRequestAsync(ResourceHandle* handle, ResourceRequest&& request, ResourceResponse&& redirectResponse)
    622 {
    623     RefPtr<ResourceHandle> protectedHandle(handle);
    624     if (documentLoader()->applicationCacheHost().maybeLoadFallbackForRedirect(this, request, redirectResponse)) {
    625         handle->continueWillSendRequest(WTFMove(request));
    626         return;
    627     }
     621ResourceRequest ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest&& request, ResourceResponse&& redirectResponse)
     622{
     623    if (documentLoader()->applicationCacheHost().maybeLoadFallbackForRedirect(this, request, redirectResponse))
     624        return WTFMove(request);
    628625    willSendRequestInternal(request, redirectResponse);
    629     handle->continueWillSendRequest(WTFMove(request));
     626    return WTFMove(request);
    630627}
    631628
     
    635632}
    636633
    637 void ResourceLoader::didReceiveResponseAsync(ResourceHandle* handle, ResourceResponse&& response)
    638 {
    639     if (documentLoader()->applicationCacheHost().maybeLoadFallbackForResponse(this, response)) {
    640         handle->continueDidReceiveResponse();
    641         return;
    642     }
     634void ResourceLoader::didReceiveResponse(ResourceHandle*, ResourceResponse&& response)
     635{
     636    if (documentLoader()->applicationCacheHost().maybeLoadFallbackForResponse(this, response))
     637        return;
    643638    didReceiveResponse(response);
    644     handle->continueDidReceiveResponse();
    645639}
    646640
     
    713707
    714708#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    715 void ResourceLoader::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle* handle, const ProtectionSpace& protectionSpace)
    716 {
    717     handle->continueCanAuthenticateAgainstProtectionSpace(canAuthenticateAgainstProtectionSpace(protectionSpace));
    718 }
    719709
    720710bool ResourceLoader::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
  • trunk/Source/WebCore/loader/ResourceLoader.h

    r223271 r223408  
    185185
    186186    // ResourceHandleClient
     187    ResourceRequest willSendRequest(ResourceHandle*, ResourceRequest&&, ResourceResponse&& redirectResponse) override;
    187188    void didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
    188     void didReceiveResponseAsync(ResourceHandle*, ResourceResponse&&) override;
    189     void willSendRequestAsync(ResourceHandle*, ResourceRequest&&, ResourceResponse&&) override;
     189    void didReceiveResponse(ResourceHandle*, ResourceResponse&&) override;
    190190    void didReceiveData(ResourceHandle*, const char*, unsigned, int encodedDataLength) override;
    191191    void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int encodedDataLength) override;
     
    197197    void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) override { didReceiveAuthenticationChallenge(challenge); }
    198198#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    199     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&) override;
     199    bool canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace& protectionSpace) override { return canAuthenticateAgainstProtectionSpace(protectionSpace); }
    200200#endif
    201201    void receivedCancellation(ResourceHandle*, const AuthenticationChallenge& challenge) override { receivedCancellation(challenge); }
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp

    r223271 r223408  
    486486}
    487487
    488 void ApplicationCacheGroup::didReceiveResponseAsync(ResourceHandle* handle, ResourceResponse&& response)
     488void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, ResourceResponse&& response)
    489489{
    490490    ASSERT(m_frame);
     
    493493    if (handle == m_manifestHandle) {
    494494        didReceiveManifestResponse(response);
    495         handle->continueDidReceiveResponse();
    496495        return;
    497496    }
     
    520519            // Load the next resource, if any.
    521520            startLoadingEntry();
    522             handle->continueDidReceiveResponse();
    523521            return;
    524522        }
     
    552550            startLoadingEntry();
    553551        }
    554         handle->continueDidReceiveResponse();
    555552        return;
    556553    }
    557554   
    558555    m_currentResource = ApplicationCacheResource::create(url, response, type);
    559     handle->continueDidReceiveResponse();
    560 }
    561 
    562 void ApplicationCacheGroup::willSendRequestAsync(ResourceHandle* handle, ResourceRequest&& request, ResourceResponse&&)
    563 {
    564     handle->continueWillSendRequest(WTFMove(request));
    565 }
    566 
    567 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    568 void ApplicationCacheGroup::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle* handle, const ProtectionSpace&)
    569 {
    570     handle->continueCanAuthenticateAgainstProtectionSpace(false);
    571 }
    572 #endif
     556}
    573557
    574558void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* data, unsigned length, int encodedDataLength)
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h

    r223271 r223408  
    110110
    111111    // ResourceHandleClient
    112     void didReceiveResponseAsync(ResourceHandle*, ResourceResponse&&) final;
    113     void willSendRequestAsync(ResourceHandle*, ResourceRequest&&, ResourceResponse&&) final;
    114 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    115     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&) final;
    116 #endif
    117     void didReceiveData(ResourceHandle*, const char*, unsigned length, int encodedDataLength) final;
    118     void didFinishLoading(ResourceHandle*) final;
    119     void didFail(ResourceHandle*, const ResourceError&) final;
     112    void didReceiveResponse(ResourceHandle*, ResourceResponse&&) override;
     113    void didReceiveData(ResourceHandle*, const char*, unsigned length, int encodedDataLength) override;
     114    void didFinishLoading(ResourceHandle*) override;
     115    void didFail(ResourceHandle*, const ResourceError&) override;
    120116
    121117    void didReceiveManifestResponse(const ResourceResponse&);
  • trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp

    r223271 r223408  
    7575    BlobResourceSynchronousLoader(ResourceError&, ResourceResponse&, Vector<char>&);
    7676
    77     void didReceiveResponseAsync(ResourceHandle*, ResourceResponse&&) final;
    78     void didFail(ResourceHandle*, const ResourceError&) final;
    79     void willSendRequestAsync(ResourceHandle*, ResourceRequest&&, ResourceResponse&&) final;
    80 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    81     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&) final;
    82 #endif
     77    void didReceiveResponse(ResourceHandle*, ResourceResponse&&) override;
     78    void didFail(ResourceHandle*, const ResourceError&) override;
    8379
    8480private:
     
    9591}
    9692
    97 void BlobResourceSynchronousLoader::willSendRequestAsync(ResourceHandle* handle, ResourceRequest&& request, ResourceResponse&&)
    98 {
    99     ASSERT_NOT_REACHED();
    100     handle->continueWillSendRequest(WTFMove(request));
    101 }
    102 
    103 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    104 void BlobResourceSynchronousLoader::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle* handle, const ProtectionSpace&)
    105 {
    106     ASSERT_NOT_REACHED();
    107     handle->continueCanAuthenticateAgainstProtectionSpace(false);
    108 }
    109 #endif
    110 
    111 void BlobResourceSynchronousLoader::didReceiveResponseAsync(ResourceHandle* handle, ResourceResponse&& response)
     93void BlobResourceSynchronousLoader::didReceiveResponse(ResourceHandle* handle, ResourceResponse&& response)
    11294{
    11395    // We cannot handle the size that is more than maximum integer.
    11496    if (response.expectedContentLength() > INT_MAX) {
    11597        m_error = ResourceError(webKitBlobResourceDomain, static_cast<int>(BlobResourceHandle::Error::NotReadableError), response.url(), "File is too large");
    116         handle->continueDidReceiveResponse();
    11798        return;
    11899    }
     
    123104    m_data.resize(static_cast<size_t>(response.expectedContentLength()));
    124105    static_cast<BlobResourceHandle*>(handle)->readSync(m_data.data(), static_cast<int>(m_data.size()));
    125     handle->continueDidReceiveResponse();
    126106}
    127107
     
    180160void BlobResourceHandle::continueDidReceiveResponse()
    181161{
     162    ASSERT(m_async);
     163    ASSERT(usesAsyncCallbacks());
     164
    182165    m_buffer.resize(bufferSize);
    183166    readAsync();
     
    246229            Ref<BlobResourceHandle> protectedThis(*this);
    247230            notifyResponse();
     231            if (!usesAsyncCallbacks()) {
     232                m_buffer.resize(bufferSize);
     233                readAsync();
     234            }
    248235        }
    249236        return;
     
    436423{
    437424    ASSERT(isMainThread());
     425    ASSERT(m_async);
    438426
    439427    // Do not continue if the request is aborted or an error occurs.
     
    459447{
    460448    ASSERT(isMainThread());
     449    ASSERT(m_async);
    461450    ASSERT(item.data().data());
    462451
     
    473462{
    474463    ASSERT(isMainThread());
     464    ASSERT(m_async);
    475465
    476466    if (m_fileOpened) {
     
    586576    // Notably, this will affect a name suggested in "File Save As".
    587577
    588     client()->didReceiveResponseAsync(this, WTFMove(response));
     578    didReceiveResponse(WTFMove(response));
    589579}
    590580
     
    609599    }
    610600
    611     client()->didReceiveResponseAsync(this, WTFMove(response));
     601    didReceiveResponse(WTFMove(response));
    612602}
    613603
  • trunk/Source/WebCore/platform/network/PingHandle.h

    r223271 r223408  
    4040    WTF_MAKE_NONCOPYABLE(PingHandle); WTF_MAKE_FAST_ALLOCATED;
    4141public:
    42     PingHandle(NetworkingContext* networkingContext, const ResourceRequest& request, bool shouldUseCredentialStorage, bool shouldFollowRedirects, WTF::CompletionHandler<void(const ResourceError&, const ResourceResponse&)>&& completionHandler)
     42    enum class UsesAsyncCallbacks {
     43        Yes,
     44        No,
     45    };
     46   
     47    PingHandle(NetworkingContext* networkingContext, const ResourceRequest& request, bool shouldUseCredentialStorage, UsesAsyncCallbacks useAsyncCallbacks, bool shouldFollowRedirects, WTF::CompletionHandler<void(const ResourceError&, const ResourceResponse&)>&& completionHandler)
    4348        : m_currentRequest(request)
    4449        , m_timeoutTimer(*this, &PingHandle::timeoutTimerFired)
    4550        , m_shouldUseCredentialStorage(shouldUseCredentialStorage)
    4651        , m_shouldFollowRedirects(shouldFollowRedirects)
     52        , m_usesAsyncCallbacks(useAsyncCallbacks)
    4753        , m_completionHandler(WTFMove(completionHandler))
    4854    {
     
    5561
    5662private:
    57     void willSendRequestAsync(ResourceHandle*, ResourceRequest&& request, ResourceResponse&&) final
     63    ResourceRequest willSendRequest(ResourceHandle*, ResourceRequest&& request, ResourceResponse&&) final
     64    {
     65        return m_shouldFollowRedirects ? request : ResourceRequest();
     66    }
     67    void willSendRequestAsync(ResourceHandle* handle, ResourceRequest&& request, ResourceResponse&&) final
    5868    {
    5969        m_currentRequest = WTFMove(request);
    6070        if (m_shouldFollowRedirects) {
    61             m_handle->continueWillSendRequest(ResourceRequest { m_currentRequest });
     71            handle->continueWillSendRequest(ResourceRequest { m_currentRequest });
    6272            return;
    6373        }
    64         m_handle->continueWillSendRequest({ });
    6574        pingLoadComplete(ResourceError { String(), 0, m_currentRequest.url(), ASCIILiteral("Not allowed to follow redirects"), ResourceError::Type::AccessControl });
    6675    }
    67     void didReceiveResponseAsync(ResourceHandle*, ResourceResponse&& response) final
    68     {
    69         m_handle->continueDidReceiveResponse();
    70         pingLoadComplete({ }, response);
    71     }
     76    void didReceiveResponse(ResourceHandle*, ResourceResponse&& response) final { pingLoadComplete({ }, response); }
    7277    void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int) final { pingLoadComplete(); }
    7378    void didFinishLoading(ResourceHandle*) final { pingLoadComplete(); }
    7479    void didFail(ResourceHandle*, const ResourceError& error) final { pingLoadComplete(error); }
    7580    bool shouldUseCredentialStorage(ResourceHandle*) final { return m_shouldUseCredentialStorage; }
     81    bool usesAsyncCallbacks() final { return m_usesAsyncCallbacks == UsesAsyncCallbacks::Yes; }
    7682    void timeoutTimerFired() { pingLoadComplete(ResourceError { String(), 0, m_currentRequest.url(), ASCIILiteral("Load timed out"), ResourceError::Type::Timeout }); }
    77 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    78     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&)
    79     {
    80         m_handle->continueCanAuthenticateAgainstProtectionSpace(false);
    81         delete this;
    82     }
    83 #endif
    8483
    8584    void pingLoadComplete(const ResourceError& error = { }, const ResourceResponse& response = { })
     
    105104    bool m_shouldUseCredentialStorage;
    106105    bool m_shouldFollowRedirects;
     106    UsesAsyncCallbacks m_usesAsyncCallbacks;
    107107    WTF::CompletionHandler<void(const ResourceError&, const ResourceResponse&)> m_completionHandler;
    108108};
  • trunk/Source/WebCore/platform/network/ResourceHandle.cpp

    r223271 r223408  
    160160            String message = "Cancelled load from '" + url.stringCenterEllipsizedToLength() + "' because it is using HTTP/0.9.";
    161161            d->m_client->didFail(this, { String(), 0, url, message });
    162             continueDidReceiveResponse();
    163162            return;
    164163        }
    165164    }
    166     client()->didReceiveResponseAsync(this, WTFMove(response));
     165    if (d->m_usesAsyncCallbacks)
     166        d->m_client->didReceiveResponseAsync(this, WTFMove(response));
     167    else {
     168        d->m_client->didReceiveResponse(this, WTFMove(response));
     169        platformContinueSynchronousDidReceiveResponse();
     170    }
    167171}
    168172
     
    241245}
    242246
     247bool ResourceHandle::usesAsyncCallbacks() const
     248{
     249    return d->m_usesAsyncCallbacks;
     250}
     251
    243252} // namespace WebCore
  • trunk/Source/WebCore/platform/network/ResourceHandle.h

    r223271 r223408  
    7171namespace WTF {
    7272class SchedulePair;
    73 template<typename T> class MessageQueue;
    7473}
    7574
     
    127126#if PLATFORM(COCOA) && !USE(CFURLCONNECTION)
    128127    WEBCORE_EXPORT NSURLConnection *connection() const;
    129     id makeDelegate(bool, WTF::MessageQueue<WTF::Function<void()>>*);
     128    id makeDelegate(bool);
    130129    id delegate();
    131130    void releaseDelegate();
     
    239238    ResourceHandle(NetworkingContext*, const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff);
    240239
     240    bool usesAsyncCallbacks() const;
     241
    241242private:
    242243    enum FailureType {
     
    267268
    268269#if USE(CFURLCONNECTION)
    269     void createCFURLConnection(bool shouldUseCredentialStorage, bool shouldContentSniff, WTF::MessageQueue<WTF::Function<void()>>*, CFDictionaryRef clientProperties);
     270    void createCFURLConnection(bool shouldUseCredentialStorage, bool shouldContentSniff, SchedulingBehavior, CFDictionaryRef clientProperties);
    270271#endif
    271272
  • trunk/Source/WebCore/platform/network/ResourceHandleClient.cpp

    r223271 r223408  
    4040{
    4141}
     42   
     43ResourceRequest ResourceHandleClient::willSendRequest(ResourceHandle*, ResourceRequest&& request, ResourceResponse&&)
     44{
     45    return WTFMove(request);
     46}
     47
     48void ResourceHandleClient::willSendRequestAsync(ResourceHandle* handle, ResourceRequest&& request, ResourceResponse&& /*redirectResponse*/)
     49{
     50    handle->continueWillSendRequest(WTFMove(request));
     51}
     52
     53void ResourceHandleClient::didReceiveResponseAsync(ResourceHandle* handle, ResourceResponse&&)
     54{
     55    handle->continueDidReceiveResponse();
     56}
     57
     58#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     59void ResourceHandleClient::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle* handle, const ProtectionSpace&)
     60{
     61    handle->continueCanAuthenticateAgainstProtectionSpace(false);
     62}
     63#endif
    4264
    4365#if USE(CFURLCONNECTION)
  • trunk/Source/WebCore/platform/network/ResourceHandleClient.h

    r223271 r223408  
    6464    WEBCORE_EXPORT virtual ~ResourceHandleClient();
    6565
     66    WEBCORE_EXPORT virtual ResourceRequest willSendRequest(ResourceHandle*, ResourceRequest&&, ResourceResponse&&);
    6667    virtual void didSendData(ResourceHandle*, unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/) { }
    6768
     69    virtual void didReceiveResponse(ResourceHandle*, ResourceResponse&&) { }
     70   
    6871    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int /*encodedDataLength*/) { }
    6972    WEBCORE_EXPORT virtual void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int encodedDataLength);
     
    7477    virtual void cannotShowURL(ResourceHandle*) { }
    7578
     79    virtual bool usesAsyncCallbacks() { return false; }
     80
    7681    virtual bool loadingSynchronousXHR() { return false; }
    7782
    7883    // Client will pass an updated request using ResourceHandle::continueWillSendRequest() when ready.
    79     WEBCORE_EXPORT virtual void willSendRequestAsync(ResourceHandle*, ResourceRequest&&, ResourceResponse&&) = 0;
     84    WEBCORE_EXPORT virtual void willSendRequestAsync(ResourceHandle*, ResourceRequest&&, ResourceResponse&&);
    8085
    8186    // Client will call ResourceHandle::continueDidReceiveResponse() when ready.
    82     WEBCORE_EXPORT virtual void didReceiveResponseAsync(ResourceHandle*, ResourceResponse&&) = 0;
     87    WEBCORE_EXPORT virtual void didReceiveResponseAsync(ResourceHandle*, ResourceResponse&&);
    8388
    8489#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    8590    // Client will pass an updated request using ResourceHandle::continueCanAuthenticateAgainstProtectionSpace() when ready.
    86     WEBCORE_EXPORT virtual void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&) = 0;
     91    WEBCORE_EXPORT virtual void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&);
    8792#endif
    8893    // Client will pass an updated request using ResourceHandle::continueWillCacheResponse() when ready.
     
    99104    virtual bool shouldUseCredentialStorage(ResourceHandle*) { return false; }
    100105    virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
     106#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     107    virtual bool canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace&) { return false; }
     108#endif
    101109    virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge&) { }
    102110
  • trunk/Source/WebCore/platform/network/ResourceHandleInternal.h

    r223271 r223408  
    8181        , m_defersLoading(defersLoading)
    8282        , m_shouldContentSniff(shouldContentSniff)
     83        , m_usesAsyncCallbacks(client && client->usesAsyncCallbacks())
    8384#if USE(CFURLCONNECTION)
    8485        , m_currentRequest(request)
     
    115116    bool m_defersLoading;
    116117    bool m_shouldContentSniff;
     118    bool m_usesAsyncCallbacks;
    117119#if USE(CFURLCONNECTION)
    118120    RetainPtr<CFURLConnectionRef> m_connection;
  • trunk/Source/WebCore/platform/network/SynchronousLoaderClient.cpp

    r223271 r223408  
    3737}
    3838
    39 void SynchronousLoaderClient::willSendRequestAsync(ResourceHandle* handle, ResourceRequest&& request, ResourceResponse&&)
     39ResourceRequest SynchronousLoaderClient::willSendRequest(ResourceHandle* handle, ResourceRequest&& request, ResourceResponse&&)
    4040{
    4141    // FIXME: This needs to be fixed to follow the redirect correctly even for cross-domain requests.
    42     if (protocolHostAndPortAreEqual(handle->firstRequest().url(), request.url())) {
    43         handle->continueWillSendRequest(WTFMove(request));
    44         return;
    45     }
     42    if (protocolHostAndPortAreEqual(handle->firstRequest().url(), request.url()))
     43        return WTFMove(request);
    4644
    4745    ASSERT(m_error.isNull());
    4846    m_error = platformBadResponseError();
    49     handle->continueWillSendRequest({ });
     47    m_isDone = true;
     48    return { };
    5049}
    5150
     
    5756
    5857#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    59 void SynchronousLoaderClient::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle* handle, const ProtectionSpace&)
     58bool SynchronousLoaderClient::canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace&)
    6059{
    6160    // FIXME: We should ask FrameLoaderClient. <http://webkit.org/b/65196>
    62     handle->continueCanAuthenticateAgainstProtectionSpace(true);
     61    return true;
    6362}
    6463#endif
    6564
    66 void SynchronousLoaderClient::didReceiveResponseAsync(ResourceHandle* handle, ResourceResponse&& response)
     65void SynchronousLoaderClient::didReceiveResponse(ResourceHandle*, ResourceResponse&& response)
    6766{
    6867    m_response = WTFMove(response);
    69     handle->continueDidReceiveResponse();
    7068}
    7169
     
    7775void SynchronousLoaderClient::didFinishLoading(ResourceHandle*)
    7876{
    79     m_messageQueue.kill();
     77    m_isDone = true;
    8078}
    8179
     
    8583
    8684    m_error = error;
    87    
    88     m_messageQueue.kill();
     85    m_isDone = true;
    8986}
    9087
  • trunk/Source/WebCore/platform/network/SynchronousLoaderClient.h

    r223271 r223408  
    2424 */
    2525
    26 #pragma once
     26#ifndef SynchronousLoaderClient_h
     27#define SynchronousLoaderClient_h
    2728
    2829#include "ResourceError.h"
    2930#include "ResourceHandleClient.h"
    3031#include "ResourceResponse.h"
    31 #include <wtf/Function.h>
    32 #include <wtf/MessageQueue.h>
    3332
    3433namespace WebCore {
     
    4241    Vector<char>& mutableData() { return m_data; }
    4342    const ResourceError& error() const { return m_error; }
    44     MessageQueue<Function<void()>>& messageQueue() { return m_messageQueue; }
     43    bool isDone() { return m_isDone; }
    4544
    4645    WEBCORE_EXPORT static ResourceError platformBadResponseError();
    4746
    4847private:
    49     void willSendRequestAsync(ResourceHandle*, ResourceRequest&&, ResourceResponse&&) override;
     48    ResourceRequest willSendRequest(ResourceHandle*, ResourceRequest&&, ResourceResponse&&) override;
    5049    bool shouldUseCredentialStorage(ResourceHandle*) override;
    5150    void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) override;
    52     void didReceiveResponseAsync(ResourceHandle*, ResourceResponse&&) override;
     51    void didReceiveResponse(ResourceHandle*, ResourceResponse&&) override;
    5352    void didReceiveData(ResourceHandle*, const char*, unsigned, int /*encodedDataLength*/) override;
    5453    void didFinishLoading(ResourceHandle*) override;
    5554    void didFail(ResourceHandle*, const ResourceError&) override;
    5655#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    57     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&) override;
     56    bool canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace&) override;
    5857#endif
    5958
     
    6261    Vector<char> m_data;
    6362    ResourceError m_error;
    64     MessageQueue<Function<void()>> m_messageQueue;
     63    bool m_isDone { false };
    6564};
    6665}
     66
     67#endif // SynchronousLoaderClient_h
  • trunk/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp

    r223271 r223408  
    6060};
    6161
    62 #if COMPILER(CLANG)
    63 #pragma clang diagnostic push
    64 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
    65 #endif
    6662DECLARE_CF_TYPE_TRAIT(CFHTTPCookie);
    67 #if COMPILER(CLANG)
    68 #pragma clang diagnostic pop
    69 #endif
    7063
    7164#undef DECLARE_CF_TYPE_TRAIT
  • trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp

    r223271 r223408  
    304304
    305305    if (kCFCompareEqualTo == CFStringCompare(propertyName, formDataPointerPropertyName, 0)) {
    306         long long formDataAsNumber = static_cast<long long>(reinterpret_cast<intptr_t>(form->formData.get()));
    307         return CFNumberCreate(0, kCFNumberLongLongType, &formDataAsNumber);
     306        long formDataAsNumber = static_cast<long>(reinterpret_cast<intptr_t>(form->formData.get()));
     307        return CFNumberCreate(0, kCFNumberLongType, &formDataAsNumber);
    308308    }
    309309
  • trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp

    r223271 r223408  
    4040#include "NetworkingContext.h"
    4141#include "ResourceError.h"
    42 #include "ResourceHandleCFURLConnectionDelegateWithOperationQueue.h"
    4342#include "ResourceHandleClient.h"
    4443#include "ResourceResponse.h"
    4544#include "SharedBuffer.h"
    4645#include "SynchronousLoaderClient.h"
     46#include "SynchronousResourceHandleCFURLConnectionDelegate.h"
    4747#include <CFNetwork/CFNetwork.h>
    4848#include <pal/spi/cf/CFNetworkSPI.h>
     
    127127}
    128128
    129 void ResourceHandle::createCFURLConnection(bool shouldUseCredentialStorage, bool shouldContentSniff, MessageQueue<Function<void()>>* messageQueue, CFDictionaryRef clientProperties)
     129void ResourceHandle::createCFURLConnection(bool shouldUseCredentialStorage, bool shouldContentSniff, SchedulingBehavior schedulingBehavior, CFDictionaryRef clientProperties)
    130130{
    131131    if ((!d->m_user.isEmpty() || !d->m_pass.isEmpty()) && !firstRequest().url().protocolIsInHTTPFamily()) {
     
    204204    }
    205205
     206    if (schedulingBehavior == SchedulingBehavior::Synchronous) {
     207        // Synchronous requests should not be subject to regular connection count limit to avoid deadlocks.
     208        // If we are using all available connections for async requests, and make a sync request, then prior
     209        // requests may get stuck waiting for delegate calls while we are in nested run loop, and the sync
     210        // request won't start because there are no available connections.
     211        // Connections are grouped by their socket stream properties, with each group having a separate count.
     212        CFDictionarySetValue(streamProperties, CFSTR("_WebKitSynchronousRequest"), kCFBooleanTrue);
     213    }
     214
    206215#if PLATFORM(COCOA)
    207216    RetainPtr<CFDataRef> sourceApplicationAuditData = d->m_context->sourceApplicationAuditData();
     
    229238    CFRelease(streamProperties);
    230239
    231     d->m_connectionDelegate = adoptRef(new ResourceHandleCFURLConnectionDelegateWithOperationQueue(this, messageQueue));
     240#if PLATFORM(COCOA)
     241    if (d->m_usesAsyncCallbacks)
     242        d->m_connectionDelegate = adoptRef(new ResourceHandleCFURLConnectionDelegateWithOperationQueue(this));
     243    else
     244        d->m_connectionDelegate = adoptRef(new SynchronousResourceHandleCFURLConnectionDelegate(this));
     245#else
     246    d->m_connectionDelegate = adoptRef(new SynchronousResourceHandleCFURLConnectionDelegate(this));
     247#endif
    232248    d->m_connectionDelegate->setupRequest(request.get());
    233249
     
    260276#endif
    261277
    262     createCFURLConnection(shouldUseCredentialStorage, d->m_shouldContentSniff, nullptr, client()->connectionProperties(this).get());
    263     ref();
     278    SchedulingBehavior schedulingBehavior = client()->loadingSynchronousXHR() ? SchedulingBehavior::Synchronous : SchedulingBehavior::Asynchronous;
     279
     280    createCFURLConnection(shouldUseCredentialStorage, d->m_shouldContentSniff, schedulingBehavior, client()->connectionProperties(this).get());
    264281
    265282    d->m_connectionDelegate->setupConnectionScheduling(d->m_connection.get());
     
    309326
    310327    Ref<ResourceHandle> protectedThis(*this);
    311     client()->willSendRequestAsync(this, WTFMove(request), WTFMove(redirectResponse));
    312     return { };
     328    if (d->m_usesAsyncCallbacks) {
     329        client()->willSendRequestAsync(this, WTFMove(request), WTFMove(redirectResponse));
     330        return { };
     331    }
     332   
     333    auto newRequest = client()->willSendRequest(this, WTFMove(request), WTFMove(redirectResponse));
     334
     335    // Client call may not preserve the session, especially if the request is sent over IPC.
     336    if (!newRequest.isNull()) {
     337        newRequest.setStorageSession(d->m_storageSession.get());
     338
     339        d->m_currentRequest = newRequest;
     340    }
     341    return newRequest;
    313342}
    314343
     
    316345{
    317346    LOG(Network, "CFNet - shouldUseCredentialStorage()");
    318     if (ResourceHandleClient* client = this->client())
     347    if (ResourceHandleClient* client = this->client()) {
     348        ASSERT(!d->m_usesAsyncCallbacks);
    319349        return client->shouldUseCredentialStorage(this);
     350    }
    320351    return false;
    321352}
     
    413444bool ResourceHandle::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
    414445{
    415     if (auto* client = this->client())
    416         client->canAuthenticateAgainstProtectionSpaceAsync(this, protectionSpace);
    417     else
    418         continueCanAuthenticateAgainstProtectionSpace(false);
    419     return false; // Ignored by caller.
     446    ResourceHandleClient* client = this->client();
     447    if (d->m_usesAsyncCallbacks) {
     448        if (client)
     449            client->canAuthenticateAgainstProtectionSpaceAsync(this, protectionSpace);
     450        else
     451            continueCanAuthenticateAgainstProtectionSpace(false);
     452        return false; // Ignored by caller.
     453    }
     454
     455    return client && client->canAuthenticateAgainstProtectionSpace(this, protectionSpace);
    420456}
    421457#endif
     
    539575}
    540576
    541 static void emptyPerform(void*)
    542 {
    543 }
    544 
    545577void ResourceHandle::platformLoadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentialsPolicy storedCredentialsPolicy, ResourceError& error, ResourceResponse& response, Vector<char>& data)
    546578{
     
    564596    }
    565597
    566     handle->ref();
    567     handle->createCFURLConnection(storedCredentialsPolicy == StoredCredentialsPolicy::Use, ResourceHandle::shouldContentSniffURL(request.url()), &client.messageQueue(), handle->client()->connectionProperties(handle.get()).get());
    568 
    569     static CFRunLoopRef runLoop = nullptr;
    570     if (!runLoop) {
    571         BinarySemaphore sem;
    572         Thread::create("CFNetwork Loader", [&] {
    573             runLoop = CFRunLoopGetCurrent();
    574 
    575             // Must add a source to the run loop to prevent CFRunLoopRun() from exiting.
    576             CFRunLoopSourceContext ctxt = { 0, (void*)1 /*must be non-null*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform };
    577             CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
    578             CFRunLoopAddSource(runLoop, bogusSource, kCFRunLoopDefaultMode);
    579             sem.signal();
    580 
    581             while (true)
    582                 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1E30, true);
    583         });
    584         sem.wait(TimeWithDynamicClockType(WallTime::infinity()));
    585     }
    586     CFURLConnectionScheduleWithRunLoop(handle->connection(), runLoop, kCFRunLoopDefaultMode);
    587     CFURLConnectionScheduleDownloadWithRunLoop(handle->connection(), runLoop, kCFRunLoopDefaultMode);
     598    handle->createCFURLConnection(storedCredentialsPolicy == StoredCredentialsPolicy::Use, ResourceHandle::shouldContentSniffURL(request.url()),
     599        SchedulingBehavior::Synchronous, handle->client()->connectionProperties(handle.get()).get());
     600
     601    CFURLConnectionScheduleWithRunLoop(handle->connection(), CFRunLoopGetCurrent(), synchronousLoadRunLoopMode());
     602    CFURLConnectionScheduleDownloadWithRunLoop(handle->connection(), CFRunLoopGetCurrent(), synchronousLoadRunLoopMode());
    588603    CFURLConnectionStart(handle->connection());
    589604
    590     do {
    591         if (auto task = client.messageQueue().waitForMessage())
    592             (*task)();
    593     } while (!client.messageQueue().killed());
     605    while (!client.isDone())
     606        CFRunLoopRunInMode(synchronousLoadRunLoopMode(), UINT_MAX, true);
    594607
    595608    error = client.error();
    596609
    597     if (handle->connection())
    598         CFURLConnectionCancel(handle->connection());
     610    CFURLConnectionCancel(handle->connection());
    599611
    600612    if (error.isNull())
  • trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp

    r223309 r223408  
    3232#include "AuthenticationChallenge.h"
    3333#include "Logging.h"
    34 #include "MIMETypeRegistry.h"
    3534#include "ResourceHandle.h"
    3635#include "ResourceHandleClient.h"
    3736#include "ResourceResponse.h"
    3837#include "SharedBuffer.h"
    39 #if !PLATFORM(WIN)
    4038#include "WebCoreURLResponse.h"
    41 #endif
    4239#include <pal/spi/cf/CFNetworkSPI.h>
    4340#include <wtf/MainThread.h>
    44 #include <wtf/Threading.h>
    4541#include <wtf/text/CString.h>
    4642#include <wtf/text/WTFString.h>
     
    4844namespace WebCore {
    4945
    50 ResourceHandleCFURLConnectionDelegateWithOperationQueue::ResourceHandleCFURLConnectionDelegateWithOperationQueue(ResourceHandle* handle, MessageQueue<Function<void()>>* messageQueue)
     46ResourceHandleCFURLConnectionDelegateWithOperationQueue::ResourceHandleCFURLConnectionDelegateWithOperationQueue(ResourceHandle* handle)
    5147    : ResourceHandleCFURLConnectionDelegate(handle)
    52     , m_messageQueue(messageQueue)
    53 {
     48    , m_queue(dispatch_queue_create("com.apple.WebCore/CFNetwork", DISPATCH_QUEUE_SERIAL))
     49    , m_semaphore(dispatch_semaphore_create(0))
     50{
     51    dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
     52    dispatch_set_target_queue(m_queue, backgroundQueue);
    5453}
    5554
    5655ResourceHandleCFURLConnectionDelegateWithOperationQueue::~ResourceHandleCFURLConnectionDelegateWithOperationQueue()
    5756{
     57    dispatch_release(m_semaphore);
     58    dispatch_release(m_queue);
    5859}
    5960
     
    6869    m_requestResult = nullptr;
    6970    m_cachedResponseResult = nullptr;
    70     m_semaphore.signal();
     71    m_boolResult = false;
     72    dispatch_semaphore_signal(m_semaphore);
    7173}
    7274
     
    8284}
    8385
    84 #if PLATFORM(WIN)
    85 LRESULT CALLBACK hookToRemoveCFNetworkMessage(int code, WPARAM wParam, LPARAM lParam)
    86 {
    87     MSG* msg = reinterpret_cast<MSG*>(lParam);
    88     // This message which CFNetwork sends to itself, will block the main thread, remove it.
    89     if (msg->message == WM_USER + 0xcf)
    90         msg->message = WM_NULL;
    91     return CallNextHookEx(nullptr, code, wParam, lParam);
    92 }
    93 
    94 static void installHookToRemoveCFNetworkMessageBlockingMainThread()
    95 {
    96     static HHOOK hook = nullptr;
    97     if (!hook) {
    98         DWORD threadID = ::GetCurrentThreadId();
    99         hook = ::SetWindowsHookExW(WH_GETMESSAGE, hookToRemoveCFNetworkMessage, 0, threadID);
    100     }
    101 }
    102 #endif
    103 
    104 static void emptyPerform(void*)
    105 {
    106 }
    107 
    108 static CFRunLoopRef getRunLoop()
    109 {
    110     static CFRunLoopRef runLoop = nullptr;
    111 
    112     if (!runLoop) {
    113         BinarySemaphore sem;
    114         Thread::create("CFNetwork Loader", [&] {
    115             runLoop = CFRunLoopGetCurrent();
    116 
    117             // Must add a source to the run loop to prevent CFRunLoopRun() from exiting.
    118             CFRunLoopSourceContext ctxt = { 0, (void*)1 /*must be non-null*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform };
    119             CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
    120             CFRunLoopAddSource(runLoop, bogusSource, kCFRunLoopDefaultMode);
    121             sem.signal();
    122 
    123             while (true)
    124                 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1E30, true);
    125         });
    126         sem.wait(TimeWithDynamicClockType(WallTime::infinity()));
    127     }
    128 
    129     return runLoop;
    130 }
    131 
    13286void ResourceHandleCFURLConnectionDelegateWithOperationQueue::setupConnectionScheduling(CFURLConnectionRef connection)
    13387{
    134 #if PLATFORM(WIN)
    135     installHookToRemoveCFNetworkMessageBlockingMainThread();
    136 #endif
    137     CFRunLoopRef runLoop = getRunLoop();
    138     CFURLConnectionScheduleWithRunLoop(connection, runLoop, kCFRunLoopDefaultMode);
    139     CFURLConnectionScheduleDownloadWithRunLoop(connection, runLoop, kCFRunLoopDefaultMode);
     88    CFURLConnectionSetDelegateDispatchQueue(connection, m_queue);
    14089}
    14190
     
    153102    ASSERT(!isMainThread());
    154103   
    155     auto work = [protectedThis = makeRef(*this), cfRequest = RetainPtr<CFURLRequestRef>(cfRequest), originalRedirectResponse = RetainPtr<CFURLResponseRef>(originalRedirectResponse)] () {
    156         auto& handle = protectedThis->m_handle;
     104    struct ProtectedParameters {
     105        Ref<ResourceHandleCFURLConnectionDelegateWithOperationQueue> protectedThis;
     106        RetainPtr<CFURLRequestRef> cfRequest;
     107        RetainPtr<CFURLResponseRef> originalRedirectResponse;
     108    };
     109   
     110    auto work = [] (void* context) {
     111        auto& parameters = *reinterpret_cast<ProtectedParameters*>(context);
     112        auto& protectedThis = parameters.protectedThis;
     113        auto& handle = protectedThis->m_handle;
     114        auto& cfRequest = parameters.cfRequest;
    157115       
    158116        if (!protectedThis->hasHandle()) {
     
    163121        LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::willSendRequest(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
    164122
    165         RetainPtr<CFURLResponseRef> redirectResponse = protectedThis->synthesizeRedirectResponseIfNecessary(cfRequest.get(), originalRedirectResponse.get());
     123        RetainPtr<CFURLResponseRef> redirectResponse = protectedThis->synthesizeRedirectResponseIfNecessary(cfRequest.get(), parameters.originalRedirectResponse.get());
    166124        ASSERT(redirectResponse);
    167125
     
    170128    };
    171129   
    172     if (m_messageQueue)
    173         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    174     else
    175         callOnMainThread(WTFMove(work));
    176     m_semaphore.wait(TimeWithDynamicClockType(WallTime::infinity()));
     130    ProtectedParameters parameters { makeRef(*this), cfRequest, originalRedirectResponse };
     131    dispatch_async_f(dispatch_get_main_queue(), &parameters, work);
     132    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
    177133
    178134    return m_requestResult.leakRef();
     
    181137void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveResponse(CFURLConnectionRef connection, CFURLResponseRef cfResponse)
    182138{
    183     auto work = [protectedThis = makeRef(*this), cfResponse = RetainPtr<CFURLResponseRef>(cfResponse), connection = RetainPtr<CFURLConnectionRef>(connection)] () {
    184         auto& handle = protectedThis->m_handle;
    185        
    186         if (!protectedThis->hasHandle() || !handle->client() || !handle->connection()) {
     139    struct ProtectedParameters {
     140        Ref<ResourceHandleCFURLConnectionDelegateWithOperationQueue> protectedThis;
     141        RetainPtr<CFURLConnectionRef> connection;
     142        RetainPtr<CFURLResponseRef> cfResponse;
     143    };
     144   
     145    auto work = [] (void* context) {
     146        auto& parameters = *reinterpret_cast<ProtectedParameters*>(context);
     147        auto& protectedThis = parameters.protectedThis;
     148        auto& handle = protectedThis->m_handle;
     149        auto& cfResponse = parameters.cfResponse;
     150       
     151        if (!protectedThis->hasHandle() || !handle->client()) {
    187152            protectedThis->continueDidReceiveResponse();
    188153            return;
     
    197162        if (statusCode != 304) {
    198163            bool isMainResourceLoad = handle->firstRequest().requester() == ResourceRequest::Requester::Main;
    199 #if !PLATFORM(WIN)
    200164            adjustMIMETypeIfNecessary(cfResponse.get(), isMainResourceLoad);
    201 #endif
    202165        }
    203166
     
    208171
    209172        ResourceResponse resourceResponse(cfResponse.get());
    210         resourceResponse.setSource(ResourceResponse::Source::Network);
    211 #if !PLATFORM(WIN)
    212         ResourceHandle::getConnectionTimingData(connection.get(), resourceResponse.deprecatedNetworkLoadMetrics());
    213 #endif
     173        ResourceHandle::getConnectionTimingData(parameters.connection.get(), resourceResponse.deprecatedNetworkLoadMetrics());
    214174
    215175        handle->didReceiveResponse(WTFMove(resourceResponse));
    216176    };
    217177
    218     if (m_messageQueue)
    219         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    220     else
    221         callOnMainThread(WTFMove(work));
    222     m_semaphore.wait(TimeWithDynamicClockType(WallTime::infinity()));
     178    ProtectedParameters parameters { makeRef(*this), connection, cfResponse };
     179    dispatch_async_f(dispatch_get_main_queue(), &parameters, work);
     180    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
    223181}
    224182
    225183void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveData(CFDataRef data, CFIndex originalLength)
    226184{
    227     auto work = [protectedThis = makeRef(*this), data = RetainPtr<CFDataRef>(data), originalLength = originalLength] () mutable {
     185    callOnMainThread([protectedThis = makeRef(*this), data = RetainPtr<CFDataRef>(data), originalLength = originalLength] () mutable {
     186        auto& handle = protectedThis->m_handle;
     187        if (!protectedThis->hasHandle() || !handle->client())
     188            return;
     189       
     190        LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveData(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
     191
     192        handle->client()->didReceiveBuffer(handle, SharedBuffer::create(data.get()), originalLength);
     193    });
     194}
     195
     196void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading()
     197{
     198    callOnMainThread([protectedThis = makeRef(*this)] () mutable {
     199        auto& handle = protectedThis->m_handle;
     200        if (!protectedThis->hasHandle() || !handle->client())
     201            return;
     202
     203        LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
     204
     205        handle->client()->didFinishLoading(handle);
     206    });
     207}
     208
     209void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFail(CFErrorRef error)
     210{
     211    callOnMainThread([protectedThis = makeRef(*this), error = RetainPtr<CFErrorRef>(error)] () mutable {
     212        auto& handle = protectedThis->m_handle;
     213        if (!protectedThis->hasHandle() || !handle->client())
     214            return;
     215       
     216        LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFail(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
     217
     218        handle->client()->didFail(handle, ResourceError(error.get()));
     219    });
     220}
     221
     222CFCachedURLResponseRef ResourceHandleCFURLConnectionDelegateWithOperationQueue::willCacheResponse(CFCachedURLResponseRef cachedResponse)
     223{
     224    struct ProtectedParameters {
     225        Ref<ResourceHandleCFURLConnectionDelegateWithOperationQueue> protectedThis;
     226        RetainPtr<CFCachedURLResponseRef> cachedResponse;
     227    };
     228   
     229    auto work = [] (void* context) {
     230        auto& parameters = *reinterpret_cast<ProtectedParameters*>(context);
     231        auto& protectedThis = parameters.protectedThis;
     232        auto& handle = protectedThis->m_handle;
     233       
     234        if (!protectedThis->hasHandle() || !handle->client()) {
     235            protectedThis->continueWillCacheResponse(nullptr);
     236            return;
     237        }
     238
     239        LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::willCacheResponse(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
     240
     241        handle->client()->willCacheResponseAsync(handle, parameters.cachedResponse.get());
     242    };
     243   
     244    ProtectedParameters parameters { makeRef(*this), cachedResponse };
     245    dispatch_async_f(dispatch_get_main_queue(), &parameters, work);
     246    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
     247    return m_cachedResponseResult.leakRef();
     248}
     249
     250void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveChallenge(CFURLAuthChallengeRef challenge)
     251{
     252    callOnMainThread([protectedThis = makeRef(*this), challenge = RetainPtr<CFURLAuthChallengeRef>(challenge)] () mutable {
     253        auto& handle = protectedThis->m_handle;
     254        if (!protectedThis->hasHandle())
     255            return;
     256       
     257        LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveChallenge(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
     258
     259        handle->didReceiveAuthenticationChallenge(AuthenticationChallenge(challenge.get(), handle));
     260    });
     261}
     262
     263void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didSendBodyData(CFIndex totalBytesWritten, CFIndex totalBytesExpectedToWrite)
     264{
     265    callOnMainThread([protectedThis = makeRef(*this), totalBytesWritten, totalBytesExpectedToWrite] () mutable {
    228266        auto& handle = protectedThis->m_handle;
    229267        if (!protectedThis->hasHandle() || !handle->client() || !handle->connection())
    230268            return;
    231        
    232         LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveData(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
    233 
    234         handle->client()->didReceiveBuffer(handle, SharedBuffer::create(data.get()), originalLength);
    235     };
    236    
    237     if (m_messageQueue)
    238         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    239     else
    240         callOnMainThread(WTFMove(work));
    241 }
    242 
    243 void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading()
    244 {
    245     auto work = [protectedThis = makeRef(*this)] () mutable {
    246         auto& handle = protectedThis->m_handle;
    247         if (!protectedThis->hasHandle() || !handle->client() || !handle->connection()) {
    248             protectedThis->m_handle->deref();
    249             return;
    250         }
    251 
    252         LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
    253 
    254         handle->client()->didFinishLoading(handle);
    255         if (protectedThis->m_messageQueue) {
    256             protectedThis->m_messageQueue->kill();
    257             protectedThis->m_messageQueue = nullptr;
    258         }
    259         protectedThis->m_handle->deref();
    260     };
    261    
    262     if (m_messageQueue)
    263         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    264     else
    265         callOnMainThread(WTFMove(work));
    266 }
    267 
    268 void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFail(CFErrorRef error)
    269 {
    270     auto work = [protectedThis = makeRef(*this), error = RetainPtr<CFErrorRef>(error)] () mutable {
    271         auto& handle = protectedThis->m_handle;
    272         if (!protectedThis->hasHandle() || !handle->client() || !handle->connection()) {
    273             protectedThis->m_handle->deref();
    274             return;
    275         }
    276        
    277         LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFail(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
    278 
    279         handle->client()->didFail(handle, ResourceError(error.get()));
    280         if (protectedThis->m_messageQueue) {
    281             protectedThis->m_messageQueue->kill();
    282             protectedThis->m_messageQueue = nullptr;
    283         }
    284         protectedThis->m_handle->deref();
    285     };
    286 
    287     if (m_messageQueue)
    288         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    289     else
    290         callOnMainThread(WTFMove(work));
    291 }
    292 
    293 CFCachedURLResponseRef ResourceHandleCFURLConnectionDelegateWithOperationQueue::willCacheResponse(CFCachedURLResponseRef cachedResponse)
    294 {
    295 #if PLATFORM(WIN)
    296     // Workaround for <rdar://problem/6300990> Caching does not respect Vary HTTP header.
    297     // FIXME: WebCore cache has issues with Vary, too (bug 58797, bug 71509).
    298     CFURLResponseRef wrappedResponse = CFCachedURLResponseGetWrappedResponse(cachedResponse);
    299     if (CFHTTPMessageRef httpResponse = CFURLResponseGetHTTPResponse(wrappedResponse)) {
    300         ASSERT(CFHTTPMessageIsHeaderComplete(httpResponse));
    301         RetainPtr<CFStringRef> varyValue = adoptCF(CFHTTPMessageCopyHeaderFieldValue(httpResponse, CFSTR("Vary")));
    302         if (varyValue)
    303             return nullptr;
    304     }
    305 #endif // PLATFORM(WIN)
    306 
    307     auto work = [protectedThis = makeRef(*this), cachedResponse = RetainPtr<CFCachedURLResponseRef>(cachedResponse)] () {
    308         auto& handle = protectedThis->m_handle;
    309        
    310         if (!protectedThis->hasHandle() || !handle->client() || !handle->connection()) {
    311             protectedThis->continueWillCacheResponse(nullptr);
    312             return;
    313         }
    314 
    315         LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::willCacheResponse(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
    316 
    317         handle->client()->willCacheResponseAsync(handle, cachedResponse.get());
    318     };
    319    
    320     if (m_messageQueue)
    321         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    322     else
    323         callOnMainThread(WTFMove(work));
    324     m_semaphore.wait(TimeWithDynamicClockType(WallTime::infinity()));
    325     return m_cachedResponseResult.leakRef();
    326 }
    327 
    328 void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveChallenge(CFURLAuthChallengeRef challenge)
    329 {
    330     auto work = [protectedThis = makeRef(*this), challenge = RetainPtr<CFURLAuthChallengeRef>(challenge)] () mutable {
    331         auto& handle = protectedThis->m_handle;
    332         if (!protectedThis->hasHandle())
    333             return;
    334        
    335         LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveChallenge(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
    336 
    337         handle->didReceiveAuthenticationChallenge(AuthenticationChallenge(challenge.get(), handle));
    338     };
    339 
    340     if (m_messageQueue)
    341         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    342     else
    343         callOnMainThread(WTFMove(work));
    344 }
    345 
    346 void ResourceHandleCFURLConnectionDelegateWithOperationQueue::didSendBodyData(CFIndex totalBytesWritten, CFIndex totalBytesExpectedToWrite)
    347 {
    348     auto work = [protectedThis = makeRef(*this), totalBytesWritten, totalBytesExpectedToWrite] () mutable {
    349         auto& handle = protectedThis->m_handle;
    350         if (!protectedThis->hasHandle() || !handle->client() || !handle->connection())
    351             return;
    352269
    353270        LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::didSendBodyData(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
    354271
    355272        handle->client()->didSendData(handle, totalBytesWritten, totalBytesExpectedToWrite);
    356     };
    357 
    358     if (m_messageQueue)
    359         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    360     else
    361         callOnMainThread(WTFMove(work));
     273    });
    362274}
    363275
    364276Boolean ResourceHandleCFURLConnectionDelegateWithOperationQueue::shouldUseCredentialStorage()
    365277{
    366     return false;
     278    return NO;
    367279}
    368280
     
    370282Boolean ResourceHandleCFURLConnectionDelegateWithOperationQueue::canRespondToProtectionSpace(CFURLProtectionSpaceRef protectionSpace)
    371283{
    372     auto work = [protectedThis = makeRef(*this), protectionSpace = RetainPtr<CFURLProtectionSpaceRef>(protectionSpace)] () mutable {
     284    struct ProtectedParameters {
     285        Ref<ResourceHandleCFURLConnectionDelegateWithOperationQueue> protectedThis;
     286        RetainPtr<CFURLProtectionSpaceRef> protectionSpace;
     287    };
     288   
     289    auto work = [] (void* context) {
     290        auto& parameters = *reinterpret_cast<ProtectedParameters*>(context);
     291        auto& protectedThis = parameters.protectedThis;
    373292        auto& handle = protectedThis->m_handle;
    374293       
     
    380299        LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::canRespondToProtectionSpace(handle=%p) (%s)", handle, handle->firstRequest().url().string().utf8().data());
    381300
    382         ProtectionSpace coreProtectionSpace = ProtectionSpace(protectionSpace.get());
     301        ProtectionSpace coreProtectionSpace = ProtectionSpace(parameters.protectionSpace.get());
    383302#if PLATFORM(IOS)
    384303        if (coreProtectionSpace.authenticationScheme() == ProtectionSpaceAuthenticationSchemeUnknown) {
     
    391310    };
    392311   
    393     if (m_messageQueue)
    394         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    395     else
    396         callOnMainThread(WTFMove(work));
    397     m_semaphore.wait(TimeWithDynamicClockType(WallTime::infinity()));
     312    ProtectedParameters parameters { makeRef(*this), protectionSpace };
     313    dispatch_async_f(dispatch_get_main_queue(), &parameters, work);
     314    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
    398315    return m_boolResult;
    399316}
    400 
     317#endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
     318
     319void ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueWillSendRequest(CFURLRequestRef request)
     320{
     321    m_requestResult = request;
     322    dispatch_semaphore_signal(m_semaphore);
     323}
     324
     325void ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueDidReceiveResponse()
     326{
     327    dispatch_semaphore_signal(m_semaphore);
     328}
     329
     330void ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueWillCacheResponse(CFCachedURLResponseRef response)
     331{
     332    m_cachedResponseResult = response;
     333    dispatch_semaphore_signal(m_semaphore);
     334}
     335
     336#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    401337void ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate)
    402338{
    403339    m_boolResult = canAuthenticate;
    404     m_semaphore.signal();
     340    dispatch_semaphore_signal(m_semaphore);
    405341}
    406342#endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
    407 
    408 void ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueWillSendRequest(CFURLRequestRef request)
    409 {
    410     m_requestResult = request;
    411     m_semaphore.signal();
    412 }
    413 
    414 void ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueDidReceiveResponse()
    415 {
    416     m_semaphore.signal();
    417 }
    418 
    419 void ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueWillCacheResponse(CFCachedURLResponseRef response)
    420 {
    421     m_cachedResponseResult = response;
    422     m_semaphore.signal();
    423 }
    424 
    425343} // namespace WebCore
    426344
  • trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.h

    r223271 r223408  
    3131#include <CFNetwork/CFNetwork.h>
    3232#include <dispatch/queue.h>
    33 #include <wtf/Function.h>
    34 #include <wtf/MessageQueue.h>
    35 #include <wtf/threads/BinarySemaphore.h>
     33#include <dispatch/semaphore.h>
    3634
    3735namespace WebCore {
     
    3937class ResourceHandleCFURLConnectionDelegateWithOperationQueue final : public ResourceHandleCFURLConnectionDelegate {
    4038public:
    41     ResourceHandleCFURLConnectionDelegateWithOperationQueue(ResourceHandle*, MessageQueue<Function<void()>>*);
     39    ResourceHandleCFURLConnectionDelegateWithOperationQueue(ResourceHandle*);
    4240    virtual ~ResourceHandleCFURLConnectionDelegateWithOperationQueue();
    4341
     
    5856    void didSendBodyData(CFIndex totalBytesWritten, CFIndex totalBytesExpectedToWrite) override;
    5957    Boolean shouldUseCredentialStorage() override;
     58#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     59    Boolean canRespondToProtectionSpace(CFURLProtectionSpaceRef) override;
     60#endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
    6061
    6162    void continueWillSendRequest(CFURLRequestRef) override;
     
    6364    void continueWillCacheResponse(CFCachedURLResponseRef) override;
    6465#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    65     Boolean canRespondToProtectionSpace(CFURLProtectionSpaceRef) override;
    6666    void continueCanAuthenticateAgainstProtectionSpace(bool) override;
    67 #endif
     67#endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
    6868
    69     BinarySemaphore m_semaphore;
    70     MessageQueue<Function<void()>>* m_messageQueue { nullptr };
     69    dispatch_queue_t m_queue;
     70    dispatch_semaphore_t m_semaphore;
    7171
    7272    RetainPtr<CFURLRequestRef> m_requestResult;
    7373    RetainPtr<CFCachedURLResponseRef> m_cachedResponseResult;
    74     bool m_boolResult { false };
     74    bool m_boolResult;
    7575};
    7676
  • trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp

    r223271 r223408  
    180180        CString utf8String = partition.utf8();
    181181        RetainPtr<CFStringRef> partitionValue = adoptCF(CFStringCreateWithBytes(0, reinterpret_cast<const UInt8*>(utf8String.data()), utf8String.length(), kCFStringEncodingUTF8, false));
    182         _CFURLRequestSetProtocolProperty(cfRequest, _kCFURLCachePartitionKey, partitionValue.get());
     182        _CFURLRequestSetProtocolProperty(cfRequest, kCFURLCachePartitionKey, partitionValue.get());
    183183    }
    184184#endif
     
    292292
    293293#if ENABLE(CACHE_PARTITIONING)
    294     RetainPtr<CFStringRef> cachePartition = adoptCF(static_cast<CFStringRef>(_CFURLRequestCopyProtocolPropertyForKey(m_cfRequest.get(), _kCFURLCachePartitionKey)));
     294    RetainPtr<CFStringRef> cachePartition = adoptCF(static_cast<CFStringRef>(_CFURLRequestCopyProtocolPropertyForKey(m_cfRequest.get(), kCFURLCachePartitionKey)));
    295295    if (cachePartition)
    296296        m_cachePartition = cachePartition.get();
  • trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.h

    r223407 r223408  
    11/*
    2  * Copyright (C) 2013 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2004-2013 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929
    3030#include "ResourceHandleCFURLConnectionDelegate.h"
    31 #include <CFNetwork/CFNetwork.h>
    32 #include <dispatch/queue.h>
    33 #include <wtf/Function.h>
    34 #include <wtf/MessageQueue.h>
    35 #include <wtf/threads/BinarySemaphore.h>
    3631
    3732namespace WebCore {
    3833
    39 class ResourceHandleCFURLConnectionDelegateWithOperationQueue final : public ResourceHandleCFURLConnectionDelegate {
     34class SynchronousResourceHandleCFURLConnectionDelegate final : public ResourceHandleCFURLConnectionDelegate {
    4035public:
    41     ResourceHandleCFURLConnectionDelegateWithOperationQueue(ResourceHandle*, MessageQueue<Function<void()>>*);
    42     virtual ~ResourceHandleCFURLConnectionDelegateWithOperationQueue();
     36    SynchronousResourceHandleCFURLConnectionDelegate(ResourceHandle*);
     37
     38    void didReceiveData(CFDataRef, CFIndex originalLength) override;
     39    void didFinishLoading() override;
     40    void didFail(CFErrorRef) override;
    4341
    4442private:
    45     bool hasHandle() const;
    46 
    4743    void setupRequest(CFMutableURLRequestRef) override;
    4844    void setupConnectionScheduling(CFURLConnectionRef) override;
    49     void releaseHandle() override;
    5045
    5146    CFURLRequestRef willSendRequest(CFURLRequestRef, CFURLResponseRef) override;
    5247    void didReceiveResponse(CFURLConnectionRef, CFURLResponseRef) override;
    53     void didReceiveData(CFDataRef, CFIndex originalLength) override;
    54     void didFinishLoading() override;
    55     void didFail(CFErrorRef) override;
    5648    CFCachedURLResponseRef willCacheResponse(CFCachedURLResponseRef) override;
    5749    void didReceiveChallenge(CFURLAuthChallengeRef) override;
    5850    void didSendBodyData(CFIndex totalBytesWritten, CFIndex totalBytesExpectedToWrite) override;
    5951    Boolean shouldUseCredentialStorage() override;
     52#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     53    Boolean canRespondToProtectionSpace(CFURLProtectionSpaceRef) override;
     54#endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
    6055
    6156    void continueWillSendRequest(CFURLRequestRef) override;
     
    6358    void continueWillCacheResponse(CFCachedURLResponseRef) override;
    6459#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    65     Boolean canRespondToProtectionSpace(CFURLProtectionSpaceRef) override;
    6660    void continueCanAuthenticateAgainstProtectionSpace(bool) override;
    67 #endif
    68 
    69     BinarySemaphore m_semaphore;
    70     MessageQueue<Function<void()>>* m_messageQueue { nullptr };
    71 
    72     RetainPtr<CFURLRequestRef> m_requestResult;
    73     RetainPtr<CFCachedURLResponseRef> m_cachedResponseResult;
    74     bool m_boolResult { false };
     61#endif // USE(PROTECTION_SPACE_AUTH_CALLBACK)
    7562};
    7663
  • trunk/Source/WebCore/platform/network/curl/MultipartHandle.cpp

    r223271 r223408  
    351351        response.setTextEncodingName(extractCharsetFromMediaType(contentType));
    352352
    353         m_resourceHandle->didReceiveResponse(WTFMove(response));
     353        d->client()->didReceiveResponse(m_resourceHandle, WTFMove(response));
    354354    }
    355355}
  • trunk/Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp

    r223271 r223408  
    277277{
    278278    ASSERT(isMainThread());
     279    ASSERT(!client() || client()->usesAsyncCallbacks());
    279280
    280281    if (d->m_delegate)
  • trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.cpp

    r223271 r223408  
    364364
    365365    ResourceResponse responseCopy = response();
    366     m_handle->client()->willSendRequestAsync(m_handle, WTFMove(newRequest), WTFMove(responseCopy));
     366    if (m_handle->client()->usesAsyncCallbacks())
     367        m_handle->client()->willSendRequestAsync(m_handle, WTFMove(newRequest), WTFMove(responseCopy));
     368    else {
     369        auto request = m_handle->client()->willSendRequest(m_handle, WTFMove(newRequest), WTFMove(responseCopy));
     370        continueAfterWillSendRequest(WTFMove(request));
     371    }
    367372}
    368373
     
    440445    if (base64) {
    441446        data = decodeURLEscapeSequences(data);
    442         m_handle->didReceiveResponse(WTFMove(response));
     447        m_handle->client()->didReceiveResponse(m_handle, WTFMove(response));
    443448
    444449        // didReceiveResponse might cause the client to be deleted.
     
    451456        TextEncoding encoding(charset);
    452457        data = decodeURLEscapeSequences(data, encoding);
    453         m_handle->didReceiveResponse(WTFMove(response));
     458        m_handle->client()->didReceiveResponse(m_handle, WTFMove(response));
    454459
    455460        // didReceiveResponse might cause the client to be deleted.
  • trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm

    r223271 r223408  
    4444@end
    4545
    46 #endif
    47 
    4846namespace WebCore {
    49 
    50 static NSArray *httpCookies(CFHTTPCookieStorageRef cookieStorage)
    51 {
    52     if (!cookieStorage)
    53         return [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
    54    
    55     auto cookies = adoptCF(CFHTTPCookieStorageCopyCookies(cookieStorage));
    56     return [NSHTTPCookie _cf2nsCookies:cookies.get()];
    57 }
    58 
    59 static void deleteHTTPCookie(CFHTTPCookieStorageRef cookieStorage, NSHTTPCookie *cookie)
    60 {
    61     if (!cookieStorage) {
    62         [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
    63         return;
    64     }
    65    
    66     CFHTTPCookieStorageDeleteCookie(cookieStorage, [cookie _GetInternalCFHTTPCookie]);
    67 }
    68 
    69 #if !USE(CFURLCONNECTION)
    7047
    7148static NSArray *httpCookiesForURL(CFHTTPCookieStorageRef cookieStorage, NSURL *firstParty, NSURL *url)
     
    204181}
    205182
     183static NSArray *httpCookies(CFHTTPCookieStorageRef cookieStorage)
     184{
     185    if (!cookieStorage)
     186        return [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
     187
     188    auto cookies = adoptCF(CFHTTPCookieStorageCopyCookies(cookieStorage));
     189    return [NSHTTPCookie _cf2nsCookies:cookies.get()];
     190}
     191
    206192static void setHTTPCookiesForURL(CFHTTPCookieStorageRef cookieStorage, NSArray *cookies, NSURL *url, NSURL *mainDocumentURL)
    207193{
     
    213199    auto cfCookies = adoptCF([NSHTTPCookie _ns2cfCookies:cookies]);
    214200    CFHTTPCookieStorageSetCookies(cookieStorage, cfCookies.get(), [url _cfurl], [mainDocumentURL _cfurl]);
     201}
     202
     203static void deleteHTTPCookie(CFHTTPCookieStorageRef cookieStorage, NSHTTPCookie *cookie)
     204{
     205    if (!cookieStorage) {
     206        [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
     207        return;
     208    }
     209
     210    CFHTTPCookieStorageDeleteCookie(cookieStorage, [cookie _GetInternalCFHTTPCookie]);
    215211}
    216212
     
    349345}
    350346
     347}
     348
    351349#endif // !USE(CFURLCONNECTION)
     350
     351namespace WebCore {
    352352
    353353void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& hostnames)
  • trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm

    r223271 r223408  
    4545#import "SubresourceLoader.h"
    4646#import "SynchronousLoaderClient.h"
     47#import "WebCoreResourceHandleAsDelegate.h"
    4748#import "WebCoreResourceHandleAsOperationQueueDelegate.h"
    4849#import "WebCoreURLResponse.h"
     
    248249#if !PLATFORM(IOS)
    249250    createNSURLConnection(
    250         ResourceHandle::makeDelegate(shouldUseCredentialStorage, nullptr),
     251        ResourceHandle::makeDelegate(shouldUseCredentialStorage),
    251252        shouldUseCredentialStorage,
    252253        d->m_shouldContentSniff || d->m_context->localFileContentSniffingEnabled(),
     
    254255#else
    255256    createNSURLConnection(
    256         ResourceHandle::makeDelegate(shouldUseCredentialStorage, nullptr),
     257        ResourceHandle::makeDelegate(shouldUseCredentialStorage),
    257258        shouldUseCredentialStorage,
    258259        d->m_shouldContentSniff || d->m_context->localFileContentSniffingEnabled(),
     
    261262#endif
    262263
    263     [connection() setDelegateQueue:operationQueueForAsyncClients()];
    264     [connection() start];
     264    bool scheduled = false;
     265    if (SchedulePairHashSet* scheduledPairs = d->m_context->scheduledRunLoopPairs()) {
     266        SchedulePairHashSet::iterator end = scheduledPairs->end();
     267        for (SchedulePairHashSet::iterator it = scheduledPairs->begin(); it != end; ++it) {
     268            if (NSRunLoop *runLoop = (*it)->nsRunLoop()) {
     269                [connection() scheduleInRunLoop:runLoop forMode:(NSString *)(*it)->mode()];
     270                scheduled = true;
     271            }
     272        }
     273    }
     274
     275    if (d->m_usesAsyncCallbacks) {
     276        ASSERT(!scheduled);
     277        [connection() setDelegateQueue:operationQueueForAsyncClients()];
     278        scheduled = true;
     279    }
     280#if PLATFORM(IOS)
     281    else {
     282        [connection() scheduleInRunLoop:WebThreadNSRunLoop() forMode:NSDefaultRunLoopMode];
     283        scheduled = true;
     284    }
     285#endif
     286
     287    // Start the connection if we did schedule with at least one runloop.
     288    // We can't start the connection until we have one runloop scheduled.
     289    if (scheduled)
     290        [connection() start];
     291    else
     292        d->m_startWhenScheduled = true;
    265293
    266294    LOG(Network, "Handle %p starting connection %p for %@", this, connection(), firstRequest().nsURLRequest(DoNotUpdateHTTPBody));
     
    303331        return;
    304332    [d->m_connection.get() scheduleInRunLoop:runLoop forMode:(NSString *)pair.mode()];
     333    if (d->m_startWhenScheduled) {
     334        [d->m_connection.get() start];
     335        d->m_startWhenScheduled = false;
     336    }
    305337}
    306338
     
    313345#endif
    314346
    315 id ResourceHandle::makeDelegate(bool shouldUseCredentialStorage, MessageQueue<Function<void()>>* queue)
     347id ResourceHandle::makeDelegate(bool shouldUseCredentialStorage)
    316348{
    317349    ASSERT(!d->m_delegate);
    318350
    319351    id <NSURLConnectionDelegate> delegate;
    320     if (shouldUseCredentialStorage)
    321         delegate = [[WebCoreResourceHandleAsOperationQueueDelegate alloc] initWithHandle:this messageQueue:queue];
    322     else
    323         delegate = [[WebCoreResourceHandleWithCredentialStorageAsOperationQueueDelegate alloc] initWithHandle:this messageQueue:queue];
     352    if (d->m_usesAsyncCallbacks) {
     353        if (shouldUseCredentialStorage)
     354            delegate = [[WebCoreResourceHandleAsOperationQueueDelegate alloc] initWithHandle:this];
     355        else
     356            delegate = [[WebCoreResourceHandleWithCredentialStorageAsOperationQueueDelegate alloc] initWithHandle:this];
     357    } else
     358        delegate = [[WebCoreResourceHandleAsDelegate alloc] initWithHandle:this];
    324359
    325360    d->m_delegate = delegate;
     
    332367{
    333368    if (!d->m_delegate)
    334         return makeDelegate(false, nullptr);
     369        return makeDelegate(false);
    335370    return d->m_delegate.get();
    336371}
     
    375410#if !PLATFORM(IOS)
    376411    handle->createNSURLConnection(
    377         handle->makeDelegate(shouldUseCredentialStorage, &client.messageQueue()),
     412        handle->makeDelegate(shouldUseCredentialStorage),
    378413        shouldUseCredentialStorage,
    379414        handle->shouldContentSniff() || context->localFileContentSniffingEnabled(),
     
    381416#else
    382417    handle->createNSURLConnection(
    383         handle->makeDelegate(shouldUseCredentialStorage, &client.messageQueue()), // A synchronous request cannot turn into a download, so there is no need to proxy the delegate.
     418        handle->makeDelegate(shouldUseCredentialStorage), // A synchronous request cannot turn into a download, so there is no need to proxy the delegate.
    384419        shouldUseCredentialStorage,
    385420        handle->shouldContentSniff() || (context && context->localFileContentSniffingEnabled()),
     
    388423#endif
    389424
    390     [handle->connection() setDelegateQueue:operationQueueForAsyncClients()];
     425    [handle->connection() scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:(NSString *)synchronousLoadRunLoopMode()];
    391426    [handle->connection() start];
    392427   
    393     do {
    394         if (auto task = client.messageQueue().waitForMessage())
    395             (*task)();
    396     } while (!client.messageQueue().killed());
     428    while (!client.isDone())
     429        [[NSRunLoop currentRunLoop] runMode:(NSString *)synchronousLoadRunLoopMode() beforeDate:[NSDate distantFuture]];
    397430
    398431    error = client.error();
     
    454487    }
    455488
    456     client()->willSendRequestAsync(this, WTFMove(request), WTFMove(redirectResponse));
    457     return { };
     489    if (d->m_usesAsyncCallbacks) {
     490        client()->willSendRequestAsync(this, WTFMove(request), WTFMove(redirectResponse));
     491        return { };
     492    }
     493
     494    Ref<ResourceHandle> protectedThis(*this);
     495    auto newRequest = client()->willSendRequest(this, WTFMove(request), WTFMove(redirectResponse));
     496
     497    // Client call may not preserve the session, especially if the request is sent over IPC.
     498    if (!newRequest.isNull())
     499        newRequest.setStorageSession(d->m_storageSession.get());
     500    return newRequest;
    458501}
    459502
    460503void ResourceHandle::continueWillSendRequest(ResourceRequest&& newRequest)
    461504{
     505    ASSERT(d->m_usesAsyncCallbacks);
     506
    462507    // Client call may not preserve the session, especially if the request is sent over IPC.
    463508    if (!newRequest.isNull())
     
    468513void ResourceHandle::continueDidReceiveResponse()
    469514{
     515    ASSERT(d->m_usesAsyncCallbacks);
     516
    470517    [delegate() continueDidReceiveResponse];
     518}
     519
     520bool ResourceHandle::shouldUseCredentialStorage()
     521{
     522    ASSERT(!d->m_usesAsyncCallbacks);
     523    return client() && client()->shouldUseCredentialStorage(this);
    471524}
    472525
     
    566619bool ResourceHandle::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
    567620{
    568     if (ResourceHandleClient* client = this->client())
    569         client->canAuthenticateAgainstProtectionSpaceAsync(this, protectionSpace);
    570     else
    571         continueCanAuthenticateAgainstProtectionSpace(false);
    572     return false; // Ignored by caller.
     621    ResourceHandleClient* client = this->client();
     622    if (d->m_usesAsyncCallbacks) {
     623        if (client)
     624            client->canAuthenticateAgainstProtectionSpaceAsync(this, protectionSpace);
     625        else
     626            continueCanAuthenticateAgainstProtectionSpace(false);
     627        return false; // Ignored by caller.
     628    }
     629
     630    return client && client->canAuthenticateAgainstProtectionSpace(this, protectionSpace);
    573631}
    574632
    575633void ResourceHandle::continueCanAuthenticateAgainstProtectionSpace(bool result)
    576634{
     635    ASSERT(d->m_usesAsyncCallbacks);
     636
    577637    [(id)delegate() continueCanAuthenticateAgainstProtectionSpace:result];
    578638}
     
    660720void ResourceHandle::continueWillCacheResponse(NSCachedURLResponse *response)
    661721{
     722    ASSERT(d->m_usesAsyncCallbacks);
     723
    662724    [(id)delegate() continueWillCacheResponse:response];
    663725}
  • trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.h

    r223407 r223408  
    2424 */
    2525
    26 #include "config.h"
    27 #include "ResourceHandleClient.h"
    28 
    29 #include "ResourceHandle.h"
    30 #include "ResourceRequest.h"
    31 #include "SharedBuffer.h"
     26#pragma once
    3227
    3328namespace WebCore {
    34 
    35 ResourceHandleClient::ResourceHandleClient()
    36 {
     29class ResourceHandle;
    3730}
    3831
    39 ResourceHandleClient::~ResourceHandleClient()
    40 {
     32@protocol WebCoreResourceLoaderDelegate
     33- (void)detachHandle;
     34@end
     35
     36#if !USE(CFURLCONNECTION)
     37
     38@interface WebCoreResourceHandleAsDelegate : NSObject <NSURLConnectionDelegate, WebCoreResourceLoaderDelegate> {
     39    WebCore::ResourceHandle* m_handle;
    4140}
     41- (id)initWithHandle:(WebCore::ResourceHandle*)handle;
     42@end
    4243
    43 #if USE(CFURLCONNECTION)
    44 void ResourceHandleClient::willCacheResponseAsync(ResourceHandle* handle, CFCachedURLResponseRef response)
    45 {
    46     handle->continueWillCacheResponse(response);
    47 }
    48 #elif PLATFORM(COCOA)
    49 void ResourceHandleClient::willCacheResponseAsync(ResourceHandle* handle, NSCachedURLResponse *response)
    50 {
    51     handle->continueWillCacheResponse(response);
    52 }
    53 #endif
    54 
    55 void ResourceHandleClient::didReceiveBuffer(ResourceHandle* handle, Ref<SharedBuffer>&& buffer, int encodedDataLength)
    56 {
    57     didReceiveData(handle, buffer->data(), buffer->size(), encodedDataLength);
    58 }
    59 
    60 }
     44#endif // !USE(CFURLCONNECTION)
  • trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h

    r223271 r223408  
    2828#if !USE(CFURLCONNECTION)
    2929
     30#include "WebCoreResourceHandleAsDelegate.h"
    3031#include <dispatch/dispatch.h>
    31 #include <wtf/Function.h>
    32 #include <wtf/MessageQueue.h>
    3332#include <wtf/RetainPtr.h>
    3433
     
    3736}
    3837
    39 @interface WebCoreResourceHandleAsOperationQueueDelegate : NSObject <NSURLConnectionDelegate> {
     38@interface WebCoreResourceHandleAsOperationQueueDelegate : NSObject <NSURLConnectionDelegate, WebCoreResourceLoaderDelegate> {
    4039    WebCore::ResourceHandle* m_handle;
    4140
    4241    // Synchronous delegates on operation queue wait until main thread sends an asynchronous response.
    4342    dispatch_semaphore_t m_semaphore;
    44     MessageQueue<Function<void()>>* m_messageQueue;
    4543    RetainPtr<NSURLRequest> m_requestResult;
    4644    RetainPtr<NSCachedURLResponse> m_cachedResponseResult;
     
    4846}
    4947
    50 - (void)detachHandle;
    51 - (id)initWithHandle:(WebCore::ResourceHandle*)handle messageQueue:(MessageQueue<Function<void()>>*)messageQueue;
     48- (id)initWithHandle:(WebCore::ResourceHandle*)handle;
    5249- (void)continueWillSendRequest:(NSURLRequest *)newRequest;
    5350- (void)continueDidReceiveResponse;
     51#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    5452- (void)continueCanAuthenticateAgainstProtectionSpace:(BOOL)canAuthenticate;
     53#endif
    5554- (void)continueWillCacheResponse:(NSCachedURLResponse *)response;
    5655@end
  • trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm

    r223271 r223408  
    3737#import "ResourceResponse.h"
    3838#import "SharedBuffer.h"
    39 #import "SynchronousLoaderClient.h"
    4039#import "WebCoreURLResponse.h"
    4140#import <pal/spi/cf/CFNetworkSPI.h>
     
    4645@implementation WebCoreResourceHandleAsOperationQueueDelegate
    4746
    48 - (id)initWithHandle:(ResourceHandle*)handle messageQueue:(MessageQueue<Function<void()>>*)messageQueue
     47- (id)initWithHandle:(ResourceHandle*)handle
    4948{
    5049    self = [self init];
     
    5453    m_handle = handle;
    5554    m_semaphore = dispatch_semaphore_create(0);
    56     m_messageQueue = messageQueue;
    5755
    5856    return self;
     
    116114#endif
    117115
    118     auto work = [self = self, protectedSelf = RetainPtr<id>(self), newRequest = RetainPtr<NSURLRequest>(newRequest), redirectResponse = RetainPtr<NSURLResponse>(redirectResponse)] () mutable {
     116    RetainPtr<id> protector(self);
     117
     118    dispatch_async(dispatch_get_main_queue(), ^{
    119119        if (!m_handle) {
    120120            m_requestResult = nullptr;
     
    123123        }
    124124
    125         m_handle->willSendRequest(newRequest.get(), redirectResponse.get());
    126     };
    127 
    128    
    129     if (m_messageQueue)
    130         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    131     else
    132         dispatch_async(dispatch_get_main_queue(), work);
     125        m_handle->willSendRequest(newRequest, redirectResponse);
     126    });
    133127
    134128    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
     
    143137    LOG(Network, "Handle %p delegate connection:%p didReceiveAuthenticationChallenge:%p", m_handle, connection, challenge);
    144138
    145     auto work = [self, protectedSelf = RetainPtr<id>(self), challenge = RetainPtr<NSURLAuthenticationChallenge>(challenge)] () mutable {
     139    dispatch_async(dispatch_get_main_queue(), ^{
    146140        if (!m_handle) {
    147             [[challenge sender] cancelAuthenticationChallenge:challenge.get()];
    148             return;
    149         }
    150         m_handle->didReceiveAuthenticationChallenge(core(challenge.get()));
    151     };
    152 
    153     if (m_messageQueue)
    154         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    155     else
    156         dispatch_async(dispatch_get_main_queue(), work);
    157 }
    158 
     141            [[challenge sender] cancelAuthenticationChallenge:challenge];
     142            return;
     143        }
     144        m_handle->didReceiveAuthenticationChallenge(core(challenge));
     145    });
     146}
     147
     148#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    159149- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
    160150{
     
    164154    LOG(Network, "Handle %p delegate connection:%p canAuthenticateAgainstProtectionSpace:%@://%@:%u realm:%@ method:%@ %@%@", m_handle, connection, [protectionSpace protocol], [protectionSpace host], [protectionSpace port], [protectionSpace realm], [protectionSpace authenticationMethod], [protectionSpace isProxy] ? @"proxy:" : @"", [protectionSpace isProxy] ? [protectionSpace proxyType] : @"");
    165155
    166     auto work = [self = self, protectedSelf = RetainPtr<id>(self), protectionSpace = RetainPtr<NSURLProtectionSpace>(protectionSpace)] () mutable {
     156    RetainPtr<id> protector(self);
     157
     158    dispatch_async(dispatch_get_main_queue(), ^{
    167159        if (!m_handle) {
    168160            m_boolResult = NO;
     
    170162            return;
    171163        }
    172         m_handle->canAuthenticateAgainstProtectionSpace(ProtectionSpace(protectionSpace.get()));
    173     };
    174 
    175     if (m_messageQueue)
    176         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    177     else
    178         dispatch_async(dispatch_get_main_queue(), work);
    179    
     164        m_handle->canAuthenticateAgainstProtectionSpace(ProtectionSpace(protectionSpace));
     165    });
     166
    180167    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
    181168    return m_boolResult;
    182169}
     170#endif
    183171
    184172- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)r
     
    188176    LOG(Network, "Handle %p delegate connection:%p didReceiveResponse:%p (HTTP status %d, reported MIMEType '%s')", m_handle, connection, r, [r respondsToSelector:@selector(statusCode)] ? [(id)r statusCode] : 0, [[r MIMEType] UTF8String]);
    189177
    190     auto work = [self = self, protectedSelf = RetainPtr<id>(self), r = RetainPtr<NSURLResponse>(r), connection = RetainPtr<NSURLConnection>(connection)] () mutable {
    191         RefPtr<ResourceHandle> protectedHandle(m_handle);
     178    RetainPtr<id> protector(self);
     179
     180    dispatch_async(dispatch_get_main_queue(), ^{
    192181        if (!m_handle || !m_handle->client()) {
    193182            dispatch_semaphore_signal(m_semaphore);
     
    205194            [r _setMIMEType:@"text/html"];
    206195
    207         ResourceResponse resourceResponse(r.get());
    208         resourceResponse.setSource(ResourceResponse::Source::Network);
    209         ResourceHandle::getConnectionTimingData(connection.get(), resourceResponse.deprecatedNetworkLoadMetrics());
     196        ResourceResponse resourceResponse(r);
     197        ResourceHandle::getConnectionTimingData(connection, resourceResponse.deprecatedNetworkLoadMetrics());
    210198
    211199        m_handle->didReceiveResponse(WTFMove(resourceResponse));
    212     };
    213 
    214     if (m_messageQueue)
    215         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    216     else
    217         dispatch_async(dispatch_get_main_queue(), work);
    218    
     200    });
     201
    219202    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
    220203}
     
    228211    LOG(Network, "Handle %p delegate connection:%p didReceiveData:%p lengthReceived:%lld", m_handle, connection, data, lengthReceived);
    229212
    230     auto work = [self = self, protectedSelf = RetainPtr<id>(self), data = RetainPtr<NSData>(data)] () mutable {
     213    dispatch_async(dispatch_get_main_queue(), ^{
    231214        if (!m_handle || !m_handle->client())
    232215            return;
     
    238221        // -1 means we do not provide any data about transfer size to inspector so it would use
    239222        // Content-Length headers or content size to show transfer size.
    240         m_handle->client()->didReceiveBuffer(m_handle, SharedBuffer::create(data.get()), -1);
    241     };
    242 
    243     if (m_messageQueue)
    244         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    245     else
    246         dispatch_async(dispatch_get_main_queue(), work);
     223        m_handle->client()->didReceiveBuffer(m_handle, SharedBuffer::create(data), -1);
     224    });
    247225}
    248226
     
    255233    LOG(Network, "Handle %p delegate connection:%p didSendBodyData:%d totalBytesWritten:%d totalBytesExpectedToWrite:%d", m_handle, connection, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
    256234
    257     auto work = [self = self, protectedSelf = RetainPtr<id>(self), totalBytesWritten = totalBytesWritten, totalBytesExpectedToWrite = totalBytesExpectedToWrite] () mutable {
     235    dispatch_async(dispatch_get_main_queue(), ^{
    258236        if (!m_handle || !m_handle->client())
    259237            return;
    260238        m_handle->client()->didSendData(m_handle, totalBytesWritten, totalBytesExpectedToWrite);
    261     };
    262 
    263     if (m_messageQueue)
    264         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    265     else
    266         dispatch_async(dispatch_get_main_queue(), work);
     239    });
    267240}
    268241
     
    274247    LOG(Network, "Handle %p delegate connectionDidFinishLoading:%p", m_handle, connection);
    275248
    276     auto task = [self = self, protectedSelf = RetainPtr<id>(self)] () mutable {
     249    dispatch_async(dispatch_get_main_queue(), ^{
    277250        if (!m_handle || !m_handle->client())
    278251            return;
    279252
    280253        m_handle->client()->didFinishLoading(m_handle);
    281         if (m_messageQueue) {
    282             m_messageQueue->kill();
    283             m_messageQueue = nullptr;
    284         }
    285     };
    286 
    287     if (m_messageQueue)
    288         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(task)));
    289     else
    290         dispatch_async(dispatch_get_main_queue(), task);
     254    });
    291255}
    292256
     
    298262    LOG(Network, "Handle %p delegate connection:%p didFailWithError:%@", m_handle, connection, error);
    299263
    300     auto work = [self = self, protectedSelf = RetainPtr<id>(self), error = RetainPtr<NSError>(error)] () mutable {
     264    dispatch_async(dispatch_get_main_queue(), ^{
    301265        if (!m_handle || !m_handle->client())
    302266            return;
    303267
    304         m_handle->client()->didFail(m_handle, error.get());
    305         if (m_messageQueue) {
    306             m_messageQueue->kill();
    307             m_messageQueue = nullptr;
    308         }
    309     };
    310 
    311     if (m_messageQueue)
    312         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    313     else
    314         dispatch_async(dispatch_get_main_queue(), work);
     268        m_handle->client()->didFail(m_handle, error);
     269    });
    315270}
    316271
     
    323278    LOG(Network, "Handle %p delegate connection:%p willCacheResponse:%p", m_handle, connection, cachedResponse);
    324279
    325     auto work = [self = self, protectedSelf = RetainPtr<id>(self), cachedResponse = RetainPtr<NSCachedURLResponse>(cachedResponse)] () mutable {
     280    RetainPtr<id> protector(self);
     281
     282    dispatch_async(dispatch_get_main_queue(), ^{
    326283        if (!m_handle || !m_handle->client()) {
    327284            m_cachedResponseResult = nullptr;
     
    330287        }
    331288
    332         m_handle->client()->willCacheResponseAsync(m_handle, cachedResponse.get());
    333     };
    334 
    335     if (m_messageQueue)
    336         m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    337     else
    338         dispatch_async(dispatch_get_main_queue(), work);
     289        m_handle->client()->willCacheResponseAsync(m_handle, cachedResponse);
     290    });
    339291
    340292    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
  • trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r223271 r223408  
    356356
    357357    ResourceResponse responseCopy = d->m_response;
    358     d->client()->willSendRequestAsync(handle, WTFMove(newRequest), WTFMove(responseCopy));
     358    if (d->client()->usesAsyncCallbacks())
     359        d->client()->willSendRequestAsync(handle, WTFMove(newRequest), WTFMove(responseCopy));
     360    else {
     361        auto request = d->client()->willSendRequest(handle, WTFMove(newRequest), WTFMove(responseCopy));
     362        continueAfterWillSendRequest(handle, WTFMove(request));
     363    }
     364
    359365}
    360366
     
    10291035void ResourceHandle::continueWillSendRequest(ResourceRequest&& request)
    10301036{
     1037    ASSERT(!client() || client()->usesAsyncCallbacks());
    10311038    continueAfterWillSendRequest(this, WTFMove(request));
    10321039}
     
    10341041void ResourceHandle::continueDidReceiveResponse()
    10351042{
     1043    ASSERT(!client() || client()->usesAsyncCallbacks());
    10361044    continueAfterDidReceiveResponse(this);
    10371045}
  • trunk/Source/WebKit/ChangeLog

    r223299 r223408  
     12017-10-16  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r223271.
     4
     5        This change introduced LayoutTest failures on WK1.
     6
     7        Reverted changeset:
     8
     9        "Use asynchronous ResourceHandleClient calls for WebKit1"
     10        https://bugs.webkit.org/show_bug.cgi?id=160677
     11        https://trac.webkit.org/changeset/223271
     12
    1132017-10-13  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/Source/WebKit/NetworkProcess/Downloads/BlobDownloadClient.cpp

    r223271 r223408  
    7272}
    7373
    74 void BlobDownloadClient::willSendRequestAsync(ResourceHandle*, ResourceRequest&&, ResourceResponse&&)
    75 {
    76     ASSERT_NOT_REACHED();
    77 }
    78 
    79 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    80 void BlobDownloadClient::canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&)
    81 {
    82     ASSERT_NOT_REACHED();
    83 }
    84 #endif
    85 
    8674void BlobDownloadClient::didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&& buffer, int)
    8775{
  • trunk/Source/WebKit/NetworkProcess/Downloads/BlobDownloadClient.h

    r223271 r223408  
    5050    void didFinishLoading(WebCore::ResourceHandle*) final;
    5151    void didFail(WebCore::ResourceHandle*, const WebCore::ResourceError&) final;
    52     void willSendRequestAsync(WebCore::ResourceHandle*, WebCore::ResourceRequest&&, WebCore::ResourceResponse&&) final;
    53 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    54     void canAuthenticateAgainstProtectionSpaceAsync(WebCore::ResourceHandle*, const WebCore::ProtectionSpace&) final;
    55 #endif
     52    bool usesAsyncCallbacks() final { return true; }
    5653
    5754    Download& m_download;
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r223271 r223408  
    252252
    253253    // PingHandle manages its own lifetime, deleting itself when its purpose has been fulfilled.
    254     new PingHandle(context.ptr(), loadParameters.request, loadParameters.storedCredentialsPolicy == StoredCredentialsPolicy::Use, loadParameters.shouldFollowRedirects, WTFMove(completionHandler));
     254    new PingHandle(context.ptr(), loadParameters.request, loadParameters.storedCredentialsPolicy == StoredCredentialsPolicy::Use, PingHandle::UsesAsyncCallbacks::Yes, loadParameters.shouldFollowRedirects, WTFMove(completionHandler));
    255255#endif
    256256}
  • trunk/Source/WebKit/NetworkProcess/NetworkLoad.h

    r223271 r223408  
    126126    void didReceiveAuthenticationChallenge(WebCore::ResourceHandle*, const WebCore::AuthenticationChallenge&) final;
    127127    void receivedCancellation(WebCore::ResourceHandle*, const WebCore::AuthenticationChallenge&) final;
     128    bool usesAsyncCallbacks() final { return true; }
    128129    bool loadingSynchronousXHR() final { return m_client.get().isSynchronous(); }
    129130#else
  • trunk/Source/WebKit/Shared/mac/ArgumentCodersMac.h

    r223271 r223408  
    2424 */
    2525
    26 #pragma once
     26#ifndef ArgumentCodersMac_h
     27#define ArgumentCodersMac_h
    2728
    28 #include <objc/objc.h>
    2929#include <wtf/RetainPtr.h>
    3030
     
    9494
    9595} // namespace IPC
     96
     97#endif // ArgumentCodersMac_h
  • trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm

    r223271 r223408  
    174174}
    175175
     176static RetainPtr<CFDictionaryRef> createSerializableRepresentation(NSURLRequest *request, CFTypeRef tokenNull)
     177{
     178    return createSerializableRepresentation([request _CFURLRequest], tokenNull);
     179}
     180
     181static RetainPtr<NSURLRequest> createNSURLRequestFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull)
     182{
     183    auto cfRequest = createCFURLRequestFromSerializableRepresentation(representation, tokenNull);
     184    if (!cfRequest)
     185        return nullptr;
     186
     187    return adoptNS([[NSURLRequest alloc] _initWithCFURLRequest:cfRequest.get()]);
     188}
     189
    176190#if USE(CFURLCONNECTION)
    177191void ArgumentCoder<ResourceRequest>::encodePlatformData(Encoder& encoder, const ResourceRequest& resourceRequest)
     
    204218    encoder.encodeEnum(resourceRequest.cachePolicy());
    205219}
    206 
    207220#else
    208 
    209 static RetainPtr<CFDictionaryRef> createSerializableRepresentation(NSURLRequest *request, CFTypeRef tokenNull)
    210 {
    211     return createSerializableRepresentation([request _CFURLRequest], tokenNull);
    212 }
    213 
    214 static RetainPtr<NSURLRequest> createNSURLRequestFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull)
    215 {
    216     auto cfRequest = createCFURLRequestFromSerializableRepresentation(representation, tokenNull);
    217     if (!cfRequest)
    218         return nullptr;
    219    
    220     return adoptNS([[NSURLRequest alloc] _initWithCFURLRequest:cfRequest.get()]);
    221 }
    222    
    223221void ArgumentCoder<ResourceRequest>::encodePlatformData(Encoder& encoder, const ResourceRequest& resourceRequest)
    224222{
  • trunk/Source/WebKitLegacy/ChangeLog

    r223271 r223408  
     12017-10-16  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r223271.
     4
     5        This change introduced LayoutTest failures on WK1.
     6
     7        Reverted changeset:
     8
     9        "Use asynchronous ResourceHandleClient calls for WebKit1"
     10        https://bugs.webkit.org/show_bug.cgi?id=160677
     11        https://trac.webkit.org/changeset/223271
     12
    1132017-10-12  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/Source/WebKitLegacy/WebCoreSupport/WebResourceLoadScheduler.cpp

    r223271 r223408  
    364364{
    365365    // PingHandle manages its own lifetime, deleting itself when its purpose has been fulfilled.
    366     new PingHandle(frame.loader().networkingContext(), request, options.credentials != FetchOptions::Credentials::Omit, options.redirect == FetchOptions::Redirect::Follow, WTFMove(completionHandler));
     366    new PingHandle(frame.loader().networkingContext(), request, options.credentials != FetchOptions::Credentials::Omit, PingHandle::UsesAsyncCallbacks::No, options.redirect == FetchOptions::Redirect::Follow, WTFMove(completionHandler));
    367367}
    368368
Note: See TracChangeset for help on using the changeset viewer.