Allow CachedResourceLoader clients to opt out of the MemoryCache.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jan 2016 19:52:57 +0000 (19:52 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jan 2016 19:52:57 +0000 (19:52 +0000)
commit83e9abbfbe268c2471189b9387b51c0d68199ec5
tree990872e689f6125d783c40933c013b820fa2fe67
parent2cd844edf648aad2a79cd1e159d246b40f099a6f
Allow CachedResourceLoader clients to opt out of the MemoryCache.
https://bugs.webkit.org/show_bug.cgi?id=153549

Reviewed by Darin Adler.

Add a flag to ResourceLoaderOptions which allow loader clients to opt out of having
resources stored in the MemoryCache.

* loader/ResourceLoaderOptions.h:
(WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
(WebCore::ResourceLoaderOptions::cachingPolicy):

Existing clients will have to add the (default) AllowCaching flag when they create a
ResourceLoaderOptions object.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startLoadingMainResource):
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::start):
* loader/NetscapePlugInStreamLoader.cpp:
(WebCore::NetscapePlugInStreamLoader::NetscapePlugInStreamLoader):
(WebCore::ResourceLoaderOptions::setCachingPolicy):
* loader/icon/IconLoader.cpp:
(WebCore::IconLoader::startLoading):
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
(WebCore::WebCoreAVFResourceLoader::startLoading):

Every time the CachedResource or CachedResourceLoader accesses the MemoryCache, check
to see whether the resource or the request have allowed caching before adding resources
to, removing resources from, or sourcing resource data from the MemoryCache.

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::~CachedResource):
(WebCore::CachedResource::failBeforeStarting):
(WebCore::CachedResource::addClientToSet):
(WebCore::CachedResource::removeClient):
(WebCore::CachedResource::setDecodedSize):
(WebCore::CachedResource::setEncodedSize):
(WebCore::CachedResource::didAccessDecodedData):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::allowsCaching):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::revalidateResource):
(WebCore::CachedResourceLoader::loadResource):
(WebCore::CachedResourceLoader::printPreloadStats):
(WebCore::CachedResourceLoader::defaultCachedResourceOptions):
* loader/cache/CachedResourceRequest.h:
(WebCore::CachedResourceRequest::allowsCaching):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195770 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/MediaResourceLoader.cpp
Source/WebCore/loader/NetscapePlugInStreamLoader.cpp
Source/WebCore/loader/ResourceLoaderOptions.h
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceRequest.h
Source/WebCore/loader/icon/IconLoader.cpp
Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm