Do not add a caches to its engine if the salt cannot be initialized
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2019 15:51:47 +0000 (15:51 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2019 15:51:47 +0000 (15:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194604

Reviewed by Antti Koivisto.

This is a follow-up to https://bugs.webkit.org/show_bug.cgi?id=194588.
We should return early if initialize fails.

* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::readCachesFromDisk):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241544 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp

index 5643f75..7c09d7d 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-14  Youenn Fablet  <youenn@apple.com>
+
+        Do not add a caches to its engine if the salt cannot be initialized
+        https://bugs.webkit.org/show_bug.cgi?id=194604
+
+        Reviewed by Antti Koivisto.
+
+        This is a follow-up to https://bugs.webkit.org/show_bug.cgi?id=194588.
+        We should return early if initialize fails.
+
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::Engine::readCachesFromDisk):
+
 2019-02-13  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Use a scrolled window for script alerts text
index c5d1372..1d2754e 100644 (file)
@@ -310,6 +310,11 @@ void Engine::initialize(CompletionCallback&& callback)
 void Engine::readCachesFromDisk(const WebCore::ClientOrigin& origin, CachesCallback&& callback)
 {
     initialize([this, origin, callback = WTFMove(callback)](Optional<Error>&& error) mutable {
+        if (error) {
+            callback(makeUnexpected(error.value()));
+            return;
+        }
+
         auto& caches = m_caches.ensure(origin, [&origin, this] {
             auto path = cachesRootPath(origin);
             return Caches::create(*this, WebCore::ClientOrigin { origin }, WTFMove(path), m_quota);
@@ -320,11 +325,6 @@ void Engine::readCachesFromDisk(const WebCore::ClientOrigin& origin, CachesCallb
             return;
         }
 
-        if (error) {
-            callback(makeUnexpected(error.value()));
-            return;
-        }
-
         caches->initialize([callback = WTFMove(callback), caches = caches.copyRef()](Optional<Error>&& error) mutable {
             if (error) {
                 callback(makeUnexpected(error.value()));