Title: [181775] trunk/Source/WebKit2
Revision
181775
Author
[email protected]
Date
2015-03-19 18:37:14 -0700 (Thu, 19 Mar 2015)

Log Message

Add support for deleting individual cache entries
https://bugs.webkit.org/show_bug.cgi?id=142886

Reviewed by Antti Koivisto.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::fetchDiskCacheEntries):
Remove an unnecessary call to cfURLCacheOrigins().

(WebKit::clearDiskCacheEntries):
Helper function for clearing disk cache entries. This handles both the old and new cache implementations.

(WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
Call clearDiskCacheEntries if needed.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (181774 => 181775)


--- trunk/Source/WebKit2/ChangeLog	2015-03-20 00:53:33 UTC (rev 181774)
+++ trunk/Source/WebKit2/ChangeLog	2015-03-20 01:37:14 UTC (rev 181775)
@@ -1,3 +1,20 @@
+2015-03-19  Anders Carlsson  <[email protected]>
+
+        Add support for deleting individual cache entries
+        https://bugs.webkit.org/show_bug.cgi?id=142886
+
+        Reviewed by Antti Koivisto.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::fetchDiskCacheEntries):
+        Remove an unnecessary call to cfURLCacheOrigins().
+
+        (WebKit::clearDiskCacheEntries):
+        Helper function for clearing disk cache entries. This handles both the old and new cache implementations.
+
+        (WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
+        Call clearDiskCacheEntries if needed.
+
 2015-03-19  Jer Noble  <[email protected]>
 
         [WK2][Mac] Fullscreen animations with mismatched aspect ratios are "squished".

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (181774 => 181775)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2015-03-20 00:53:33 UTC (rev 181774)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2015-03-20 01:37:14 UTC (rev 181775)
@@ -297,7 +297,6 @@
     Vector<WebsiteData::Entry> entries;
 
 #if USE(CFURLCACHE)
-    auto origins = cfURLCacheOrigins();
     for (auto& origin : cfURLCacheOrigins())
         entries.append(WebsiteData::Entry { WTF::move(origin), WebsiteDataTypeDiskCache });
 #endif
@@ -366,6 +365,52 @@
     completionHandler();
 }
 
+static void clearDiskCacheEntries(const Vector<SecurityOriginData>& origins, std::function<void ()> completionHandler)
+{
+#if ENABLE(NETWORK_CACHE)
+    if (NetworkCache::singleton().isEnabled()) {
+        auto* originsToDelete = new HashSet<RefPtr<SecurityOrigin>>();
+
+        for (auto& origin : origins)
+            originsToDelete->add(origin.securityOrigin());
+
+        auto* cacheKeysToDelete = new Vector<NetworkCache::Key>;
+
+        NetworkCache::singleton().traverse([completionHandler, originsToDelete, cacheKeysToDelete](const NetworkCache::Entry *entry) {
+
+            if (entry) {
+                if (originsToDelete->contains(SecurityOrigin::create(entry->response.url())))
+                    cacheKeysToDelete->append(entry->storageEntry.key);
+                return;
+            }
+
+            delete originsToDelete;
+
+            for (auto& key : *cacheKeysToDelete)
+                NetworkCache::singleton().remove(key);
+
+            delete cacheKeysToDelete;
+
+            RunLoop::main().dispatch(completionHandler);
+            return;
+        });
+
+        return;
+    }
+#endif
+
+#if USE(CFURLCACHE)
+    auto hostNames = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
+    for (auto& origin : origins)
+        CFArrayAppendValue(hostNames.get(), origin.host.createCFString().get());
+
+    CFShow(hostNames.get());
+    WebResourceCacheManager::clearCFURLCacheForHostNames(hostNames.get());
+#endif
+
+    RunLoop::main().dispatch(WTF::move(completionHandler));
+}
+
 void NetworkProcess::deleteWebsiteDataForOrigins(SessionID sessionID, uint64_t websiteDataTypes, const Vector<SecurityOriginData>& origins, const Vector<String>& cookieHostNames, uint64_t callbackID)
 {
     if (websiteDataTypes & WebsiteDataTypeCookies) {
@@ -379,6 +424,11 @@
         parentProcessConnection()->send(Messages::NetworkProcessProxy::DidDeleteWebsiteDataForOrigins(callbackID), 0);
     };
 
+    if ((websiteDataTypes & WebsiteDataTypeDiskCache) && !sessionID.isEphemeral()) {
+        clearDiskCacheEntries(origins, WTF::move(completionHandler));
+        return;
+    }
+
     completionHandler();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to