[Cache API] Add support for overwriting responses with put on an existing record
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 18:02:43 +0000 (18:02 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 18:02:43 +0000 (18:02 +0000)
commit672d7b5be655e29e9cc1b9b97602c1043c00e6f3
tree1287ccb3e148365207297c447bbac5ac9163a938
parentbbe9ba108792c76fc24190383e5101d5aebbace2
[Cache API] Add support for overwriting responses with put on an existing record
https://bugs.webkit.org/show_bug.cgi?id=175825

Patch by Youenn Fablet <youenn@apple.com> on 2017-08-22
Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

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

Source/WebCore:

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

Adding support for the new response update counter.
Overwriting local cached response with new retrieved response when the counter is different.
Adding support for passing this value from/to workers.

* Modules/cache/Cache.cpp:
(WebCore::Cache::queryCacheWithTargetStorage):
(WebCore::toConnectionRecord):
(WebCore::Cache::updateRecords):
* Modules/cache/CacheStorageConnection.cpp:
(WebCore::CacheStorageConnection::Record::copy const):
* Modules/cache/CacheStorageConnection.h:
* Modules/cache/CacheStorageRecord.h:
* Modules/cache/WorkerCacheStorageConnection.cpp:
(WebCore::toCrossThreadRecordData):
(WebCore::fromCrossThreadRecordData):

Source/WebKit:

Add support for encoding/decoding the update counter.
Incrementing it when overwriting an existing response.
Storing the new body in addition to the new response.

* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorageEngine::putRecords):
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<CacheStorageConnection::Record>::encode):
(IPC::ArgumentCoder<CacheStorageConnection::Record>::decode):

LayoutTests:

Adding update counter for response
Skipping new test on WK1.

* platform/ios-wk1/TestExpectations:
* platform/mac-wk1/TestExpectations:
* http/wpt/cache-storage/cache-put-keys.https.any-expected.txt: Added.
* http/wpt/cache-storage/cache-put-keys.https.any.html: Added.
* http/wpt/cache-storage/cache-put-keys.https.any.js: Added.
(cache_test):
* http/wpt/cache-storage/cache-put-keys.https.any.worker-expected.txt: Added.
* http/wpt/cache-storage/cache-put-keys.https.any.worker.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/http/wpt/cache-storage/cache-put-keys.https.any-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-put-keys.https.any.html [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-put-keys.https.any.js [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-put-keys.https.any.worker-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/cache-storage/cache-put-keys.https.any.worker.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
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/worker/cache-put.https-expected.txt
LayoutTests/platform/ios-wk1/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/Cache.cpp
Source/WebCore/Modules/cache/CacheStorageConnection.cpp
Source/WebCore/Modules/cache/CacheStorageConnection.h
Source/WebCore/Modules/cache/CacheStorageRecord.h
Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.cpp