Skip to content
Permalink
Browse files
Query directly for cache partition names
https://bugs.webkit.org/show_bug.cgi?id=114538

Reviewed by David Kilzer.

Source/WebKit2:

Call back into WebKitSystemInterface to ask it for the cache
partition names instead of trying to figure them out.

* WebProcess/ResourceCache/WebResourceCacheManager.cpp:
(WebKit::WebResourceCacheManager::getCacheOrigins):
(WebKit):
(WebKit::WebResourceCacheManager::returnCacheOrigins):
* WebProcess/ResourceCache/WebResourceCacheManager.h:
(WebResourceCacheManager):
* WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp:
(WebKit::WebResourceCacheManager::cfURLCacheHostNames):
(WebKit):
(WebKit::WebResourceCacheManager::cfURLCacheHostNamesWithCallback):

WebKitLibraries:

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLion.a:
* libWebKitSystemInterfaceMountainLion.a:

Canonical link: https://commits.webkit.org/132930@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148329 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Jeffrey Pfau committed Apr 13, 2013
1 parent 9fa0fce commit 748e5e7b786727cc070a335eda7f906ffee6fc8b
Showing 8 changed files with 77 additions and 23 deletions.
@@ -1,3 +1,24 @@
2013-04-12 Jeffrey Pfau <jpfau@apple.com>

Query directly for cache partition names
https://bugs.webkit.org/show_bug.cgi?id=114538

Reviewed by David Kilzer.

Call back into WebKitSystemInterface to ask it for the cache
partition names instead of trying to figure them out.

* WebProcess/ResourceCache/WebResourceCacheManager.cpp:
(WebKit::WebResourceCacheManager::getCacheOrigins):
(WebKit):
(WebKit::WebResourceCacheManager::returnCacheOrigins):
* WebProcess/ResourceCache/WebResourceCacheManager.h:
(WebResourceCacheManager):
* WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp:
(WebKit::WebResourceCacheManager::cfURLCacheHostNames):
(WebKit):
(WebKit::WebResourceCacheManager::cfURLCacheHostNamesWithCallback):

2013-04-12 Gavin Barraclough <barraclough@apple.com>

Build fix - too soon!
@@ -53,20 +53,37 @@ WebResourceCacheManager::WebResourceCacheManager(WebProcess* process)

void WebResourceCacheManager::getCacheOrigins(uint64_t callbackID) const
{
#if USE(CFURLCACHE) && ENABLE(CACHE_PARTITIONING)
__block MemoryCache::SecurityOriginSet origins;
#else
MemoryCache::SecurityOriginSet origins;
#endif
memoryCache()->getOriginsWithCache(origins);

#if USE(CFURLCACHE)
RetainPtr<CFArrayRef> cfURLHosts = cfURLCacheHostNames();
CFIndex size = cfURLHosts ? CFArrayGetCount(cfURLHosts.get()) : 0;
#if ENABLE(CACHE_PARTITIONING)
cfURLCacheHostNamesWithCallback(^(RetainPtr<CFArrayRef> cfURLHosts) {
#else
RetainPtr<CFArrayRef> cfURLHosts = cfURLCacheHostNames();
#endif
CFIndex size = cfURLHosts ? CFArrayGetCount(cfURLHosts.get()) : 0;

String httpString("http");
for (CFIndex i = 0; i < size; ++i) {
CFStringRef host = static_cast<CFStringRef>(CFArrayGetValueAtIndex(cfURLHosts.get(), i));
origins.add(SecurityOrigin::create(httpString, host, 0));
}
String httpString("http");
for (CFIndex i = 0; i < size; ++i) {
CFStringRef host = static_cast<CFStringRef>(CFArrayGetValueAtIndex(cfURLHosts.get(), i));
origins.add(SecurityOrigin::create(httpString, host, 0));
}
#endif

returnCacheOrigins(callbackID, origins);

#if USE(CFURLCACHE) && ENABLE(CACHE_PARTITIONING)
});
#endif
}

