Clear associated cache partitions when deleting origins' cache
authorjpfau@apple.com <jpfau@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2013 22:30:06 +0000 (22:30 +0000)
committerjpfau@apple.com <jpfau@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2013 22:30:06 +0000 (22:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111383

Reviewed by Maciej Stachowiak.

Source/WebCore:

Clear the cache partitions associated with the origin being cleared.

Not possible to test with current automated test tools, must be tested manually.

* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::removeResourcesWithOrigin):

Source/WebKit2:

Clear the cache partitions associated with the origin being cleared.

* WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp:
(WebKit):
(WebKit::partitionName):
(WebKit::WebResourceCacheManager::clearCFURLCacheForHostNames):

WebKitLibraries:

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

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

Source/WebCore/ChangeLog
Source/WebCore/loader/cache/MemoryCache.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLion.a
WebKitLibraries/libWebKitSystemInterfaceMountainLion.a

index 752cf04..f8c6256 100644 (file)
@@ -1,3 +1,17 @@
+2013-03-05  Jeffrey Pfau  <jpfau@apple.com>
+
+        Clear associated cache partitions when deleting origins' cache
+        https://bugs.webkit.org/show_bug.cgi?id=111383
+
+        Reviewed by Maciej Stachowiak.
+
+        Clear the cache partitions associated with the origin being cleared.
+
+        Not possible to test with current automated test tools, must be tested manually.
+
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::removeResourcesWithOrigin):
+
 2013-03-04  Ojan Vafai  <ojan@chromium.org>
 
         Inline min/maxInstrinsicLogicalWidth functions
index 03af02a..51d59df 100644 (file)
@@ -584,10 +584,19 @@ void MemoryCache::removeResourcesWithOrigin(SecurityOrigin* origin)
     Vector<CachedResource*> resourcesWithOrigin;
 
     CachedResourceMap::iterator e = m_resources.end();
+#if ENABLE(CACHE_PARTITIONING)
+    String originPartition = partitionName(origin->host());
+#endif
+
     for (CachedResourceMap::iterator it = m_resources.begin(); it != e; ++it) {
 #if ENABLE(CACHE_PARTITIONING)
         for (CachedResourceItem::iterator itemIterator = it->value->begin(); itemIterator != it->value->end(); ++itemIterator) {
             CachedResource* resource = itemIterator->value;
+            String partition = itemIterator->key;
+            if (partition == originPartition) {
+                resourcesWithOrigin.append(resource);
+                continue;
+            }
 #else
             CachedResource* resource = it->value;
 #endif
index 2f84578..46d79cc 100644 (file)
@@ -1,3 +1,17 @@
+2013-03-05  Jeffrey Pfau  <jpfau@apple.com>
+
+        Clear associated cache partitions when deleting origins' cache
+        https://bugs.webkit.org/show_bug.cgi?id=111383
+
+        Reviewed by Maciej Stachowiak.
+
+        Clear the cache partitions associated with the origin being cleared.
+
+        * WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp:
+        (WebKit):
+        (WebKit::partitionName):
+        (WebKit::WebResourceCacheManager::clearCFURLCacheForHostNames):
+
 2013-03-05  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [WK2][EFL] WebPageProxy::setThemePath() should check that the page is valid
index d286224..aced671 100644 (file)
 
 #if USE(CFURLCACHE)
 
+#if ENABLE(CACHE_PARTITIONING)
+#include <WebCore/PublicSuffix.h>
+#endif
+
 #if PLATFORM(MAC)
 #include "WebKitSystemInterface.h"
 #endif
 
 namespace WebKit {
 
+#if ENABLE(CACHE_PARTITIONING)
+static RetainPtr<CFStringRef> partitionName(CFStringRef domain)
+{
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+    String highLevel = WebCore::topPrivatelyControlledDomain(domain);
+    if (highLevel.isNull())
+        return 0;
+    return highLevel.createCFString();
+#else
+    return domain;
+#endif
+}
+#endif
+
 RetainPtr<CFArrayRef> WebResourceCacheManager::cfURLCacheHostNames()
 {
     return RetainPtr<CFArrayRef>(AdoptCF, WKCFURLCacheCopyAllHostNamesInPersistentStore());
@@ -43,6 +61,15 @@ RetainPtr<CFArrayRef> WebResourceCacheManager::cfURLCacheHostNames()
 void WebResourceCacheManager::clearCFURLCacheForHostNames(CFArrayRef hostNames)
 {
     WKCFURLCacheDeleteHostNamesInPersistentStore(hostNames);
+
+#if ENABLE(CACHE_PARTITIONING)
+    CFIndex size = CFArrayGetCount(hostNames);
+    for (CFIndex i = 0; i < size; ++i) {
+        RetainPtr<CFStringRef> partition = partitionName(static_cast<CFStringRef>(CFArrayGetValueAtIndex(hostNames, i)));
+        RetainPtr<CFArrayRef> partitionHostNames(AdoptCF, WKCFURLCacheCopyAllHostNamesInPersistentStoreForPartition(partition.get()));
+        WKCFURLCacheDeleteHostNamesInPersistentStoreForPartition(partitionHostNames.get(), partition.get());
+    }
+#endif
 }
 
 } // namespace WebKit
index 03b9eaa..a7cbac5 100644 (file)
@@ -1,3 +1,14 @@
+2013-03-05  Jeffrey Pfau  <jpfau@apple.com>
+
+        Clear associated cache partitions when deleting origins' cache
+        https://bugs.webkit.org/show_bug.cgi?id=111383
+
+        Reviewed by Maciej Stachowiak.
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLion.a:
+        * libWebKitSystemInterfaceMountainLion.a:
+
 2013-03-04  Kunihiko Sakamoto  <ksakamoto@chromium.org>
 
         Add build flag for FontLoader
index 8bc98fb..6c39578 100644 (file)
@@ -506,9 +506,11 @@ void WKCFNetworkSetOverrideSystemProxySettings(CFDictionaryRef);
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
 bool WKIsPublicSuffix(NSString *domain);
-#endif
 
+CFArrayRef WKCFURLCacheCopyAllHostNamesInPersistentStoreForPartition(CFStringRef partition);
+void WKCFURLCacheDeleteHostNamesInPersistentStoreForPartition(CFArrayRef hostArray, CFStringRef partition);
 CFStringRef WKCachePartitionKey(void);
+#endif
 
 #ifdef __cplusplus
 }
index a5edb73..a315c1c 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLion.a and b/WebKitLibraries/libWebKitSystemInterfaceLion.a differ
index 18924dc..437a8c1 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceMountainLion.a and b/WebKitLibraries/libWebKitSystemInterfaceMountainLion.a differ