Network Cache: Disk cache getting filled by YouTube video data
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2015 12:49:30 +0000 (12:49 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2015 12:49:30 +0000 (12:49 +0000)
commitd9d7f44f4b3e74bb8c05da7d95f7ef180d9b87b7
tree56dddcb612aae26344ffc1de6be0651056b4219e
parent57d82c2742ce93a8c0f84c17540fb935c669f200
Network Cache: Disk cache getting filled by YouTube video data
https://bugs.webkit.org/show_bug.cgi?id=144259

Reviewed by Darin Adler.

Source/WebCore:

MSE media is loaded via XHR and tends to eventually fill the cache.

YouTube serves the media chunks cacheable, however they are rarely (if ever) reused.
We can reduce disk writes and keep more useful resources around by not caching them

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

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startLoadingMainResource):

    Set the requester.

* loader/cache/CachedRawResource.cpp:
(WebCore::CachedRawResource::CachedRawResource):
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::streamingMedia):
* page/DiagnosticLoggingKeys.h:
* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::adopt):
(WebCore::ResourceRequestBase::copyData):
(WebCore::equalIgnoringHeaderFields):
* platform/network/ResourceRequestBase.h:
(WebCore::ResourceRequestBase::requester):
(WebCore::ResourceRequestBase::setRequester):

    Add requester type to the request object. Currently this is main resource, xhr or unspecified.

(WebCore::ResourceRequestBase::encodeWithoutPlatformData):
(WebCore::ResourceRequestBase::decodeWithoutPlatformData):
* platform/network/cf/ResourceRequest.h:
(WebCore::ResourceRequest::deprecatedSetMainResourceRequest): Deleted.
(WebCore::ResourceRequest::deprecatedIsMainResourceRequest): Deleted.

    Replace this iOS only field with shared mechanism.

* platform/network/ios/QuickLook.mm:
(WebCore::QuickLookHandle::create):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createRequest):

    Set the requester.

Source/WebKit2:

MSE media is loaded via XHR and tends to eventually fill the cache.

YouTube serves the media chunks cacheable, however they are rarely (if ever) reused.
We can reduce disk writes and keep more useful resources around by not caching them

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didReceiveResponseAsync):
(WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::makeStoreDecision):

    Don't store if the requester is XHR and response has video or audio content type.

* NetworkProcess/cache/NetworkCache.h:
* NetworkProcess/cache/NetworkCacheStatistics.cpp:
(WebKit::NetworkCache::storeDecisionToDiagnosticKey):
* Shared/Network/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
(WebKit::NetworkResourceLoadParameters::encode):
(WebKit::NetworkResourceLoadParameters::decode):
* Shared/Network/NetworkResourceLoadParameters.h:

    The requester type is now part of the ResourceRequest, no need for separate parameter.

* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::ArgumentCoder<ResourceRequest>::encodePlatformData):
(IPC::ArgumentCoder<ResourceRequest>::decodePlatformData):
* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::WebResourceLoadScheduler::scheduleLoad):

LayoutTests:

* http/tests/cache/disk-cache/disk-cache-media-expected.txt: Added.
* http/tests/cache/disk-cache/disk-cache-media.html: Added.
* http/tests/cache/disk-cache/resources/cache-test.js:
(generateTestURL):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183467 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache/disk-cache/disk-cache-media-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/disk-cache/disk-cache-media.html [new file with mode: 0644]
LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/cache/CachedRawResource.cpp
Source/WebCore/page/DiagnosticLoggingKeys.cpp
Source/WebCore/page/DiagnosticLoggingKeys.h
Source/WebCore/platform/network/ResourceRequestBase.cpp
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebCore/platform/network/cf/ResourceRequest.h
Source/WebCore/platform/network/ios/QuickLook.mm
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCache.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp
Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp
Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h
Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm
Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp