Cache API tests are flaky due to file writing failing from time to time
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2018 17:57:20 +0000 (17:57 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2018 17:57:20 +0000 (17:57 +0000)
commit0fd12935b85036ee5d058715bf62a086bcbe2fbf
treecf74369bd5bd12c3cd48addaad80ad338973789c
parent97a2f511e29eed114b7ab224344b63a04e8e958f
Cache API tests are flaky due to file writing failing from time to time
https://bugs.webkit.org/show_bug.cgi?id=190321

Reviewed by Chris Dumez.

Make NetworkCache::Storage::store callback return an error in case of writing failure.
Use this to surface this error at Cache API level.

Minor clean-up to make Storage::clear take a completion handler.

Make also sure to create the folder before writing the file in CacheStorageEngine.
As can be seen from some logging, it does happen that writing the 'origin' file sometimes fail with Posix error 9,
which might mean the folder is not present.

Changes are covered by current tests, flaky tests like http/wpt/cache-storage/cache-put-keys.https.any.worker.html
will show a "failed writing data to the file system" error message.

* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::writeFile):
* NetworkProcess/cache/CacheStorageEngine.h:
* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::Caches::storeOrigin):
(WebKit::CacheStorage::Caches::writeCachesToDisk):
(WebKit::CacheStorage::Caches::writeRecord):
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::WriteOperation::WriteOperation):
(WebKit::NetworkCache::Storage::dispatchWriteOperation):
(WebKit::NetworkCache::Storage::finishWriteOperation):
(WebKit::NetworkCache::Storage::store):
(WebKit::NetworkCache::Storage::clear):
* NetworkProcess/cache/NetworkCacheStorage.h:
(WebKit::NetworkCache::Storage::store):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237071 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp
Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp
Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h