Implement Cache API partitioning based on ClientOrigin
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 08:49:12 +0000 (08:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 08:49:12 +0000 (08:49 +0000)
commitf084f24bd644670b574e9a3eaa6ab3c751bfda0d
tree6c4ca0343e998dc1971d2666e5a206ea4863dac3
parent7dfdd350308bf5ad4ed79f1c4339f302cce68df6
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
27 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache-storage/cache-clearing-origin.https-expected.txt
LayoutTests/http/tests/cache-storage/cache-clearing-origin.https.html
LayoutTests/http/tests/cache-storage/cache-origins.https-expected.txt
LayoutTests/http/tests/cache-storage/cache-origins.https.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/CacheStorageConnection.cpp
Source/WebCore/Modules/cache/CacheStorageConnection.h
Source/WebCore/Modules/cache/DOMCacheStorage.cpp
Source/WebCore/Modules/cache/DOMCacheStorage.h
Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp
Source/WebCore/Modules/cache/WorkerCacheStorageConnection.h
Source/WebCore/page/ClientOrigin.h
Source/WebCore/page/SecurityOriginData.cpp
Source/WebCore/page/SecurityOriginData.h
Source/WebCore/testing/Internals.cpp
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/NetworkProcess/cache/CacheStorageEngineConnection.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.h
Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.messages.in
Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp
Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.h