This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=177552 Patch by Youenn Fablet <[email protected]> on 2017-10-09 Reviewed by Alex Christensen. Source/WebCore: Tests: http/wpt/cache-storage/cache-quota.any.html Storing padded opaque response body sizes within FetchResponse and CacheStorageConnection. See whatwg/storage#31 for the rationale about this padding. Storing in CacheStorageConnection is needed for handling cloned network fetched created responses. Storing in FetchResponse is needed for handling cloned cache-storage created opaque responses. Adding internals to query and set the fuzzed size of a response. * Modules/cache/CacheStorageConnection.cpp: (WebCore::computeRealBodySize): (WebCore::CacheStorageConnection::computeRecordBodySize): (WebCore::CacheStorageConnection::setResponseBodySizeWithPadding): (WebCore::CacheStorageConnection::responseBodySizeWithPadding const): * Modules/cache/CacheStorageConnection.h: * Modules/cache/DOMCache.cpp: (WebCore::DOMCache::toConnectionRecord): (WebCore::DOMCache::updateRecords): * Modules/cache/DOMCache.h: * Modules/cache/DOMCacheEngine.cpp: (WebCore::DOMCacheEngine::errorToException): (WebCore::DOMCacheEngine::Record::copy const): * Modules/cache/DOMCacheEngine.h: * Modules/cache/WorkerCacheStorageConnection.cpp: (WebCore::toCrossThreadRecordData): (WebCore::fromCrossThreadRecordData): * Modules/fetch/FetchResponse.cpp: (WebCore::FetchResponse::clone): (WebCore::FetchResponse::BodyLoader::didReceiveResponse): * Modules/fetch/FetchResponse.h: * Modules/fetch/FetchResponse.idl: * testing/Internals.cpp: (WebCore::Internals::setResponseSizeWithPadding): (WebCore::Internals::responseSizeWithPadding const): * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Adding support for quota checking in CacheStorage::Caches. It is passed to NetworkProcess at creation time. Default quota size is configured to 400Ko by origin per default. This value is suitable for testing. Future patch should raise this default value and allows configuring it. Quota is computed based on the response body size. This size is padded at WebCore for opaque responses. Size is stored persistently as opaque response padded size should remain stable. See whatwg/storage#31 for the rationale about this padding. In case of putting several records at the same time, the size of all records is computed so that all records will be written or rejected together. Sending QuotaExceeded error when quota is exceeded. Future effort should allow asking UIProcess for quota extension. * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::cacheStoragePerOriginQuota const): * NetworkProcess/NetworkProcess.h: * NetworkProcess/NetworkProcessCreationParameters.cpp: (WebKit::NetworkProcessCreationParameters::encode const): (WebKit::NetworkProcessCreationParameters::decode): * NetworkProcess/NetworkProcessCreationParameters.h: * NetworkProcess/cache/CacheStorageEngine.cpp: (WebKit::CacheStorage::Engine::readCachesFromDisk): * NetworkProcess/cache/CacheStorageEngineCache.cpp: (WebKit::CacheStorage::Cache::toRecordInformation): (WebKit::CacheStorage::isolatedCopy): (WebKit::CacheStorage::Cache::open): (WebKit::CacheStorage::Cache::storeRecords): (WebKit::CacheStorage::Cache::put): (WebKit::CacheStorage::Cache::writeRecordToDisk): (WebKit::CacheStorage::Cache::updateRecordToDisk): (WebKit::CacheStorage::Cache::removeRecordFromDisk): (WebKit::CacheStorage::Cache::encode): (WebKit::CacheStorage::Cache::decodeRecordHeader): (WebKit::CacheStorage::Cache::decode): * NetworkProcess/cache/CacheStorageEngineCache.h: * NetworkProcess/cache/CacheStorageEngineCaches.cpp: (WebKit::CacheStorage::Caches::Caches): (WebKit::CacheStorage::Caches::initialize): (WebKit::CacheStorage::Caches::initializeSize): (WebKit::CacheStorage::Caches::requestSpace): (WebKit::CacheStorage::Caches::writeRecord): (WebKit::CacheStorage::Caches::removeRecord): (WebKit::CacheStorage::Caches::removeCacheEntry): * NetworkProcess/cache/CacheStorageEngineCaches.h: (WebKit::CacheStorage::Caches::create): (WebKit::CacheStorage::Caches::hasEnoughSpace const): * NetworkProcess/cache/NetworkCacheStorage.cpp: (WebKit::NetworkCache::Storage::traverse): * NetworkProcess/cocoa/NetworkProcessCocoa.mm: (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa): * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<DOMCacheEngine::Record>::encode): (IPC::ArgumentCoder<DOMCacheEngine::Record>::decode): * UIProcess/API/APIProcessPoolConfiguration.cpp: (API::ProcessPoolConfiguration::copy): * UIProcess/API/APIProcessPoolConfiguration.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::ensureNetworkProcess): LayoutTests: * http/wpt/cache-storage/cache-quota.https.any-expected.txt: Added. * http/wpt/cache-storage/cache-quota.https.any.html: Added. * http/wpt/cache-storage/cache-quota.https.any.js: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@223073 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
6f0fbd7
commit d8e12b9
Showing
34 changed files
with
574 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
2017-10-09 Youenn Fablet <[email protected]> | ||
|
||
Add quota to cache API | ||
https://bugs.webkit.org/show_bug.cgi?id=177552 | ||
|
||
Reviewed by Alex Christensen. | ||
|
||
* http/wpt/cache-storage/cache-quota.https.any-expected.txt: Added. | ||
* http/wpt/cache-storage/cache-quota.https.any.html: Added. | ||
* http/wpt/cache-storage/cache-quota.https.any.js: Added. | ||
|
||
2017-10-09 Matt Lewis <[email protected]> | ||
|
||
Unskipped http/tests/cache/disk-cache/disk-cache-validation-no-body.html | ||
|
7 changes: 7 additions & 0 deletions
7
LayoutTests/http/wpt/cache-storage/cache-quota.any-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
PASS Testing synthetic response body size padding | ||
PASS Testing non opaque response body size padding | ||
PASS Testing opaque response body size padding | ||
PASS Hitting cache quota for non opaque responses | ||
PASS Hitting cache quota for padded responses | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
// META: script=/service-workers/cache-storage/resources/test-helpers.js | ||
// META: script=/common/get-host-info.sub.js | ||
|
||
var test_url = 'https://example.com/foo'; | ||
var test_body = 'Hello world!'; | ||
|
||
function getResponseBodySizeWithPadding(response) | ||
{ | ||
var cache; | ||
var request = new Request("temp"); | ||
var clone = response.clone(); | ||
return self.caches.open("test").then((c) => { | ||
cache = c; | ||
return cache.put(request, clone); | ||
}).then(() => { | ||
return self.caches.delete("temp"); | ||
}).then(() => { | ||
return window.internals.responseSizeWithPadding(clone); | ||
}); | ||
} | ||
|
||
promise_test(() => { | ||
if (!window.internals) | ||
return Promise.reject("Test requires internals"); | ||
|
||
var response = new Response(""); | ||
return getResponseBodySizeWithPadding(response).then(size => { | ||
assert_equals(size, 0, "zero size synthetic response"); | ||
return getResponseBodySizeWithPadding(response.clone()); | ||
}).then((size) => { | ||
assert_equals(size, 0, "zero size synthetic cloned response"); | ||
|
||
response = new Response("a"); | ||
return getResponseBodySizeWithPadding(response); | ||
}).then((size) => { | ||
assert_equals(size, 1, "non zero size synthetic response"); | ||
return getResponseBodySizeWithPadding(response.clone()); | ||
}).then((size) => { | ||
assert_equals(size, 1, "non zero size synthetic cloned response"); | ||
}) | ||
}, "Testing synthetic response body size padding"); | ||
|
||
promise_test(() => { | ||
if (!window.internals) | ||
return Promise.reject("Test requires internals"); | ||
|
||
var paddedSize; | ||
var response, responseClone; | ||
return fetch("").then(r => { | ||
response = r; | ||
responseClone = response.clone(); | ||
return getResponseBodySizeWithPadding(response); | ||
}).then((size) => { | ||
paddedSize = size; | ||
return response.arrayBuffer(); | ||
}).then((buffer) => { | ||
assert_equals(buffer.byteLength, paddedSize, "non opaque network response"); | ||
return getResponseBodySizeWithPadding(responseClone); | ||
}).then((size) => { | ||
assert_equals(size, paddedSize, "non opaque network cloned response"); | ||
}); | ||
}, "Testing non opaque response body size padding"); | ||
|
||
promise_test(() => { | ||
if (!window.internals) | ||
return Promise.reject("Test requires internals"); | ||
|
||
var actualSize, paddedSize; | ||
var response, responseClone1; | ||
return fetch(get_host_info().HTTP_REMOTE_ORIGIN, {mode: "no-cors"}).then(r => { | ||
response = r; | ||
}).then(() => { | ||
return fetch(get_host_info().HTTP_ORIGIN); | ||
}).then(r => { | ||
return r.arrayBuffer(); | ||
}).then((buffer) => { | ||
actualSize = buffer.byteLength; | ||
}).then(() => { | ||
responseClone1 = response.clone(); | ||
return getResponseBodySizeWithPadding(response); | ||
}).then((size) => { | ||
paddedSize = size; | ||
return getResponseBodySizeWithPadding(responseClone1); | ||
}).then((size) => { | ||
assert_not_equals(size, actualSize, "padded size should be different from actual size"); | ||
assert_equals(size, paddedSize, "opaque network cloned response"); | ||
}); | ||
}, "Testing opaque response body size padding"); | ||
|
||
async function doCleanup() | ||
{ | ||
var cachesKeys = await self.caches.keys(); | ||
for (let name of cachesKeys) { | ||
let cache = await self.caches.open(name); | ||
let keys = await cache.keys(); | ||
for (let key of keys) | ||
await cache.delete(key); | ||
} | ||
} | ||
|
||
promise_test((test) => { | ||
var cache; | ||
var response1ko = new Response(new ArrayBuffer(1 * 1024)); | ||
var response399ko = new Response(new ArrayBuffer(399 * 1024)); | ||
|
||
return doCleanup().then(() => { | ||
return self.caches.open("temp1"); | ||
}).then((c) => { | ||
cache = c; | ||
return cache.put("399ko", response399ko.clone()); | ||
}).then(() => { | ||
return cache.put("1ko-v1", response1ko.clone()); | ||
}).then(() => { | ||
return cache.put("1ko-v2", response1ko.clone()).then(assert_unreached, (e) => { | ||
assert_equals(e.name, "QuotaExceededError"); | ||
}); | ||
}).then(() => { | ||
return cache.delete("1ko-v1"); | ||
}).then(() => { | ||
return cache.put("1ko-v2", response1ko.clone()); | ||
}).then(() => { | ||
return cache.delete("399ko"); | ||
}).then(() => { | ||
return cache.delete("1ko-v1"); | ||
}).then(() => { | ||
return cache.delete("1ko-v2"); | ||
}); | ||
}, 'Hitting cache quota for non opaque responses'); | ||
|
||
promise_test((test) => { | ||
if (!window.internals) | ||
return Promise.reject("Test requires internals"); | ||
|
||
var cache; | ||
var response1ko = new Response(new ArrayBuffer(1 * 1024)); | ||
var responsePadded = new Response(new ArrayBuffer(1 * 1024)); | ||
var response200ko = new Response(new ArrayBuffer(200 * 1024)); | ||
|
||
return doCleanup().then(() => { | ||
return self.caches.open("temp2"); | ||
}).then((c) => { | ||
cache = c; | ||
return fetch(get_host_info().HTTP_REMOTE_ORIGIN, {mode: "no-cors"}); | ||
}).then((r) => { | ||
responsePadded = r; | ||
internals.setResponseSizeWithPadding(responsePadded, 200 * 1024); | ||
return cache.put("200ko", response200ko.clone()); | ||
}).then(() => { | ||
return cache.put("1ko-padded-to-200ko", responsePadded.clone()); | ||
}).then(() => { | ||
return cache.put("1ko", response1ko.clone()).then(assert_unreached, (e) => { | ||
assert_equals(e.name, "QuotaExceededError"); | ||
}); | ||
}).then(() => { | ||
return cache.delete("1ko-padded-to-200ko"); | ||
}).then(() => { | ||
return cache.put("1ko-v2", response1ko.clone()); | ||
}).then(() => { | ||
return cache.put("1ko-v3", response1ko.clone()); | ||
}).then(() => { | ||
return cache.delete("200ko"); | ||
}).then(() => { | ||
return cache.delete("1ko-v2"); | ||
}).then(() => { | ||
return cache.delete("1ko-v3"); | ||
}); | ||
}, 'Hitting cache quota for padded responses'); | ||
|
||
done(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,47 @@ | ||
2017-10-09 Youenn Fablet <[email protected]> | ||
|
||
Add quota to cache API | ||
https://bugs.webkit.org/show_bug.cgi?id=177552 | ||
|
||
Reviewed by Alex Christensen. | ||
|
||
Tests: http/wpt/cache-storage/cache-quota.any.html | ||
|
||
Storing padded opaque response body sizes within FetchResponse and CacheStorageConnection. | ||
See https://github.com/whatwg/storage/issues/31 for the rationale about this padding. | ||
Storing in CacheStorageConnection is needed for handling cloned network fetched created responses. | ||
Storing in FetchResponse is needed for handling cloned cache-storage created opaque responses. | ||
|
||
Adding internals to query and set the fuzzed size of a response. | ||
|
||
* Modules/cache/CacheStorageConnection.cpp: | ||
(WebCore::computeRealBodySize): | ||
(WebCore::CacheStorageConnection::computeRecordBodySize): | ||
(WebCore::CacheStorageConnection::setResponseBodySizeWithPadding): | ||
(WebCore::CacheStorageConnection::responseBodySizeWithPadding const): | ||
* Modules/cache/CacheStorageConnection.h: | ||
* Modules/cache/DOMCache.cpp: | ||
(WebCore::DOMCache::toConnectionRecord): | ||
(WebCore::DOMCache::updateRecords): | ||
* Modules/cache/DOMCache.h: | ||
* Modules/cache/DOMCacheEngine.cpp: | ||
(WebCore::DOMCacheEngine::errorToException): | ||
(WebCore::DOMCacheEngine::Record::copy const): | ||
* Modules/cache/DOMCacheEngine.h: | ||
* Modules/cache/WorkerCacheStorageConnection.cpp: | ||
(WebCore::toCrossThreadRecordData): | ||
(WebCore::fromCrossThreadRecordData): | ||
* Modules/fetch/FetchResponse.cpp: | ||
(WebCore::FetchResponse::clone): | ||
(WebCore::FetchResponse::BodyLoader::didReceiveResponse): | ||
* Modules/fetch/FetchResponse.h: | ||
* Modules/fetch/FetchResponse.idl: | ||
* testing/Internals.cpp: | ||
(WebCore::Internals::setResponseSizeWithPadding): | ||
(WebCore::Internals::responseSizeWithPadding const): | ||
* testing/Internals.h: | ||
* testing/Internals.idl: | ||
|
||
2017-10-09 Zalan Bujtas <[email protected]> | ||
|
||
Remove redundant RenderObject::virtualContinuation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.