Support caching of Response with a ReadableStream body
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Sep 2017 21:25:19 +0000 (21:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Sep 2017 21:25:19 +0000 (21:25 +0000)
commitb40c391962364799f19ca7b6b439e4e4a37d8bbb
tree9875f6c7f697ac5d5480cdbb8c7e74ca79b82a2f
parent9908b718cd5f4625f30596e1b06fd17360a9221e
Support caching of Response with a ReadableStream body
https://bugs.webkit.org/show_bug.cgi?id=176462

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

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt:

Source/WebCore:

Tests: http/wpt/cache-storage/cache-put-stream.https.any.html
       http/wpt/cache-storage/cache-put-stream.https.any.worker.html

Making FetchResponse use more of ReadableStream:
- Cloning of its body is done through ReadableStream.
- Computation of disturbed and locked is done through ReadableStream.
- Storing of the ReadableStream body given at constructor time is done in FetchBody for FetchResponse.
This allows making FetchResponse closer to FetchRequest.
This also allows to correctly compute disturbed and locked in clone cases.

Adding the ability to consume a Response ReadableStream body as a SharedBuffer.
Using that ability in DOMCache.

* Modules/cache/DOMCache.cpp:
(WebCore::DOMCache::putWithResponseData):
(WebCore::DOMCache::put):
* Modules/cache/DOMCache.h:
* Modules/fetch/FetchBody.h:
(WebCore::FetchBody::readableStream const):
* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::extract):
* Modules/fetch/FetchBodyConsumer.h:
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::isDisturbed const):
(WebCore::FetchBodyOwner::isDisturbedOrLocked const):
* Modules/fetch/FetchBodyOwner.h:
(WebCore::FetchBodyOwner::hasReadableStreamBody const):
* Modules/fetch/FetchBodySource.cpp:
* Modules/fetch/FetchBodySource.h:
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::consumeBodyFromReadableStream):
(WebCore::FetchResponse::consumeBodyWhenLoaded):
(WebCore::FetchResponse::consumeBodyAsStream):
* Modules/fetch/FetchResponse.h:
* Modules/fetch/FetchResponse.idl:
* Modules/fetch/FetchResponse.js:
(initializeFetchResponse):
(clone):
* bindings/js/ReadableStream.cpp:
(WebCore::callFunction):
(WebCore::ReadableStream::pipeTo):
(WebCore::ReadableStream::tee):
(WebCore::checkReadableStream):
(WebCore::ReadableStream::isLocked const):
(WebCore::ReadableStream::isDisturbed const):
(WebCore::ReadableStream::isDisturbed):
* bindings/js/ReadableStream.h:
* bindings/js/ReadableStreamDefaultController.cpp:
* bindings/js/ReadableStreamDefaultController.h:
* bindings/js/WebCoreBuiltinNames.h:
* testing/Internals.cpp:
(WebCore::Internals::isReadableStreamDisturbed):

LayoutTests:

* TestExpectations: Removing flakiness expectation for cache-put tests.
* http/wpt/cache-storage/cache-put-stream.https.any-expected.txt: Added.
* http/wpt/cache-storage/cache-put-stream.https.any.html: Added.
* http/wpt/cache-storage/cache-put-stream.https.any.js: Added.
(cache_test.):
(cache_test):
(string_appeared_here.cache_test.return.reader.read.then.):
(string_appeared_here.cache_test):
* http/wpt/cache-storage/cache-put-stream.https.any.worker-expected.txt: Added.
* http/wpt/cache-storage/cache-put-stream.https.any.worker.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221704 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/wpt/cache-storage/cache-put-stream.https.any-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-put-stream.https.any.html [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-put-stream.https.any.js [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-put-stream.https.any.worker-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-put-stream.https.any.worker.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/DOMCache.cpp
Source/WebCore/Modules/cache/DOMCache.h
Source/WebCore/Modules/fetch/FetchBody.h
Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp
Source/WebCore/Modules/fetch/FetchBodyConsumer.h
Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
Source/WebCore/Modules/fetch/FetchBodyOwner.h
Source/WebCore/Modules/fetch/FetchBodySource.cpp
Source/WebCore/Modules/fetch/FetchBodySource.h
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebCore/Modules/fetch/FetchResponse.h
Source/WebCore/Modules/fetch/FetchResponse.idl
Source/WebCore/Modules/fetch/FetchResponse.js
Source/WebCore/bindings/js/ReadableStream.cpp
Source/WebCore/bindings/js/ReadableStream.h
Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp
Source/WebCore/bindings/js/ReadableStreamDefaultController.h
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/testing/Internals.cpp