WebKit2: The CFNetwork Cache should be shared between the UI Process and the Web...
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Feb 2011 22:23:26 +0000 (22:23 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Feb 2011 22:23:26 +0000 (22:23 +0000)
Windows.
https://bugs.webkit.org/show_bug.cgi?id=54683

Reviewed by Adam Roben.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:

* UIProcess/win/WebContextWin.cpp:
(WebKit::WebContext::platformInitializeWebProcess):
Make sure to remove the ending slash, as CFNetwork does not recognize the directory with
that slash.

* WebProcess/win/WebProcessWin.cpp:
(WebKit::WebProcess::platformInitializeWebProcess):
Create a cache using the path, disk capacity, and memory capacity and set it as default.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/win/WebContextWin.cpp
Source/WebKit2/WebProcess/win/WebProcessWin.cpp

index 4cf5d50..9149834 100644 (file)
@@ -1,3 +1,25 @@
+2011-02-17  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Adam Roben.
+
+        WebKit2: The CFNetwork Cache should be shared between the UI Process and the Web Process on
+        Windows.
+        https://bugs.webkit.org/show_bug.cgi?id=54683
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/win/WebContextWin.cpp:
+        (WebKit::WebContext::platformInitializeWebProcess):
+        Make sure to remove the ending slash, as CFNetwork does not recognize the directory with
+        that slash.
+
+        * WebProcess/win/WebProcessWin.cpp:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        Create a cache using the path, disk capacity, and memory capacity and set it as default.
+
 2011-02-17  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index 89b1009..a2014cb 100644 (file)
@@ -67,6 +67,9 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con
     encoder->encode(uiProcessBundleResourcePath);
 #elif PLATFORM(WIN)
     encoder->encode(shouldPaintNativeControls);
+    encoder->encode(cfURLCachePath);
+    encoder->encode(cfURLCacheDiskCapacity);
+    encoder->encode(cfURLCacheMemoryCapacity);
 #endif
 }
 
@@ -117,6 +120,12 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
 #elif PLATFORM(WIN)
     if (!decoder->decode(parameters.shouldPaintNativeControls))
         return false;
+    if (!decoder->decode(parameters.cfURLCachePath))
+        return false;
+    if (!decoder->decode(parameters.cfURLCacheDiskCapacity))
+        return false;
+    if (!decoder->decode(parameters.cfURLCacheMemoryCapacity))
+        return false;
 #endif
 
     return true;
index b157c94..7b25740 100644 (file)
@@ -85,6 +85,10 @@ struct WebProcessCreationParameters {
 
     CString uiProcessBundleResourcePath;
 #elif PLATFORM(WIN)
+    String cfURLCachePath;
+    uint64_t cfURLCacheDiskCapacity;
+    uint64_t cfURLCacheMemoryCapacity;
+
     bool shouldPaintNativeControls;
 #endif
 };
index 210d6cc..b1b7bb8 100644 (file)
 #include "WebProcessMessages.h"
 #include <WebCore/FileSystem.h>
 
+#if USE(CFNETWORK)
+#include <CFNetwork/CFURLCachePriv.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h> 
+#endif
+
 using namespace WebCore;
 
 namespace WebKit {
@@ -51,6 +56,17 @@ void WebContext::setShouldPaintNativeControls(bool b)
 void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
 {
     parameters.shouldPaintNativeControls = m_shouldPaintNativeControls;
+
+#if USE(CFNETWORK)
+    RetainPtr<CFURLCacheRef> cfurlCache(AdoptCF, CFURLCacheCopySharedURLCache());
+    parameters.cfURLCacheDiskCapacity = CFURLCacheDiskCapacity(cfurlCache.get());
+    parameters.cfURLCacheMemoryCapacity = CFURLCacheMemoryCapacity(cfurlCache.get());
+
+    RetainPtr<CFStringRef> cfURLCachePath(AdoptCF, wkCopyFoundationCacheDirectory());
+    parameters.cfURLCachePath = String(cfURLCachePath.get());
+    // Remove the ending '/' (necessary to have CFNetwork find the Cache file).
+    parameters.cfURLCachePath.remove(parameters.cfURLCachePath.length() - 1);
+#endif
 }
 
 String WebContext::platformDefaultDatabaseDirectory() const
index 97e2385..44d4b13 100644 (file)
@@ -108,6 +108,17 @@ void WebProcess::platformClearResourceCaches()
 void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters& parameters, CoreIPC::ArgumentDecoder*)
 {
     setShouldPaintNativeControls(parameters.shouldPaintNativeControls);
+
+#if USE(CFNETWORK)
+    RetainPtr<CFStringRef> cachePath(AdoptCF, parameters.cfURLCachePath.createCFString());
+    if (!cachePath)
+        return;
+
+    CFIndex cacheDiskCapacity = parameters.cfURLCacheDiskCapacity;
+    CFIndex cacheMemoryCapacity = parameters.cfURLCacheMemoryCapacity;
+    RetainPtr<CFURLCacheRef> uiProcessCache(AdoptCF, CFURLCacheCreate(kCFAllocatorDefault, cacheMemoryCapacity, cacheDiskCapacity, cachePath.get()));
+    CFURLCacheSetSharedURLCache(uiProcessCache.get());
+#endif
 }
 
 void WebProcess::platformShutdown()