void WebResourceCacheManager::returnCacheOrigins(uint64_t callbackID, const MemoryCache::SecurityOriginSet& origins) const
{
// Create a list with the origins in both of the caches.
Vector<SecurityOriginData> identifiers;
identifiers.reserveCapacity(origins.size());
@@ -29,6 +29,7 @@
#include "MessageReceiver.h"
#include "ResourceCachesToClear.h"
#include "WebProcessSupplement.h"
#include <WebCore/MemoryCache.h>
#include <wtf/Noncopyable.h>
#include <wtf/RetainPtr.h>
#include <wtf/text/WTFString.h>
@@ -51,11 +52,16 @@ class WebResourceCacheManager : public WebProcessSupplement, public CoreIPC::Mes
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;

void getCacheOrigins(uint64_t callbackID) const;
void returnCacheOrigins(uint64_t callbackID, const WebCore::MemoryCache::SecurityOriginSet&) const;
void clearCacheForOrigin(const SecurityOriginData&, uint32_t cachesToClear) const;
void clearCacheForAllOrigins(uint32_t cachesToClear) const;

#if USE(CFURLCACHE)
static RetainPtr<CFArrayRef> cfURLCacheHostNames();
#if ENABLE(CACHE_PARTITIONING)
typedef void (^CacheCallback)(RetainPtr<CFArrayRef>);
static void cfURLCacheHostNamesWithCallback(CacheCallback);
#endif
static void clearCFURLCacheForHostNames(CFArrayRef);
#endif

@@ -57,24 +57,20 @@ static RetainPtr<CFStringRef> partitionName(CFStringRef domain)

RetainPtr<CFArrayRef> WebResourceCacheManager::cfURLCacheHostNames()
{
RetainPtr<CFArrayRef> hostNames(AdoptCF, WKCFURLCacheCopyAllHostNamesInPersistentStore());
#if ENABLE(CACHE_PARTITIONING)
RetainPtr<CFMutableArrayRef> partitions(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
CFIndex size = CFArrayGetCount(hostNames.get());
for (CFIndex i = 0; i < size; ++i) {
RetainPtr<CFStringRef> partition = partitionName(static_cast<CFStringRef>(CFArrayGetValueAtIndex(hostNames.get(), i)));
RetainPtr<CFArrayRef> partitionHostNames(AdoptCF, WKCFURLCacheCopyAllHostNamesInPersistentStoreForPartition(partition.get()));
if (CFArrayGetCount(partitionHostNames.get()))
CFArrayAppendValue(partitions.get(), partition.get());
}
return RetainPtr<CFArrayRef>(AdoptCF, WKCFURLCacheCopyAllHostNamesInPersistentStore());
}

RetainPtr<CFArrayRef> rootHostNames(AdoptCF, WKCFURLCacheCopyAllHostNamesInPersistentStoreForPartition(CFSTR("")));
CFArrayAppendArray(partitions.get(), rootHostNames.get(), CFRangeMake(0, CFArrayGetCount(rootHostNames.get())));
return partitions;
#else
return hostNames;
#endif
#if ENABLE(CACHE_PARTITIONING)
void WebResourceCacheManager::cfURLCacheHostNamesWithCallback(CacheCallback callback)
{
WKCFURLCacheCopyAllPartitionNames(^(CFArrayRef partitionNames) {
CFMutableArrayRef hostNames = CFArrayCreateMutableCopy(0, 0, WKCFURLCacheCopyAllHostNamesInPersistentStoreForPartition(CFSTR("")));
CFArrayAppendArray(hostNames, partitionNames, CFRangeMake(0, CFArrayGetCount(partitionNames)));
CFRelease(partitionNames);
callback(adoptCF(hostNames));
});
}
#endif

void WebResourceCacheManager::clearCFURLCacheForHostNames(CFArrayRef hostNames)
{
@@ -1,3 +1,14 @@
2013-04-12 Jeffrey Pfau <jpfau@apple.com>

Query directly for cache partition names
https://bugs.webkit.org/show_bug.cgi?id=114538

Reviewed by David Kilzer.

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLion.a:
* libWebKitSystemInterfaceMountainLion.a:

2013-04-08 Roger Fong <roger_fong@apple.com>

Build fix.
@@ -501,8 +501,11 @@ void WKCFNetworkSetOverrideSystemProxySettings(CFDictionaryRef);
bool WKIsPublicSuffix(NSString *domain);

CFArrayRef WKCFURLCacheCopyAllHostNamesInPersistentStoreForPartition(CFStringRef partition);
typedef void (^CFURLCacheCopyAllPartitionNamesResultsNotification)(CFArrayRef partitionNames);

void WKCFURLCacheDeleteHostNamesInPersistentStoreForPartition(CFArrayRef hostArray, CFStringRef partition);
CFStringRef WKCachePartitionKey(void);
void WKCFURLCacheCopyAllPartitionNames(CFURLCacheCopyAllPartitionNamesResultsNotification resultsBlock);
#endif

#ifdef __cplusplus
Binary file not shown.
Binary file not shown.

0 comments on commit 748e5e7

Please sign in to comment.