Cache small media resources in disk cache
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Apr 2017 10:09:14 +0000 (10:09 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Apr 2017 10:09:14 +0000 (10:09 +0000)
commitfc8f5125df3d3369595ccc172e4a68cf8b6139c9
tree22b6e11b11766abb0e920ffd07270dbcf335e64e
parentf73026118b412fc4b22333cf7ce461895f7a3acb
Cache small media resources in disk cache
https://bugs.webkit.org/show_bug.cgi?id=170676
<rdar://problem/31532649>

Reviewed by Andreas Kling.

Source/WebCore:

Test: http/tests/cache/disk-cache/disk-cache-media-small.html

Testing support. Functional changes are in WebKit2.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerCreateResourceLoader):
(WebCore::HTMLMediaElement::lastMediaResourceLoaderForTesting):
* html/HTMLMediaElement.h:
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::MediaResourceLoader):
(WebCore::MediaResourceLoader::addResponseForTesting):
(WebCore::MediaResource::responseReceived):
* loader/MediaResourceLoader.h:
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSessionDataTask resource:receivedResponse:]):

    We can now receive cached responses.

* testing/Internals.cpp:
(WebCore::responseSourceToString):
(WebCore::Internals::xhrResponseSource):
(WebCore::Internals::mediaResponseSources):
(WebCore::Internals::mediaResponseContentRanges):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2:

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::makeRetrieveDecision):

    Allow retrieving media resources.

(WebKit::NetworkCache::expectedTotalResourceSizeFromContentRange):
(WebKit::NetworkCache::expectedTotalResourceSize):
(WebKit::NetworkCache::makeStoreDecision):

    Store media resource if we can figure out its total size and it is less than 5MB
    (and it is cacheable by the usual rules).

LayoutTests:

* http/tests/cache/disk-cache/disk-cache-media-small-expected.txt: Added.
* http/tests/cache/disk-cache/disk-cache-media-small.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215263 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache/disk-cache/disk-cache-media-small-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/disk-cache/disk-cache-media-small.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/loader/MediaResourceLoader.cpp
Source/WebCore/loader/MediaResourceLoader.h
Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp