- Revision
- 196831
- Author
- [email protected]
- Date
- 2016-02-19 13:04:56 -0800 (Fri, 19 Feb 2016)
Log Message
Adopt CachedRawResourceClient::shouldCacheResponse() in MediaResourceLoader and WebCoreNSURLSession
https://bugs.webkit.org/show_bug.cgi?id=154466
Reviewed by Alex Christensen.
Adopt the new shouldCacheResponse() callback so that byte-range
requests generated by WebCoreNSURLSession are not cached.
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResource::shouldCacheResponse):
* loader/MediaResourceLoader.h:
* platform/graphics/PlatformMediaResourceLoader.h:
(WebCore::PlatformMediaResourceClient::shouldCacheResponse):
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSession downloadTaskWithRequest:]):
(-[WebCoreNSURLSession streamTaskWithHostName:port:]):
(-[WebCoreNSURLSession streamTaskWithNetService:]):
(-[WebCoreNSURLSessionDataTask _timingData]):
(-[WebCoreNSURLSessionDataTask resource:sentBytes:totalBytesToBeSent:]):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (196830 => 196831)
--- trunk/Source/WebCore/ChangeLog 2016-02-19 21:02:43 UTC (rev 196830)
+++ trunk/Source/WebCore/ChangeLog 2016-02-19 21:04:56 UTC (rev 196831)
@@ -1,3 +1,25 @@
+2016-02-19 Jer Noble <[email protected]>
+
+ Adopt CachedRawResourceClient::shouldCacheResponse() in MediaResourceLoader and WebCoreNSURLSession
+ https://bugs.webkit.org/show_bug.cgi?id=154466
+
+ Reviewed by Alex Christensen.
+
+ Adopt the new shouldCacheResponse() callback so that byte-range
+ requests generated by WebCoreNSURLSession are not cached.
+
+ * loader/MediaResourceLoader.cpp:
+ (WebCore::MediaResource::shouldCacheResponse):
+ * loader/MediaResourceLoader.h:
+ * platform/graphics/PlatformMediaResourceLoader.h:
+ (WebCore::PlatformMediaResourceClient::shouldCacheResponse):
+ * platform/network/cocoa/WebCoreNSURLSession.mm:
+ (-[WebCoreNSURLSession downloadTaskWithRequest:]):
+ (-[WebCoreNSURLSession streamTaskWithHostName:port:]):
+ (-[WebCoreNSURLSession streamTaskWithNetService:]):
+ (-[WebCoreNSURLSessionDataTask _timingData]):
+ (-[WebCoreNSURLSessionDataTask resource:sentBytes:totalBytesToBeSent:]):
+
2016-02-12 Jer Noble <[email protected]>
[Mac] CORS-compliant videos throw security errors when painting to Canvas
Modified: trunk/Source/WebCore/loader/MediaResourceLoader.cpp (196830 => 196831)
--- trunk/Source/WebCore/loader/MediaResourceLoader.cpp 2016-02-19 21:02:43 UTC (rev 196830)
+++ trunk/Source/WebCore/loader/MediaResourceLoader.cpp 2016-02-19 21:04:56 UTC (rev 196831)
@@ -131,6 +131,16 @@
m_client->responseReceived(*this, response);
}
+bool MediaResource::shouldCacheResponse(CachedResource* resource, const ResourceResponse& response)
+{
+ ASSERT_UNUSED(resource, resource == m_resource);
+
+ RefPtr<MediaResource> protect(this);
+ if (m_client)
+ return m_client->shouldCacheResponse(*this, response);
+ return true;
+}
+
void MediaResource::redirectReceived(CachedResource* resource, ResourceRequest& request, const ResourceResponse& response)
{
ASSERT_UNUSED(resource, resource == m_resource);
Modified: trunk/Source/WebCore/loader/MediaResourceLoader.h (196830 => 196831)
--- trunk/Source/WebCore/loader/MediaResourceLoader.h 2016-02-19 21:02:43 UTC (rev 196830)
+++ trunk/Source/WebCore/loader/MediaResourceLoader.h 2016-02-19 21:04:56 UTC (rev 196831)
@@ -70,6 +70,7 @@
// CachedResourceClient
void responseReceived(CachedResource*, const ResourceResponse&) override;
void redirectReceived(CachedResource*, ResourceRequest&, const ResourceResponse&) override;
+ bool shouldCacheResponse(CachedResource*, const ResourceResponse&) override;
void dataSent(CachedResource*, unsigned long long, unsigned long long) override;
void dataReceived(CachedResource*, const char*, int) override;
void notifyFinished(CachedResource*) override;
Modified: trunk/Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h (196830 => 196831)
--- trunk/Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h 2016-02-19 21:02:43 UTC (rev 196830)
+++ trunk/Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h 2016-02-19 21:04:56 UTC (rev 196831)
@@ -44,6 +44,7 @@
virtual void responseReceived(PlatformMediaResource&, const ResourceResponse&) { }
virtual void redirectReceived(PlatformMediaResource&, ResourceRequest&, const ResourceResponse&) { }
+ virtual bool shouldCacheResponse(PlatformMediaResource&, const ResourceResponse&) { return true; }
virtual void dataSent(PlatformMediaResource&, unsigned long long, unsigned long long) { }
virtual void dataReceived(PlatformMediaResource&, const char*, int) { }
virtual void accessControlCheckFailed(PlatformMediaResource&, const ResourceError&) { }
Modified: trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm (196830 => 196831)
--- trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm 2016-02-19 21:02:43 UTC (rev 196830)
+++ trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm 2016-02-19 21:04:56 UTC (rev 196831)
@@ -57,6 +57,7 @@
- (void)resource:(PlatformMediaResource&)resource sentBytes:(unsigned long long)bytesSent totalBytesToBeSent:(unsigned long long)totalBytesToBeSent;
- (void)resource:(PlatformMediaResource&)resource receivedResponse:(const ResourceResponse&)response;
+- (BOOL)resource:(PlatformMediaResource&)resource shouldCacheResponse:(const ResourceResponse&)response;
- (void)resource:(PlatformMediaResource&)resource receivedData:(const char*)data length:(int)length;
- (void)resource:(PlatformMediaResource&)resource receivedRedirect:(const ResourceResponse&)response request:(ResourceRequest&)request;
- (void)resource:(PlatformMediaResource&)resource accessControlCheckFailedWithError:(const ResourceError&)error;
@@ -316,6 +317,7 @@
void responseReceived(PlatformMediaResource&, const ResourceResponse&) override;
void redirectReceived(PlatformMediaResource&, ResourceRequest&, const ResourceResponse&) override;
+ bool shouldCacheResponse(PlatformMediaResource&, const ResourceResponse&) override;
void dataSent(PlatformMediaResource&, unsigned long long, unsigned long long) override;
void dataReceived(PlatformMediaResource&, const char* /* data */, int /* length */) override;
void accessControlCheckFailed(PlatformMediaResource&, const ResourceError&) override;
@@ -336,6 +338,11 @@
[m_task resource:resource receivedResponse:response];
}
+bool WebCoreNSURLSessionDataTaskClient::shouldCacheResponse(PlatformMediaResource& resource, const ResourceResponse& response)
+{
+ return [m_task resource:resource shouldCacheResponse:response];
+}
+
void WebCoreNSURLSessionDataTaskClient::dataReceived(PlatformMediaResource& resource, const char* data, int length)
{
[m_task resource:resource receivedData:data length:length];
@@ -535,6 +542,17 @@
}];
}
+- (BOOL)resource:(PlatformMediaResource&)resource shouldCacheResponse:(const ResourceResponse&)response
+{
+ ASSERT_UNUSED(resource, &resource == _resource);
+ UNUSED_PARAM(response);
+
+ ASSERT(isMainThread());
+
+ // FIXME: remove if <rdar://problem/20001985> is ever resolved.
+ return response.httpHeaderField(HTTPHeaderName::ContentRange).isEmpty();
+}
+
- (void)resource:(PlatformMediaResource&)resource receivedData:(const char*)data length:(int)length
{
ASSERT_UNUSED(resource, &resource == _resource);