Source/JavaScriptCore: WebResourceCacheManager should be responsible for managing...
authorbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Feb 2011 22:26:56 +0000 (22:26 +0000)
committerbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Feb 2011 22:26:56 +0000 (22:26 +0000)
as the WebCore memory cache.
https://bugs.webkit.org/show_bug.cgi?id=54886
Part of <rdar://problem/8971738>

Reviewed by Adam Roben.

Add a new use flag for using the CFURLCache.

* wtf/Platform.h:

Source/WebKit2: WebResourceCacheManager should be responsible for managing the CFURLCache as well
as the WebCore memory cache.
https://bugs.webkit.org/show_bug.cgi?id=54886
Part of <rdar://problem/8971738>

Reviewed by Adam Roben.

* WebProcess/ResourceCache/WebResourceCacheManager.cpp:
(WebKit::WebResourceCacheManager::getCacheOrigins): Call through to cFURLCacheHostNames, and add
    create SecurityOrigin's for them and add them to the set of SecurityOrigins with cache.
(WebKit::WebResourceCacheManager::clearCacheForOrigin): Call through to clear the CFURLCache for
    the origin's hostname.
* WebProcess/ResourceCache/WebResourceCacheManager.h:

* WebProcess/ResourceCache/cf: Added.
* WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp: Added.
(WebKit::WebResourceCacheManager::cfURLCacheHostNames): Call through to WebKitSystemInterface.
(WebKit::WebResourceCacheManager::clearCFURLCacheForHostNames): Ditto.

* win/WebKit2.vcproj: Added new file.
* WebKit2.xcodeproj/project.pbxproj: Ditto.

WebKitLibraries: WebResourceCacheManager should be responsible for managing the CFURLCache as well
as the WebCore memory cache.
https://bugs.webkit.org/show_bug.cgi?id=54886
Part of <rdar://problem/8971738>

Reviewed by Adam Roben.

Update WebKitSystemInterface headers and libraries with new functions.

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLeopard.a:
* libWebKitSystemInterfaceSnowLeopard.a:
* win/include/WebKitSystemInterface/WebKitSystemInterface.h:
* win/lib/WebKitSystemInterface.lib:

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

14 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wtf/Platform.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp
Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.h
Source/WebKit2/WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp [new file with mode: 0644]
Source/WebKit2/win/WebKit2.vcproj
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a
WebKitLibraries/win/include/WebKitSystemInterface/WebKitSystemInterface.h
WebKitLibraries/win/lib/WebKitSystemInterface.lib

index 104973a..94600ef 100644 (file)
@@ -1,3 +1,16 @@
+2011-02-21  Brian Weinstein  <bweinstein@apple.com>
+
+        Reviewed by Adam Roben.
+
+        WebResourceCacheManager should be responsible for managing the CFURLCache as well
+        as the WebCore memory cache.
+        https://bugs.webkit.org/show_bug.cgi?id=54886
+        Part of <rdar://problem/8971738>
+
+        Add a new use flag for using the CFURLCache.
+
+        * wtf/Platform.h:
+
 2011-02-21  Xan Lopez  <xlopez@igalia.com>
 
         Reviewed by Gavin Barraclough.
index 7d146dd..1a9afcb 100644 (file)
 #define WTF_USE_CFNETWORK 1
 #endif
 
+#if USE(CFNETWORK) || PLATFORM(MAC)
+#define WTF_USE_CFURLCACHE 1
+#endif
+
 #if PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(CHROMIUM) && !PLATFORM(QT)
 #define ENABLE_WEB_ARCHIVE 1
 #endif
index aa4cb9e..608a6e5 100644 (file)
@@ -1,3 +1,27 @@
+2011-02-18  Brian Weinstein  <bweinstein@apple.com>
+
+        Reviewed by Adam Roben.
+
+        WebResourceCacheManager should be responsible for managing the CFURLCache as well
+        as the WebCore memory cache.
+        https://bugs.webkit.org/show_bug.cgi?id=54886
+        Part of <rdar://problem/8971738>
+
+        * WebProcess/ResourceCache/WebResourceCacheManager.cpp:
+        (WebKit::WebResourceCacheManager::getCacheOrigins): Call through to cFURLCacheHostNames, and add
+            create SecurityOrigin's for them and add them to the set of SecurityOrigins with cache.
+        (WebKit::WebResourceCacheManager::clearCacheForOrigin): Call through to clear the CFURLCache for
+            the origin's hostname.
+        * WebProcess/ResourceCache/WebResourceCacheManager.h:
+
+        * WebProcess/ResourceCache/cf: Added.
+        * WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp: Added.
+        (WebKit::WebResourceCacheManager::cfURLCacheHostNames): Call through to WebKitSystemInterface.
+        (WebKit::WebResourceCacheManager::clearCFURLCacheForHostNames): Ditto.
+
+        * win/WebKit2.vcproj: Added new file.
+        * WebKit2.xcodeproj/project.pbxproj: Ditto.
+
 2011-02-21  Adam Roben  <aroben@apple.com>
 
         Move control of the sequence number from DrawingAreaImpl to DrawingAreaProxyImpl
index c9813b9..e5148c4 100644 (file)
                33367656130C9ECA006C9DE2 /* WebResourceCacheManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 33367652130C9ECA006C9DE2 /* WebResourceCacheManagerMessages.h */; };
                33367657130C9ECA006C9DE2 /* WebResourceCacheManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33367653130C9ECA006C9DE2 /* WebResourceCacheManagerProxyMessageReceiver.cpp */; };
                33367658130C9ECB006C9DE2 /* WebResourceCacheManagerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 33367654130C9ECA006C9DE2 /* WebResourceCacheManagerProxyMessages.h */; };
+               33F9D5B91312F1EE000D683F /* WebResourceCacheManagerCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33F9D5B81312F1EE000D683F /* WebResourceCacheManagerCFNet.cpp */; };
                37F623B812A57B6200E3FDF6 /* WKFindOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 37F623B712A57B6200E3FDF6 /* WKFindOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
                51021E9C12B16788005C033C /* WebContextMenuClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */; };
                510FBB9A1288C95E00AFFDF4 /* WebContextMenuItemData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510FBB981288C95E00AFFDF4 /* WebContextMenuItemData.cpp */; };
                33367652130C9ECA006C9DE2 /* WebResourceCacheManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceCacheManagerMessages.h; sourceTree = "<group>"; };
                33367653130C9ECA006C9DE2 /* WebResourceCacheManagerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceCacheManagerProxyMessageReceiver.cpp; sourceTree = "<group>"; };
                33367654130C9ECA006C9DE2 /* WebResourceCacheManagerProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceCacheManagerProxyMessages.h; sourceTree = "<group>"; };
+               33F9D5B81312F1EE000D683F /* WebResourceCacheManagerCFNet.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = WebResourceCacheManagerCFNet.cpp; path = ResourceCache/cf/WebResourceCacheManagerCFNet.cpp; sourceTree = "<group>"; };
                37F623B712A57B6200E3FDF6 /* WKFindOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFindOptions.h; sourceTree = "<group>"; };
                51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContextMenuClientMac.mm; sourceTree = "<group>"; };
                510FBB981288C95E00AFFDF4 /* WebContextMenuItemData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextMenuItemData.cpp; sourceTree = "<group>"; };
                3336762B130C9978006C9DE2 /* ResourceCache */ = {
                        isa = PBXGroup;
                        children = (
+                               33F9D5B71312F1B1000D683F /* cf */,
                                3336762C130C9998006C9DE2 /* WebResourceCacheManager.cpp */,
                                3336762D130C9998006C9DE2 /* WebResourceCacheManager.h */,
                                3336762E130C9998006C9DE2 /* WebResourceCacheManager.messages.in */,
                        name = ResourceCache;
                        sourceTree = "<group>";
                };
+               33F9D5B71312F1B1000D683F /* cf */ = {
+                       isa = PBXGroup;
+                       children = (
+                               33F9D5B81312F1EE000D683F /* WebResourceCacheManagerCFNet.cpp */,
+                       );
+                       name = cf;
+                       sourceTree = "<group>";
+               };
                512F588612A8834700629530 /* Authentication */ = {
                        isa = PBXGroup;
                        children = (
                                33367655130C9ECA006C9DE2 /* WebResourceCacheManagerMessageReceiver.cpp in Sources */,
                                33367657130C9ECA006C9DE2 /* WebResourceCacheManagerProxyMessageReceiver.cpp in Sources */,
                                33152975130D0CB200ED2483 /* SecurityOriginData.cpp in Sources */,
+                               33F9D5B91312F1EE000D683F /* WebResourceCacheManagerCFNet.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index c2b48df..1e98adc 100644 (file)
@@ -65,6 +65,18 @@ void WebResourceCacheManager::getCacheOrigins(uint64_t callbackID) const
     MemoryCache::SecurityOriginSet origins;
     memoryCache()->getOriginsWithCache(origins);
 
+#if USE(CFURLCACHE)
+    RetainPtr<CFArrayRef> cfURLHosts = cfURLCacheHostNames(); 
+    CFIndex size = CFArrayGetCount(cfURLHosts.get());
+
+    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
+
+    // Create a list with the origins in both of the caches.
     Vector<SecurityOriginData> identifiers;
     identifiers.reserveCapacity(origins.size());
 
@@ -90,6 +102,14 @@ void WebResourceCacheManager::clearCacheForOrigin(SecurityOriginData originData)
         return;
 
     memoryCache()->removeResourcesWithOrigin(origin.get());
+
+#if USE(CFURLCACHE)
+    RetainPtr<CFMutableArrayRef> hostArray(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
+    RetainPtr<CFStringRef> host(AdoptCF, origin->host().createCFString());
+    CFArrayAppendValue(hostArray.get(), host.get());
+
+    clearCFURLCacheForHostNames(hostArray.get());
+#endif
 }
 
 void WebResourceCacheManager::clearCacheForAllOrigins() const
index 7c66a47..3a29a4b 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "Arguments.h"
 #include <wtf/Noncopyable.h>
+#include <wtf/RetainPtr.h>
 #include <wtf/text/WTFString.h>
 
 namespace CoreIPC {
@@ -57,6 +58,11 @@ private:
     void getCacheOrigins(uint64_t callbackID) const;
     void clearCacheForOrigin(SecurityOriginData origin) const;
     void clearCacheForAllOrigins() const;
+
+#if USE(CFURLCACHE)
+    static RetainPtr<CFArrayRef> cfURLCacheHostNames();
+    static void clearCFURLCacheForHostNames(CFArrayRef);
+#endif
 };
 
 } // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp b/Source/WebKit2/WebProcess/ResourceCache/cf/WebResourceCacheManagerCFNet.cpp
new file mode 100644 (file)
index 0000000..86372cf
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebResourceCacheManager.h"
+
+#if USE(CFURLCACHE)
+
+#if PLATFORM(WIN)
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#elif PLATFORM(MAC)
+#include "WebKitSystemInterface.h"
+#endif
+
+
+namespace WebKit {
+
+#if PLATFORM(WIN)
+// The Windows version of WKSI defines these functions as capitalized, while the Mac version defines them as lower case.
+static inline CFArrayRef WKCFURLCacheCopyAllHostNamesInPersistentStore() { return wkCFURLCacheCopyAllHostNamesInPersistentStore(); }
+static inline void WKCFURLCacheDeleteHostNamesInPersistentStore(CFArrayRef hostNames) { return wkCFURLCacheDeleteHostNamesInPersistentStore(hostNames); }
+#endif
+
+RetainPtr<CFArrayRef> WebResourceCacheManager::cfURLCacheHostNames()
+{
+    return RetainPtr<CFArrayRef>(AdoptCF, WKCFURLCacheCopyAllHostNamesInPersistentStore());
+}
+
+void WebResourceCacheManager::clearCFURLCacheForHostNames(CFArrayRef hostNames)
+{
+    WKCFURLCacheDeleteHostNamesInPersistentStore(hostNames);
+}
+
+} // namespace WebKit
+
+#endif // USE(CFURLCACHE)
index c22b938..f490875 100755 (executable)
             <Filter
                 Name="ResourceCache"
                 >
+                <Filter
+                                       Name="cf"
+                                       >
+                                       <File
+                                               RelativePath="..\WebProcess\ResourceCache\cf\WebResourceCacheManagerCFNet.cpp"
+                                               >
+                                       </File>
+                               </Filter>
                 <File
                                        RelativePath="..\WebProcess\ResourceCache\WebResourceCacheManager.cpp"
                                        >
index 9a69ffb..012b6a4 100644 (file)
@@ -1,5 +1,22 @@
 2011-02-21  Brian Weinstein  <bweinstein@apple.com>
 
+        Reviewed by Adam Roben.
+
+        WebResourceCacheManager should be responsible for managing the CFURLCache as well
+        as the WebCore memory cache.
+        https://bugs.webkit.org/show_bug.cgi?id=54886
+        Part of <rdar://problem/8971738>
+        
+        Update WebKitSystemInterface headers and libraries with new functions.
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLeopard.a:
+        * libWebKitSystemInterfaceSnowLeopard.a:
+        * win/include/WebKitSystemInterface/WebKitSystemInterface.h:
+        * win/lib/WebKitSystemInterface.lib:
+
+2011-02-21  Brian Weinstein  <bweinstein@apple.com>
+
         Rubber-stamped by Dan Bernstein.
 
         Update WebKitSystemInterface.h on Mac. The header that was in the tree didn't
index ae85034..fe7f8d2 100644 (file)
@@ -369,6 +369,9 @@ ScriptCode WKGetScriptCodeFromCurrentKeyboardInputSource(void);
 CFIndex WKGetHyphenationLocationBeforeIndex(CFStringRef string, CFIndex index);
 #endif
 
+CFArrayRef WKCFURLCacheCopyAllHostNamesInPersistentStore(void);
+void WKCFURLCacheDeleteHostNamesInPersistentStore(CFArrayRef hostArray);    
+
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
 typedef enum {
     WKSandboxExtensionTypeReadOnly,
index 55887f8..92fd648 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index 667c394..9e43171 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ
index 7f24a30..635b57b 100644 (file)
@@ -95,6 +95,9 @@ void wkSetClientCertificateInSSLProperties(CFMutableDictionaryRef, CFDataRef);
 CFArrayRef wkCFURLRequestCopyHTTPRequestBodyParts(CFURLRequestRef);
 void wkCFURLRequestSetHTTPRequestBodyParts(CFMutableURLRequestRef, CFArrayRef bodyParts);
 
+CFArrayRef wkCFURLCacheCopyAllHostNamesInPersistentStore();
+void wkCFURLCacheDeleteHostNamesInPersistentStore(CFArrayRef hostNames);
+
 unsigned wkInitializeMaximumHTTPConnectionCountPerHost(unsigned preferredConnectionCount);
 
 void wkSetCONNECTProxyForStream(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
index 90e9ceb..1adfd48 100644 (file)
Binary files a/WebKitLibraries/win/lib/WebKitSystemInterface.lib and b/WebKitLibraries/win/lib/WebKitSystemInterface.lib differ