Cache.add and Cache.addAll should compute a correct response body size
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 20:36:39 +0000 (20:36 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 20:36:39 +0000 (20:36 +0000)
commitb8adc0ddf91740b2114415124012fb209d84f3d9
tree8133c0ec242386ddf9d5c038896502b3db3da307
parentd28875166fe64a2e00704068ce026f4d73daa133
Cache.add and Cache.addAll should compute a correct response body size
https://bugs.webkit.org/show_bug.cgi?id=197464

Reviewed by Chris Dumez.

Source/WebCore:

Compute the response body size as we do for regular Cache.put

Test: http/wpt/cache-storage/cache-quota-add.any.html

* Modules/cache/CacheStorageConnection.cpp:
(WebCore::CacheStorageConnection::computeRecordBodySize):
* Modules/cache/CacheStorageConnection.h:
* Modules/cache/DOMCache.cpp:
(WebCore::FetchTasksHandler::addResponseBody):
(WebCore::DOMCache::addAll):
Compute the response body size requires getting access to the connection.
'this' is added to the lambda which is fine since taskHandler keeps a
Ref to 'this' in its completion handler.
(WebCore::DOMCache::toConnectionRecord):
* Modules/fetch/FetchResponse.h:

LayoutTests:

* http/wpt/cache-storage/cache-quota-add.any-expected.txt: Added.
* http/wpt/cache-storage/cache-quota-add.any.html: Added.
* http/wpt/cache-storage/cache-quota-add.any.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244918 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/wpt/cache-storage/cache-quota-add.any-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-quota-add.any.html [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-quota-add.any.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/CacheStorageConnection.cpp
Source/WebCore/Modules/cache/CacheStorageConnection.h
Source/WebCore/Modules/cache/DOMCache.cpp
Source/WebCore/Modules/cache/DOMCache.h
Source/WebCore/Modules/fetch/FetchResponse.h