2008-12-05 Darin Adler <darin@apple.com>
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Dec 2008 15:47:24 +0000 (15:47 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Dec 2008 15:47:24 +0000 (15:47 +0000)
        Reviewed by Alexey Proskuryakov.

        - fix https://bugs.webkit.org/show_bug.cgi?id=22674
          Webkit r39005 does not start, an entry point not found

        * WebView.cpp:
        (findCFNetworkModule): Added.
        (findCopySharedURLCacheFunction): Added.
        (WebView::setCacheModel): Call CFURLCacheCopySharedURLCache via dynamic loading
        instead of compiling based on which version of CFNetwork headers are present.

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

WebKit/win/ChangeLog
WebKit/win/WebView.cpp

index 843cbca..1f62542 100644 (file)
@@ -1,3 +1,16 @@
+2008-12-05  Darin Adler  <darin@apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        - fix https://bugs.webkit.org/show_bug.cgi?id=22674
+          Webkit r39005 does not start, an entry point not found
+
+        * WebView.cpp:
+        (findCFNetworkModule): Added.
+        (findCopySharedURLCacheFunction): Added.
+        (WebView::setCacheModel): Call CFURLCacheCopySharedURLCache via dynamic loading
+        instead of compiling based on which version of CFNetwork headers are present.
+
 2008-12-04  Steve Falkenburg  <sfalken@apple.com>
 
         Implement IPropertyBag2::Read.
index 6468fa1..bd892af 100644 (file)
@@ -125,6 +125,20 @@ static HashSet<WebView*> pendingDeleteBackingStoreSet;
 static String osVersion();
 static String webKitVersion();
 
+typedef CFURLCacheRef (*CopySharedURLCacheFunction)();
+
+static HMODULE findCFNetworkModule()
+{
+    if (HMODULE module = GetModuleHandleA("CFNetwork"))
+        return module;
+    return GetModuleHandleA("CFNetwork_debug");
+}
+
+static CopySharedURLCacheFunction findCopySharedURLCacheFunction()
+{
+    return reinterpret_cast<CopySharedURLCacheFunction>(GetProcAddress(findCFNetworkModule(), "CFURLCacheCopySharedURLCache"));
+}
+
 WebView* kit(Page* page)
 {
     return page ? static_cast<WebChromeClient*>(page->chrome()->client())->webView() : 0;
@@ -367,11 +381,14 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
     if (s_didSetCacheModel && cacheModel == s_cacheModel)
         return;
 
-#ifdef CFURLCacheCopySharedURLCachePresent
-    RetainPtr<CFURLCacheRef> cfurlCache(AdoptCF, CFURLCacheCopySharedURLCache());
-#else
-    RetainPtr<CFURLCacheRef> cfurlCache = CFURLCacheSharedURLCache();
-#endif
+    // Once we require a newer version of CFNetwork with the CFURLCacheCopySharedURLCache function,
+    // we can call CFURLCacheCopySharedURLCache directly and eliminate copySharedURLCache.
+    static CopySharedURLCacheFunction copySharedURLCache = findCopySharedURLCacheFunction();
+    RetainPtr<CFURLCacheRef> cfurlCache;
+    if (copySharedURLCache)
+        cfurlCache.adoptCF(copySharedURLCache());
+    else
+        cfurlCache = CFURLCacheSharedURLCache();
 
     RetainPtr<CFStringRef> cfurlCacheDirectory(AdoptCF, wkCopyFoundationCacheDirectory());
     if (!cfurlCacheDirectory)