[Cache API] Add support for Cache.add/addAll
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 02:03:24 +0000 (02:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 02:03:24 +0000 (02:03 +0000)
commit990e87ab16f9f7e3c3e5cb4f9e5baea714c25c37
treece6a2768d370f0e937c3085055de3fb726cc4484
parent3924ea6f9965a9f75873460274dd536937a74842
[Cache API] Add support for Cache.add/addAll
https://bugs.webkit.org/show_bug.cgi?id=175677

Patch by Youenn Fablet <youenn@apple.com> on 2017-08-21
Reviewed by Alex Christensen.

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-storage.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-storage.https-expected.txt:

Source/WebCore:

Covered by rebased tests.

Cache.addAll implementation is then as follow:
- Fetch the resources in parallel.
- Wait for all them to complete using FetchTaskCounter.
- If an error happens in any load or if the response is not as expected for Cache API, reject the promise.
- Call the batch put operation with all received FetchResponse objects.

FetchTaskCounter is responsible to wait for each response to arrive.
It then checks whether the response is fine,
If not, the addAll promise is rejected.
Otherwise, it waits for the body to be received.

Introducing a helper routine to create a FetchRequest from a given RequestInfo.
Introducing a helper routine to check for Vary Header '*' value in response headers.

* Modules/cache/Cache.cpp:
(WebCore::Cache::doMatch):
(WebCore::Cache::add):
(WebCore::queryCacheMatch):
(WebCore::hasResponseVaryStarHeaderValue):
(WebCore::FetchTaskCounter::FetchTaskCounter):
(WebCore::FetchTaskCounter::~FetchTaskCounter):
(WebCore::FetchTaskCounter::addRecord):
(WebCore::FetchTaskCounter::isDone const):
(WebCore::FetchTaskCounter::reject):
(WebCore::Cache::requestFromInfo):
(WebCore::Cache::addAll):
(WebCore::Cache::put):
(WebCore::Cache::remove):
(WebCore::Cache::keys):
(WebCore::toConnectionRecord):
(WebCore::Cache::batchPutOperation):
* Modules/cache/Cache.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
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-storage.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-put.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/Cache.cpp
Source/WebCore/Modules/cache/Cache.h