<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196827] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196827">196827</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2016-02-19 11:46:19 -0800 (Fri, 19 Feb 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Mac] CORS-compliant videos throw security errors when painting to Canvas
https://bugs.webkit.org/show_bug.cgi?id=154188
<rdar://problem/22959556>
Reviewed by Alex Christensen.
Pass the CORS access check results from WebCoreNSURLSession to it's client,
MediaPlayerPrivateAVFoundationObjC.
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::didPassCORSAccessCheck): Ask the WebCoreNSURLSession.
* platform/network/cocoa/WebCoreNSURLSession.h:
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSession task:didReceiveCORSAccessCheckResult:]): Conditionally set _corsResults.
(-[WebCoreNSURLSession didPassCORSAccessChecks]): Return _corsResults.
(WebCoreNSURLSessionDataTaskClient::accessControlCheckFailed): Call -resource:accessControlCheckFailedWithError:.
(WebCoreNSURLSessionDataTaskClient::loadFailed): Call -resource:loadFailedWithError:.
(-[WebCoreNSURLSessionDataTask resource:receivedResponse:]): Set _response within the delegate queue.
(-[WebCoreNSURLSessionDataTask _resource:loadFinishedWithError:]): Renamed from resourceFinished:
(-[WebCoreNSURLSessionDataTask resource:accessControlCheckFailedWithError:]): Ditto.
(-[WebCoreNSURLSessionDataTask resource:loadFailedWithError:]): Ditto.
(-[WebCoreNSURLSessionDataTask resourceFinished:]): Ditto.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcocoaWebCoreNSURLSessionh">trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcocoaWebCoreNSURLSessionmm">trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (196826 => 196827)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-19 19:12:51 UTC (rev 196826)
+++ trunk/Source/WebCore/ChangeLog        2016-02-19 19:46:19 UTC (rev 196827)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-02-12 Jer Noble <jer.noble@apple.com>
+
+ [Mac] CORS-compliant videos throw security errors when painting to Canvas
+ https://bugs.webkit.org/show_bug.cgi?id=154188
+ <rdar://problem/22959556>
+
+ Reviewed by Alex Christensen.
+
+ Pass the CORS access check results from WebCoreNSURLSession to it's client,
+ MediaPlayerPrivateAVFoundationObjC.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::didPassCORSAccessCheck): Ask the WebCoreNSURLSession.
+ * platform/network/cocoa/WebCoreNSURLSession.h:
+ * platform/network/cocoa/WebCoreNSURLSession.mm:
+ (-[WebCoreNSURLSession task:didReceiveCORSAccessCheckResult:]): Conditionally set _corsResults.
+ (-[WebCoreNSURLSession didPassCORSAccessChecks]): Return _corsResults.
+ (WebCoreNSURLSessionDataTaskClient::accessControlCheckFailed): Call -resource:accessControlCheckFailedWithError:.
+ (WebCoreNSURLSessionDataTaskClient::loadFailed): Call -resource:loadFailedWithError:.
+ (-[WebCoreNSURLSessionDataTask resource:receivedResponse:]): Set _response within the delegate queue.
+ (-[WebCoreNSURLSessionDataTask _resource:loadFinishedWithError:]): Renamed from resourceFinished:
+ (-[WebCoreNSURLSessionDataTask resource:accessControlCheckFailedWithError:]): Ditto.
+ (-[WebCoreNSURLSessionDataTask resource:loadFailedWithError:]): Ditto.
+ (-[WebCoreNSURLSessionDataTask resourceFinished:]): Ditto.
+
</ins><span class="cx"> 2016-02-19 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed build fix.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (196826 => 196827)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2016-02-19 19:12:51 UTC (rev 196826)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h        2016-02-19 19:46:19 UTC (rev 196827)
</span><span class="lines">@@ -216,7 +216,8 @@
</span><span class="cx">
</span><span class="cx"> virtual void updateVideoLayerGravity() override;
</span><span class="cx">
</span><del>- virtual bool hasSingleSecurityOrigin() const override;
</del><ins>+ bool hasSingleSecurityOrigin() const override;
+ bool didPassCORSAccessCheck() const override;
</ins><span class="cx">
</span><span class="cx"> MediaTime getStartDate() const override;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (196826 => 196827)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2016-02-19 19:12:51 UTC (rev 196826)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2016-02-19 19:46:19 UTC (rev 196827)
</span><span class="lines">@@ -917,7 +917,7 @@
</span><span class="cx"> AVAssetResourceLoader *resourceLoader = m_avAsset.get().resourceLoader;
</span><span class="cx"> [resourceLoader setDelegate:m_loaderDelegate.get() queue:globalLoaderDelegateQueue()];
</span><span class="cx">
</span><del>-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
</del><ins>+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED > 101100
</ins><span class="cx"> if (Settings::isAVFoundationNSURLSessionEnabled()
</span><span class="cx"> && [resourceLoader respondsToSelector:@selector(setURLSession:)]
</span><span class="cx"> && [resourceLoader respondsToSelector:@selector(URLSessionDataDelegate)]
</span><span class="lines">@@ -2163,6 +2163,21 @@
</span><span class="cx"> return resolvedOrigin.get().isSameSchemeHostPort(&requestedOrigin.get());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool MediaPlayerPrivateAVFoundationObjC::didPassCORSAccessCheck() const
+{
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED > 101100
+ AVAssetResourceLoader *resourceLoader = m_avAsset.get().resourceLoader;
+ if (!Settings::isAVFoundationNSURLSessionEnabled()
+ || ![resourceLoader respondsToSelector:@selector(URLSession)])
+ return false;
+
+ WebCoreNSURLSession *session = (WebCoreNSURLSession *)resourceLoader.URLSession;
+ if ([session respondsToSelector:@selector(didPassCORSAccessChecks)])
+ return session.didPassCORSAccessChecks;
+#endif
+ return false;
+}
+
</ins><span class="cx"> #if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::createVideoOutput()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcocoaWebCoreNSURLSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.h (196826 => 196827)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.h        2016-02-19 19:12:51 UTC (rev 196826)
+++ trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.h        2016-02-19 19:46:19 UTC (rev 196827)
</span><span class="lines">@@ -48,6 +48,12 @@
</span><span class="cx"> class WebCoreNSURLSessionDataTaskClient;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+enum class WebCoreNSURLSessionCORSAccessCheckResults {
+ Unknown,
+ Pass,
+ Fail,
+};
+
</ins><span class="cx"> NS_ASSUME_NONNULL_BEGIN
</span><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT @interface WebCoreNSURLSession : NSObject {
</span><span class="lines">@@ -59,12 +65,14 @@
</span><span class="cx"> BOOL _invalidated;
</span><span class="cx"> NSUInteger _nextTaskIdentifier;
</span><span class="cx"> OSObjectPtr<dispatch_queue_t> _internalQueue;
</span><ins>+ WebCoreNSURLSessionCORSAccessCheckResults _corsResults;
</ins><span class="cx"> }
</span><span class="cx"> - (id)initWithResourceLoader:(WebCore::PlatformMediaResourceLoader&)loader delegate:(id<NSURLSessionTaskDelegate>)delegate delegateQueue:(NSOperationQueue*)queue;
</span><span class="cx"> @property (readonly, retain) NSOperationQueue *delegateQueue;
</span><span class="cx"> @property (nullable, readonly, retain) id <NSURLSessionDelegate> delegate;
</span><span class="cx"> @property (readonly, copy) NSURLSessionConfiguration *configuration;
</span><span class="cx"> @property (copy) NSString *sessionDescription;
</span><ins>+@property (readonly) BOOL didPassCORSAccessChecks;
</ins><span class="cx"> - (void)finishTasksAndInvalidate;
</span><span class="cx"> - (void)invalidateAndCancel;
</span><span class="cx">
</span><span class="lines">@@ -97,7 +105,6 @@
</span><span class="cx">
</span><span class="cx"> @interface WebCoreNSURLSessionDataTask : NSObject {
</span><span class="cx"> WebCoreNSURLSession *_session;
</span><del>- std::unique_ptr<WebCore::WebCoreNSURLSessionDataTaskClient> _client;
</del><span class="cx"> RefPtr<WebCore::PlatformMediaResource> _resource;
</span><span class="cx"> RetainPtr<NSURLResponse> _response;
</span><span class="cx"> NSUInteger _taskIdentifier;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcocoaWebCoreNSURLSessionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm (196826 => 196827)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm        2016-02-19 19:12:51 UTC (rev 196826)
+++ trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm        2016-02-19 19:46:19 UTC (rev 196827)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> @property (readwrite, retain) id<NSURLSessionTaskDelegate> delegate;
</span><span class="cx"> - (void)taskCompleted:(WebCoreNSURLSessionDataTask *)task;
</span><span class="cx"> - (void)addDelegateOperation:(void (^)(void))operation;
</span><ins>+- (void)task:(WebCoreNSURLSessionDataTask *)task didReceiveCORSAccessCheckResult:(BOOL)result;
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @interface WebCoreNSURLSessionDataTask ()
</span><span class="lines">@@ -58,6 +59,8 @@
</span><span class="cx"> - (void)resource:(PlatformMediaResource&)resource receivedResponse:(const ResourceResponse&)response;
</span><span class="cx"> - (void)resource:(PlatformMediaResource&)resource receivedData:(const char*)data length:(int)length;
</span><span class="cx"> - (void)resource:(PlatformMediaResource&)resource receivedRedirect:(const ResourceResponse&)response request:(ResourceRequest&)request;
</span><ins>+- (void)resource:(PlatformMediaResource&)resource accessControlCheckFailedWithError:(const ResourceError&)error;
+- (void)resource:(PlatformMediaResource&)resource loadFailedWithError:(const ResourceError&)error;
</ins><span class="cx"> - (void)resourceFinished:(PlatformMediaResource&)resource;
</span><span class="cx"> @end
</span><span class="cx">
</span><span class="lines">@@ -72,10 +75,12 @@
</span><span class="cx"> if (!self)
</span><span class="cx"> return nil;
</span><span class="cx">
</span><ins>+ ASSERT(_corsResults == WebCoreNSURLSessionCORSAccessCheckResults::Unknown);
+ ASSERT(!_invalidated);
+
</ins><span class="cx"> _loader = &loader;
</span><span class="cx"> self.delegate = inDelegate;
</span><span class="cx"> _queue = inQueue ? inQueue : [NSOperationQueue mainQueue];
</span><del>- _invalidated = NO;
</del><span class="cx"> _internalQueue = adoptOSObject(dispatch_queue_create("WebCoreNSURLSession _internalQueue", DISPATCH_QUEUE_SERIAL));
</span><span class="cx">
</span><span class="cx"> return self;
</span><span class="lines">@@ -120,6 +125,15 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)task:(WebCoreNSURLSessionDataTask *)task didReceiveCORSAccessCheckResult:(BOOL)result
+{
+ UNUSED_PARAM(task);
+ if (!result)
+ _corsResults = WebCoreNSURLSessionCORSAccessCheckResults::Fail;
+ else if (_corsResults != WebCoreNSURLSessionCORSAccessCheckResults::Fail)
+ _corsResults = WebCoreNSURLSessionCORSAccessCheckResults::Pass;
+}
+
</ins><span class="cx"> #pragma mark - NSURLSession API
</span><span class="cx"> @synthesize sessionDescription=_sessionDescription;
</span><span class="cx"> @dynamic delegate;
</span><span class="lines">@@ -151,6 +165,12 @@
</span><span class="cx"> return *_loader;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+@dynamic didPassCORSAccessChecks;
+- (BOOL)didPassCORSAccessChecks
+{
+ return _corsResults == WebCoreNSURLSessionCORSAccessCheckResults::Pass;
+}
+
</ins><span class="cx"> - (void)finishTasksAndInvalidate
</span><span class="cx"> {
</span><span class="cx"> _invalidated = YES;
</span><span class="lines">@@ -298,6 +318,8 @@
</span><span class="cx"> void redirectReceived(PlatformMediaResource&, ResourceRequest&, const ResourceResponse&) override;
</span><span class="cx"> void dataSent(PlatformMediaResource&, unsigned long long, unsigned long long) override;
</span><span class="cx"> void dataReceived(PlatformMediaResource&, const char* /* data */, int /* length */) override;
</span><ins>+ void accessControlCheckFailed(PlatformMediaResource&, const ResourceError&) override;
+ void loadFailed(PlatformMediaResource&, const ResourceError&) override;
</ins><span class="cx"> void loadFinished(PlatformMediaResource&) override;
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -324,6 +346,16 @@
</span><span class="cx"> [m_task resource:resource receivedRedirect:response request:request];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebCoreNSURLSessionDataTaskClient::accessControlCheckFailed(PlatformMediaResource& resource, const ResourceError& error)
+{
+ [m_task resource:resource accessControlCheckFailedWithError:error];
+}
+
+void WebCoreNSURLSessionDataTaskClient::loadFailed(PlatformMediaResource& resource, const ResourceError& error)
+{
+ [m_task resource:resource loadFailedWithError:error];
+}
+
</ins><span class="cx"> void WebCoreNSURLSessionDataTaskClient::loadFinished(PlatformMediaResource& resource)
</span><span class="cx"> {
</span><span class="cx"> [m_task resourceFinished:resource];
</span><span class="lines">@@ -473,11 +505,14 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT_UNUSED(resource, &resource == _resource);
</span><span class="cx"> ASSERT(isMainThread());
</span><del>- _response = response.nsURLResponse();
</del><ins>+ [self.session task:self didReceiveCORSAccessCheckResult:resource.didPassAccessControlCheck()];
</ins><span class="cx"> self.countOfBytesExpectedToReceive = response.expectedContentLength();
</span><span class="cx"> [self _setDefersLoading:YES];
</span><ins>+ RetainPtr<NSURLResponse> strongResponse { response.nsURLResponse() };
</ins><span class="cx"> RetainPtr<WebCoreNSURLSessionDataTask> strongSelf { self };
</span><del>- [self.session addDelegateOperation:[strongSelf] {
</del><ins>+ [self.session addDelegateOperation:[strongSelf, strongResponse] {
+ strongSelf->_response = strongResponse.get();
+
</ins><span class="cx"> id<NSURLSessionDataDelegate> dataDelegate = (id<NSURLSessionDataDelegate>)strongSelf.get().session.delegate;
</span><span class="cx"> if (![dataDelegate respondsToSelector:@selector(URLSession:dataTask:didReceiveResponse:completionHandler:)]) {
</span><span class="cx"> callOnMainThread([strongSelf] {
</span><span class="lines">@@ -486,7 +521,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- [dataDelegate URLSession:(NSURLSession *)strongSelf.get().session dataTask:(NSURLSessionDataTask *)strongSelf.get() didReceiveResponse:strongSelf.get().response completionHandler:[strongSelf] (NSURLSessionResponseDisposition disposition) {
</del><ins>+ [dataDelegate URLSession:(NSURLSession *)strongSelf.get().session dataTask:(NSURLSessionDataTask *)strongSelf.get() didReceiveResponse:strongResponse.get() completionHandler:[strongSelf] (NSURLSessionResponseDisposition disposition) {
</ins><span class="cx"> if (disposition == NSURLSessionResponseCancel)
</span><span class="cx"> [strongSelf cancel];
</span><span class="cx"> else if (disposition == NSURLSessionResponseAllow)
</span><span class="lines">@@ -531,22 +566,36 @@
</span><span class="cx"> // API, this can be implemented.
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)resourceFinished:(PlatformMediaResource&)resource
</del><ins>+- (void)_resource:(PlatformMediaResource&)resource loadFinishedWithError:(NSError *)error
</ins><span class="cx"> {
</span><span class="cx"> ASSERT_UNUSED(resource, &resource == _resource);
</span><del>- self.state = NSURLSessionTaskStateCompleted;
-
</del><span class="cx"> RetainPtr<WebCoreNSURLSessionDataTask> strongSelf { self };
</span><del>- [self.session addDelegateOperation:[strongSelf] {
</del><ins>+ RetainPtr<NSError> strongError { error };
+ [self.session addDelegateOperation:[strongSelf, strongError] {
</ins><span class="cx"> id<NSURLSessionTaskDelegate> delegate = (id<NSURLSessionTaskDelegate>)strongSelf.get().session.delegate;
</span><span class="cx"> if ([delegate respondsToSelector:@selector(URLSession:task:didCompleteWithError:)])
</span><del>- [delegate URLSession:(NSURLSession *)strongSelf.get().session task:(NSURLSessionDataTask *)strongSelf.get() didCompleteWithError:nil];
</del><ins>+ [delegate URLSession:(NSURLSession *)strongSelf.get().session task:(NSURLSessionDataTask *)strongSelf.get() didCompleteWithError:strongError.get()];
</ins><span class="cx">
</span><span class="cx"> callOnMainThread([strongSelf] {
</span><span class="cx"> [strongSelf.get().session taskCompleted:strongSelf.get()];
</span><span class="cx"> });
</span><span class="cx"> }];
</span><span class="cx"> }
</span><ins>+
+- (void)resource:(PlatformMediaResource&)resource accessControlCheckFailedWithError:(const ResourceError&)error
+{
+ [self _resource:resource loadFinishedWithError:error.nsError()];
+}
+
+- (void)resource:(PlatformMediaResource&)resource loadFailedWithError:(const ResourceError&)error
+{
+ [self _resource:resource loadFinishedWithError:error.nsError()];
+}
+
+- (void)resourceFinished:(PlatformMediaResource&)resource
+{
+ [self _resource:resource loadFinishedWithError:nil];
+}
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
</span></span></pre>
</div>
</div>
</body>
</html>