Implement Cache API partitioning based on ClientOrigin
https://bugs.webkit.org/show_bug.cgi?id=181240
Patch by Youenn Fablet <youenn@apple.com> on 2018-01-04
Reviewed by Alex Christensen.
Source/WebCore:
Covered by updated tests.
Previously, cache storage was partitioned according the origin of the client, represented as a String.
We now partition according both client and top origins, represented as a ClientOrigin
Minor refactoring to use more makePendingActivity.
Added support for IPC serialization of ClientOrigin.
Added SecurityOriginData::toString which is used by WebKit2 Cache Storage implementation.
* Modules/cache/CacheStorageConnection.cpp:
(WebCore::CacheStorageConnection::open):
(WebCore::CacheStorageConnection::retrieveCaches):
* Modules/cache/CacheStorageConnection.h:
(WebCore::CacheStorageConnection::clearMemoryRepresentation):
(WebCore::CacheStorageConnection::doOpen):
(WebCore::CacheStorageConnection::doRetrieveCaches):
* Modules/cache/DOMCacheStorage.cpp:
(WebCore::DOMCacheStorage::origin const):
(WebCore::DOMCacheStorage::retrieveCaches):
(WebCore::DOMCacheStorage::open):
(WebCore::DOMCacheStorage::remove):
* Modules/cache/DOMCacheStorage.h:
* Modules/cache/WorkerCacheStorageConnection.cpp:
(WebCore::WorkerCacheStorageConnection::doOpen):
(WebCore::WorkerCacheStorageConnection::doRetrieveCaches):
* Modules/cache/WorkerCacheStorageConnection.h:
* page/ClientOrigin.h:
(WebCore::ClientOrigin::isolatedCopy const):
(WebCore::ClientOrigin::encode const):
(WebCore::ClientOrigin::decode):
* page/SecurityOriginData.cpp:
(WebCore::SecurityOriginData::toString const):
(WebCore::SecurityOriginData::debugString const): Deleted.
* page/SecurityOriginData.h:
(WebCore::SecurityOriginData::debugString const):
* testing/Internals.cpp:
(WebCore::Internals::clearCacheStorageMemoryRepresentation):
Source/WebKit:
open and retrieveCaches now take a ClientOrigin instead of a String.
Updated cache filesystem path computation to take both client origin and top origin.
When clearing an origin, caches whose client origin or top origin matches the origin are cleared.
Caches are added to the web site data of their client origin with their corresponding cache size.
Caches are added to the web site data of their top origin with a size equal to 0.
Updated memory representation dumping used for test to include both top and client origins.
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::cachesRootPath):
(WebKit::CacheStorage::Engine::open):
(WebKit::CacheStorage::Engine::remove):
(WebKit::CacheStorage::Engine::retrieveCaches):
(WebKit::CacheStorage::Engine::readCachesFromDisk):
(WebKit::CacheStorage::Engine::removeCaches):
(WebKit::CacheStorage::Engine::fetchEntries):
(WebKit::CacheStorage::Engine::clearCachesForOrigin):
(WebKit::CacheStorage::Engine::clearMemoryRepresentation):
(WebKit::CacheStorage::Engine::representation):
* NetworkProcess/cache/CacheStorageEngine.h:
* NetworkProcess/cache/CacheStorageEngineCache.cpp:
(WebKit::CacheStorage::Cache::Cache):
* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::Caches::retrieveOriginFromDirectory):
(WebKit::CacheStorage::Caches::Caches):
(WebKit::CacheStorage::Caches::storeOrigin):
(WebKit::CacheStorage::Caches::readOrigin):
(WebKit::CacheStorage::Caches::open):
* NetworkProcess/cache/CacheStorageEngineCaches.h:
(WebKit::CacheStorage::Caches::create):
(WebKit::CacheStorage::Caches::origin const):
* NetworkProcess/cache/CacheStorageEngineConnection.cpp:
(WebKit::CacheStorageEngineConnection::open):
(WebKit::CacheStorageEngineConnection::caches):
(WebKit::CacheStorageEngineConnection::clearMemoryRepresentation):
* NetworkProcess/cache/CacheStorageEngineConnection.h:
* NetworkProcess/cache/CacheStorageEngineConnection.messages.in:
* WebProcess/Cache/WebCacheStorageConnection.cpp:
(WebKit::WebCacheStorageConnection::doOpen):
(WebKit::WebCacheStorageConnection::doRetrieveCaches):
(WebKit::WebCacheStorageConnection::clearMemoryRepresentation):
* WebProcess/Cache/WebCacheStorageConnection.h:
LayoutTests:
Beefing up test to ensure that client and top origins are taken into consideration.
* http/tests/cache-storage/cache-origins.https-expected.txt:
* http/tests/cache-storage/cache-origins.https.html:
* http/tests/cache-storage/cache-clearing-origin.https-expected.txt:
* http/tests/cache-storage/cache-clearing-origin.https.html:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226401
268f45cc-cd09-0410-ab3c-
d52691b4dbfc