Query directly for cache partition names
authorjpfau@apple.com <jpfau@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Apr 2013 01:09:47 +0000 (01:09 +0000)
committerjpfau@apple.com <jpfau@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Apr 2013 01:09:47 +0000 (01:09 +0000)
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:

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp
Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.h
Source/WebKit2/WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLion.a
WebKitLibraries/libWebKitSystemInterfaceMountainLion.a

index 5d76c53..d58fb73 100644 (file)
@@ -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!
index cdcc0de..602550f 100644 (file)
@@ -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());
index 4d1f176..1cebfa5 100644 (file)
@@ -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 @@ private:
     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
 
index 44a6e85..3f3e413 100644 (file)
@@ -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)
 {
index 7e6d76c..7d72d2b 100644 (file)
@@ -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.
index 329251a..7d9b9f5 100644 (file)
@@ -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
index e0516d3..a7c61c3 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLion.a and b/WebKitLibraries/libWebKitSystemInterfaceLion.a differ
index 9ecff34..7f3e753 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceMountainLion.a and b/WebKitLibraries/libWebKitSystemInterfaceMountainLion.a differ