Clearing WebSite data on iOS does not clear the Fetch Cache
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Dec 2017 00:50:04 +0000 (00:50 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Dec 2017 00:50:04 +0000 (00:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180846
<rdar://problem/36060129>

Reviewed by Youenn Fablet.

When clearing WebSite data, construct the engine for the given sessionID
if missing, instead of not clearing anything when the engine is missing.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::deleteWebsiteData):
(WebKit::NetworkProcess::deleteWebsiteDataForOrigins):

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

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

index 86beb9c..7abce14 100644 (file)
@@ -1,5 +1,20 @@
 2017-12-14  Chris Dumez  <cdumez@apple.com>
 
+        Clearing WebSite data on iOS does not clear the Fetch Cache
+        https://bugs.webkit.org/show_bug.cgi?id=180846
+        <rdar://problem/36060129>
+
+        Reviewed by Youenn Fablet.
+
+        When clearing WebSite data, construct the engine for the given sessionID
+        if missing, instead of not clearing anything when the engine is missing.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::deleteWebsiteData):
+        (WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
+
+2017-12-14  Chris Dumez  <cdumez@apple.com>
+
         self.importScripts() should obey updateViaCache inside service workers
         https://bugs.webkit.org/show_bug.cgi?id=180826
 
index 84e52b2..e9fac84 100644 (file)
@@ -460,7 +460,7 @@ void NetworkProcess::deleteWebsiteData(PAL::SessionID sessionID, OptionSet<Websi
     });
 
     if (websiteDataTypes.contains(WebsiteDataType::DOMCache))
-        CacheStorage::Engine::clearAllEngines([clearTasksHandler = clearTasksHandler.copyRef()] { });
+        CacheStorage::Engine::from(sessionID).clearAllCaches(clearTasksHandler);
 
     if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral())
         clearDiskCache(modifiedSince, [clearTasksHandler = WTFMove(clearTasksHandler)] { });
@@ -503,10 +503,10 @@ void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, Optio
     });
 
     if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) {
-        auto origins = WTF::map(originDatas, [] (auto& originData) {
-            return originData.securityOrigin()->toString();
-        });
-        CacheStorage::Engine::clearEnginesForOrigins(origins, [clearTasksHandler = clearTasksHandler.copyRef()] { });
+        for (auto& originData : originDatas) {
+            auto origin = originData.securityOrigin()->toString();
+            CacheStorage::Engine::from(sessionID).clearCachesForOrigin(origin, clearTasksHandler);
+        }
     }
 
     if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral())
index ada4140..84c4ffe 100644 (file)
@@ -86,22 +86,6 @@ void Engine::fetchEntries(PAL::SessionID sessionID, bool shouldComputeSize, WTF:
     from(sessionID).fetchEntries(shouldComputeSize, WTFMove(completionHandler));
 }
 
-void Engine::clearAllEngines(WTF::Function<void()>&& completionHandler)
-{
-    auto clearTaskHandler = CallbackAggregator::create(WTFMove(completionHandler));
-    for (auto& engine : globalEngineMap().values())
-        engine->clearAllCaches(clearTaskHandler.get());
-}
-
-void Engine::clearEnginesForOrigins(const Vector<String>& origins, WTF::Function<void()>&& completionHandler)
-{
-    auto clearTaskHandler = CallbackAggregator::create(WTFMove(completionHandler));
-    for (auto& engine : globalEngineMap().values()) {
-        for (auto& origin : origins)
-            engine->clearCachesForOrigin(origin, clearTaskHandler.get());
-    }
-}
-
 Engine& Engine::defaultEngine()
 {
     auto sessionID = PAL::SessionID::defaultSessionID();
index ec8843a..8aea8f1 100644 (file)
@@ -57,8 +57,6 @@ public:
 
     static Engine& from(PAL::SessionID);
     static void destroyEngine(PAL::SessionID);
-    static void clearAllEngines(WTF::Function<void()>&&);
-    static void clearEnginesForOrigins(const Vector<String>& origins, WTF::Function<void()>&&);
     static void fetchEntries(PAL::SessionID, bool shouldComputeSize, WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&&);
 
     static Ref<Engine> create(String&& rootPath) { return adoptRef(*new Engine(WTFMove(rootPath))); }
@@ -89,6 +87,9 @@ public:
     void clearMemoryRepresentation(const String& origin, WebCore::DOMCacheEngine::CompletionCallback&&);
     String representation();
 
+    void clearAllCaches(WTF::CallbackAggregator&);
+    void clearCachesForOrigin(const String& origin, WTF::CallbackAggregator&);
+
 private:
     static Engine& defaultEngine();
     explicit Engine(String&& rootPath);
@@ -98,8 +99,6 @@ private:
     void fetchEntries(bool /* shouldComputeSize */, WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&&);
 
     void initialize(WTF::Function<void(std::optional<WebCore::DOMCacheEngine::Error>&&)>&&);
-    void clearAllCaches(WTF::CallbackAggregator&);
-    void clearCachesForOrigin(const String& origin, WTF::CallbackAggregator&);
 
     using CachesOrError = Expected<std::reference_wrapper<Caches>, WebCore::DOMCacheEngine::Error>;
     using CachesCallback = WTF::Function<void(CachesOrError&&)>;