Skip to content
Permalink
Browse files
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.

Canonical link: https://commits.webkit.org/160911@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181775 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Mar 20, 2015
1 parent 2b031c4 commit d6c8bba8ac0b9e382f5ffe55cd05635e02ffec4d
Showing with 68 additions and 1 deletion.
  1. +17 −0 Source/WebKit2/ChangeLog
  2. +51 −1 Source/WebKit2/NetworkProcess/NetworkProcess.cpp
@@ -1,3 +1,20 @@
2015-03-19 Anders Carlsson <andersca@apple.com>

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 <jer.noble@apple.com>

[WK2][Mac] Fullscreen animations with mismatched aspect ratios are "squished".
@@ -297,7 +297,6 @@ static void fetchDiskCacheEntries(SessionID sessionID, std::function<void (Vecto
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 @@ void NetworkProcess::deleteWebsiteData(SessionID sessionID, uint64_t websiteData
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 @@ void NetworkProcess::deleteWebsiteDataForOrigins(SessionID sessionID, uint64_t w
parentProcessConnection()->send(Messages::NetworkProcessProxy::DidDeleteWebsiteDataForOrigins(callbackID), 0);
};

if ((websiteDataTypes & WebsiteDataTypeDiskCache) && !sessionID.isEphemeral()) {
clearDiskCacheEntries(origins, WTF::move(completionHandler));
return;
}

completionHandler();
}

0 comments on commit d6c8bba

Please sign in to comment.