WebItemProviderPasteboard should call its completion block immediately after a synchr...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jun 2017 19:34:37 +0000 (19:34 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jun 2017 19:34:37 +0000 (19:34 +0000)
commit833b332e555b3a26b082e77c3d3ff6002970c885
treeda276dd9cbdd9293a9c229e95676efbe3a90c9f1
parentb90d21939d2d5b208d4f93a6216c4e6da6371e12
WebItemProviderPasteboard should call its completion block immediately after a synchronous load
https://bugs.webkit.org/show_bug.cgi?id=173225
<rdar://problem/32713144>

Reviewed by Tim Horton.

Source/WebCore:

Ensures that a completion block passed to doAfterLoadingProvidedContentIntoFileURLs:synchronousTimeout: will be
invoked immediately, if a synchronous timeout is specified and loading finishes before the synchronous timeout
is reached. To do this, we first factor out the completion logic into a new block. If the synchronous timeout
exists and dispatch_group_wait returns 0 (indicating that the dispatch group finished without hitting the
wait timeout) we simply invoke the block and return early; otherwise, we will register the completion block
using dispatch_group_notify.

Test: DataInteractionTests.WebItemProviderPasteboardLoading

* platform/ios/WebItemProviderPasteboard.mm:
(-[WebItemProviderPasteboard doAfterLoadingProvidedContentIntoFileURLs:synchronousTimeout:]):

Tools:

Adds a new unit test to verify whether the completion block is called synchronously or asynchronously, in both
cases where the synchronous timeout is very large, and the synchronous timeout is not used (0).

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@218125 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/ios/WebItemProviderPasteboard.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm