[Cocoa] Add SPI to opt out a URL scheme from the memory cache
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jan 2016 21:57:09 +0000 (21:57 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jan 2016 21:57:09 +0000 (21:57 +0000)
commit192cc20d902ddf1029a6966338a3eff272b4ff53
tree316c5f090d4c100b437610e1b491d12f15d45f1b
parentb2ac7ae8993847f40f8c98d4badddbf03290296c
[Cocoa] Add SPI to opt out a URL scheme from the memory cache
https://bugs.webkit.org/show_bug.cgi?id=152950
rdar://problem/24066652

Reviewed by Tim Horton.

Source/WebCore:

Added a list of schemes to SchemeRegistry whose resources should always be revalidated. Taught CachedResource to
return a freshness lifetime of 0 for these resources, unless the scheme is one that should be cached indefinitely.

New API test: WebKit2.AlwaysRevalidatedURLSchemes

* loader/cache/CachedResource.cpp:
(WebCore::shouldCacheSchemeIndefinitely): Moved from SchemeRegistry::shouldCacheResponsesFromURLSchemeIndefinitely().
(WebCore::CachedResource::freshnessLifetime): For a scheme that should not be cached indefinitely, return 0 if
that scheme should always be revalidated according to SchemeRegistry.
* platform/SchemeRegistry.cpp:
(WebCore::alwaysRevalidatedSchemes):
(WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated):
(WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme):
(WebCore::SchemeRegistry::shouldCacheResponsesFromURLSchemeIndefinitely): Moved to WebCore::shouldCacheSchemeIndefinitely().
There was no reason for this to be in SchemeRegistry.
* platform/SchemeRegistry.h:

Source/WebKit2:

Added a alwaysRevalidatedURLSchemes property to _WKProcessPoolConfiguration. Taught WebProcess to add these
schemes to SchemeRegistry when initializing a new web process.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration alwaysRevalidatedURLSchemes]):
(-[_WKProcessPoolConfiguration setAlwaysRevalidatedURLSchemes:]):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createNewWebProcess):
* UIProcess/WebProcessPool.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::registerURLSchemeAsAlwaysRevalidated):
* WebProcess/WebProcess.h:

Tools:

Added an API test.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/AlwaysRevalidatedURLSchemes.mm: Added.
(+[AlwaysRevalidatedURLSchemeProtocol canInitWithRequest:]):
(+[AlwaysRevalidatedURLSchemeProtocol canonicalRequestForRequest:]):
(+[AlwaysRevalidatedURLSchemeProtocol requestIsCacheEquivalent:toRequest:]):
(-[AlwaysRevalidatedURLSchemeProtocol startLoading]):
(-[AlwaysRevalidatedURLSchemeProtocol stopLoading]):
(-[AlwaysRevalidatedURLSchemesDelegate webView:didFinishNavigation:]):
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194866 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/platform/SchemeRegistry.cpp
Source/WebCore/platform/SchemeRegistry.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp
Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h
Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h
Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/UIProcess/WebProcessPool.h
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AlwaysRevalidatedURLSchemes.mm [new file with mode: 0644]