[Cache API] Add a WK2 implementation of CacheStorageConnection
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Aug 2017 15:51:45 +0000 (15:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Aug 2017 15:51:45 +0000 (15:51 +0000)
commitae7249354d9845916c69b32c8ad1dd4daef20bcd
tree5b251e1cff0195f5668d9997f01418a6359e2d0c
parentb90829e503cd603f353d229465c880022ad6e82a
[Cache API] Add a WK2 implementation of CacheStorageConnection
https://bugs.webkit.org/show_bug.cgi?id=175640

Patch by Youenn Fablet <youenn@apple.com> on 2017-08-18
Reviewed by Alex Christensen & Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/cache-storage/window/cache-add.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/window/cache-delete.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/window/cache-keys.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/window/cache-match.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/window/cache-matchAll.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/window/cache-put.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/window/cache-storage-keys.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/window/cache-storage.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/window/sandboxed-iframes.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/worker/cache-add.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/worker/cache-delete.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/worker/cache-keys.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/worker/cache-match.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/worker/cache-matchAll.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/worker/cache-storage-keys.https-expected.txt:
* web-platform-tests/service-workers/cache-storage/worker/cache-storage.https-expected.txt:

Source/WebCore:

* Modules/cache/CacheStorageConnection.cpp: Adding Internal error.
* Modules/cache/CacheStorageConnection.h: Ditto.
* WebCore.xcodeproj/project.pbxproj: Exporting CacheQueryOptions.h header.

Source/WebKit:

Adding WebCacheStorageConnection as an implementation of CacheStorageConnection.
Making WebCacheStorageProvider instantiates such class.
One WebCacheStorageConnection is created for each session of a given WebProcess.

WebCacheStorageConnection is sending IPC calls to the network process.
Main implementation of the cache API is done in the network process by CacheStorageEngineConnection and CacheStorageEngine.
There is one WebCacheStorageConnection per session.
WebCacheStorageConnection is passing the session ID for each call to the network process to ensure the right cache storage engine is used.

CacheStorageEngineConnection mirrors WebCacheStorageConnection on the network process.
There is one CacheStorageEngine per session and CacheStorageEngineConnection will select the right CacheStorageEngine using the given session ID.

CacheStorageEngine is responsible of storing and matching cache API records.
Current implementation only keeps in memory the cached objects.

CacheStorageEngine is keeping (for each different origin) caches and records as a Vector as the order of insertion is important as per spec.
It also keeps a list of removed caches. These caches should remain functional until the last web page having access to these is gone.
The mechanism to fully remove these caches is not implemented yet.

Adding IPC encodings for WTF::Expected, CacheQueryOptions, FetchOptions, CacheStorageConnection Record and CacheInfo.

* CMakeLists.txt:
* DerivedSources.make:
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
(WebKit::generateCacheStorageConnectionIdentifier):
(WebKit::NetworkConnectionToWebProcess::createCacheStorageConnection):
(WebKit::NetworkConnectionToWebProcess::closeCacheStorageConnection):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* NetworkProcess/cache/CacheStorageEngine.cpp: Added.
(WebKit::defaultCacheStorageEngine):
(WebKit::globalEngineMap):
(WebKit::CacheStorageEngine::from):
(WebKit::CacheStorageEngine::destroyEngine):
(WebKit::CacheStorageEngine::defaultEngine):
(WebKit::CacheStorageEngine::open):
(WebKit::CacheStorageEngine::remove):
(WebKit::CacheStorageEngine::retrieveCaches):
(WebKit::CacheStorageEngine::retrieveRecords):
(WebKit::CacheStorageEngine::putRecords):
(WebKit::CacheStorageEngine::deleteMatchingRecords):
(WebKit::CacheStorageEngine::writeCachesToDisk):
(WebKit::CacheStorageEngine::readCachesFromDisk):
(WebKit::CacheStorageEngine::readCache):
(WebKit::CacheStorageEngine::writeCacheRecords):
(WebKit::CacheStorageEngine::removeCacheRecords):
(WebKit::CacheStorageEngine::cache):
(WebKit::CacheStorageEngine::caches const):
(WebKit::CacheStorageEngine::records):
(WebKit::CacheStorageEngine::queryCache):
* NetworkProcess/cache/CacheStorageEngine.h: Added.
* NetworkProcess/cache/CacheStorageEngineConnection.cpp: Added.
(WebKit::CacheStorageEngineConnection::CacheStorageEngineConnection):
(WebKit::CacheStorageEngineConnection::open):
(WebKit::CacheStorageEngineConnection::remove):
(WebKit::CacheStorageEngineConnection::caches):
(WebKit::CacheStorageEngineConnection::records):
(WebKit::CacheStorageEngineConnection::deleteMatchingRecords):
(WebKit::CacheStorageEngineConnection::putRecords):
* NetworkProcess/cache/CacheStorageEngineConnection.h: Added.
(WebKit::CacheStorageEngineConnection::create):
* NetworkProcess/cache/CacheStorageEngineConnection.messages.in: Added.
* Platform/IPC/ArgumentCoders.h:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<CacheQueryOptions>::encode):
(IPC::ArgumentCoder<CacheQueryOptions>::decode):
(IPC::ArgumentCoder<FetchOptions>::encode):
(IPC::ArgumentCoder<FetchOptions>::decode):
(IPC::ArgumentCoder<CacheStorageConnection::CacheInfo>::encode):
(IPC::ArgumentCoder<CacheStorageConnection::CacheInfo>::decode):
(IPC::ArgumentCoder<CacheStorageConnection::Record>::encode):
(IPC::ArgumentCoder<CacheStorageConnection::Record>::decode):
* Shared/WebCoreArgumentCoders.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/Cache/WebCacheStorageConnection.cpp: Added.
(WebKit::WebCacheStorageConnection::WebCacheStorageConnection):
(WebKit::WebCacheStorageConnection::~WebCacheStorageConnection):
(WebKit::WebCacheStorageConnection::messageSenderConnection):
(WebKit::WebCacheStorageConnection::doOpen):
(WebKit::WebCacheStorageConnection::doRemove):
(WebKit::WebCacheStorageConnection::doRetrieveCaches):
(WebKit::WebCacheStorageConnection::doRetrieveRecords):
(WebKit::WebCacheStorageConnection::doBatchDeleteOperation):
(WebKit::WebCacheStorageConnection::doBatchPutOperation):
(WebKit::WebCacheStorageConnection::openCompleted):
(WebKit::WebCacheStorageConnection::removeCompleted):
(WebKit::WebCacheStorageConnection::updateCaches):
(WebKit::WebCacheStorageConnection::updateRecords):
(WebKit::WebCacheStorageConnection::deleteRecordsCompleted):
(WebKit::WebCacheStorageConnection::putRecordsCompleted):
* WebProcess/Cache/WebCacheStorageConnection.h: Added.
* WebProcess/Cache/WebCacheStorageConnection.messages.in: Added.
* WebProcess/Cache/WebCacheStorageProvider.cpp: Copied from Source/WebKit/WebProcess/Cache/WebCacheStorageProvider.h.
(WebKit::WebCacheStorageProvider::createCacheStorageConnection):
* WebProcess/Cache/WebCacheStorageProvider.h:
* WebProcess/Network/NetworkProcessConnection.cpp:
(WebKit::NetworkProcessConnection::didReceiveMessage):

LayoutTests:

* TestExpectations: Marking some tests as flaky until being loaded resources can be cached.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-add.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-delete.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-keys.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-match.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-matchAll.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-put.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-storage-keys.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-storage.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/sandboxed-iframes.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-add.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-delete.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-keys.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-match.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-matchAll.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-storage-keys.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-storage.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/CacheStorageConnection.cpp
Source/WebCore/Modules/cache/CacheStorageConnection.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebKit/CMakeLists.txt
Source/WebKit/ChangeLog
Source/WebKit/DerivedSources.make
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp [new file with mode: 0644]
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h [new file with mode: 0644]
Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.cpp [new file with mode: 0644]
Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.h [new file with mode: 0644]
Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.messages.in [new file with mode: 0644]
Source/WebKit/Platform/IPC/ArgumentCoders.h
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp [new file with mode: 0644]
Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.h [new file with mode: 0644]
Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.messages.in [new file with mode: 0644]
Source/WebKit/WebProcess/Cache/WebCacheStorageProvider.cpp [new file with mode: 0644]
Source/WebKit/WebProcess/Cache/WebCacheStorageProvider.h
Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp