Add API to clean CacheStorage data
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 23:55:11 +0000 (23:55 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 23:55:11 +0000 (23:55 +0000)
commitd00e1bf7c251c6e4eb8853f51a5ccf4c249efa16
tree9e54baf88e5963fc47c49559951add2b2a082f1f
parent720d20092ae00bdf33025eb156c9f3e79bedaada
Add API to clean CacheStorage data
https://bugs.webkit.org/show_bug.cgi?id=178034

Patch by Youenn Fablet <youenn@apple.com> on 2017-10-11
Reviewed by Chris Dumez.

Source/WebCore:

Test: http/tests/cache-storage/cache-clearing.https.html

* platform/FileSystem.h:

Source/WebKit:

Introducing a new website data type for DOMCache.
Adding API to delete DOMCache for a given origin or for all origins.
This is added to WKWebsiteDataStore.

Cleaning a CacheStorage will remove all data in the Cache object but the object will stay live
for the duration of the NetworkProcess.
This allows ensuring that once a cache is cleaned, WebProcess will update to this new state.

Fetching of WebsiteData for DOMCache is not implemented yet since we do not keep a list of all origins for which we have data.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::fetchDOMCacheEntries):
(WebKit::NetworkProcess::fetchWebsiteData):
(WebKit::NetworkProcess::deleteWebsiteData):
(WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::cachesRootPath):
(WebKit::CacheStorage::Engine::fetchEntries):
(WebKit::CacheStorage::ClearTasksHandler::ClearTasksHandler):
(WebKit::CacheStorage::ClearTasksHandler::~ClearTasksHandler):
(WebKit::CacheStorage::Engine::clearEngines):
(WebKit::CacheStorage::Engine::clearCachesForOrigins):
(WebKit::CacheStorage::Engine::readCachesFromDisk):
(WebKit::CacheStorage::deleteFolder):
(WebKit::CacheStorage::Engine::clearCaches):
(WebKit::CacheStorage::Engine::unlock): Removing the assertion as Cache objects are removed when clearing data.
* NetworkProcess/cache/CacheStorageEngine.h:
* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::Caches::Caches):
(WebKit::CacheStorage::Caches::clear):
* NetworkProcess/cache/CacheStorageEngineCaches.h:
(WebKit::CacheStorage::Caches::create):
* Shared/WebsiteData/WebsiteDataType.h:
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreRemoveAllDOMCaches):
(WKWebsiteDataStoreRemoveDOMCacheForOrigin):
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
* UIProcess/API/Cocoa/WKWebsiteDataRecord.h:
* UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:
(dataTypesToString):
* UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h:
(WebKit::toWebsiteDataType):
(WebKit::toWKWebsiteDataTypes):
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(+[WKWebsiteDataStore allWebsiteDataTypes]):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::computeNetworkProcessAccessTypeForDataFetch):
(WebKit::computeNetworkProcessAccessTypeForDataRemoval):

Source/WTF:

Moving CallbackAggregator pattern into its own class for easier reuse.

* WTF.xcodeproj/project.pbxproj:
* wtf/CallbackAggregator.h: Added.
(WTF::CallbackAggregator::create):
(WTF::CallbackAggregator::~CallbackAggregator):
(WTF::CallbackAggregator::CallbackAggregator):

Tools:

Adding internals API to trigger deleting all or origin-persistent cache storage persistent data.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::clearDOMCache):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::clearDOMCache):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests:

* http/tests/cache-storage/cache-clearing.https-expected.txt: Added.
* http/tests/cache-storage/cache-clearing.https.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223213 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache-storage/cache-clearing.https-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache-storage/cache-clearing.https.html [new file with mode: 0644]
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CallbackAggregator.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/FileSystem.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h
Source/WebKit/Shared/WebsiteData/WebsiteDataType.h
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.h
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp