[Win] Reduce the use of WKSI library calls: CFNetwork
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2018 21:43:11 +0000 (21:43 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Nov 2018 21:43:11 +0000 (21:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191718
<rdar://problem/46108732>

Reviewed by Alex Christensen.

Source/WebCore:

Remove custom WKSI CFNetwork calls, since the SPI is already documented in PAL. Just
make the same calls on Windows, like we did for iOS and macOS back in 2017.

Stop including WebKitSystemInterface.h for files that used to rely on it
for font-related features.

Tested by existing Windows regression tests. There should be no change in behavior.

* platform/graphics/win/FontCacheWin.cpp:
* platform/graphics/win/FontCustomPlatformData.cpp:
* platform/graphics/win/FontPlatformDataCGWin.cpp:
* platform/network/cf/CookieStorageCFNet.cpp:
* platform/network/cf/CredentialStorageCFNet.cpp:
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::createPrivateStorageSession):
(WebCore::NetworkStorageSession::switchToNewTestingSession):
(WebCore::NetworkStorageSession::ensureSession):
* platform/network/cf/ResourceError.h:
* platform/network/cf/ResourceErrorCF.cpp:
(WebCore::getSSLPeerCertificateData):
(WebCore::setSSLPeerCertificateData):
(WebCore::ResourceError::getSSLPeerCertificateDataBytePtr):
(WebCore::ResourceError::platformLazyInit):
(WebCore::ResourceError::cfError const):
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::setClientCertificateInSSLProperties):
(WebCore::ResourceHandle::createCFURLConnection):
* platform/network/cf/ResourceHandleCFURLConnectionDelegate.cpp:
* platform/network/cf/ResourceRequestCFNet.cpp:
* platform/network/cf/SocketStreamHandleImplCFNet.cpp:

Source/WebCore/PAL:

Add necessary declarations for CFNetwork SPI needed by the Apple Windows build.

* pal/PlatformAppleWin.cmake:
* pal/spi/cf/CFNetworkSPI.h:
* pal/spi/cf/CFNetworkSPIWin.cpp: Added.

Source/WebKitLegacy/win:

Remove custom WKSI CFNetwork calls, since the SPI is already documented in PAL. Just
make the same calls on Windows, like we did for iOS and macOS back in 2017.

* WebCache.cpp:
(WebCache::cacheFolder):
* WebCoreSupport/WebFrameNetworkingContext.cpp:
* WebCoreSupport/WebPlatformStrategies.cpp:
* WebError.cpp:
(WebError::localizedDescription):
(WebError::sslPeerCertificate):
* WebURLResponse.cpp:
(WebURLResponse::sslPeerCertificate):
(WebURLResponse::certificateDictionary const):
* WebView.cpp:
(WebView::setCacheModel):

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

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/PlatformAppleWin.cmake
Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h
Source/WebCore/PAL/pal/spi/cf/CFNetworkSPIWin.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/win/FontCacheWin.cpp
Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
Source/WebCore/platform/network/cf/CookieStorageCFNet.cpp
Source/WebCore/platform/network/cf/CredentialStorageCFNet.cpp
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
Source/WebCore/platform/network/cf/ResourceError.h
Source/WebCore/platform/network/cf/ResourceErrorCF.cpp
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegate.cpp
Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCache.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebFrameNetworkingContext.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKitLegacy/win/WebError.cpp
Source/WebKitLegacy/win/WebURLResponse.cpp
Source/WebKitLegacy/win/WebView.cpp

index 6b4b281..8409f6e 100644 (file)
@@ -1,3 +1,42 @@
+2018-11-16  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win] Reduce the use of WKSI library calls: CFNetwork
+        https://bugs.webkit.org/show_bug.cgi?id=191718
+        <rdar://problem/46108732>
+
+        Reviewed by Alex Christensen.
+
+        Remove custom WKSI CFNetwork calls, since the SPI is already documented in PAL. Just
+        make the same calls on Windows, like we did for iOS and macOS back in 2017.
+
+        Stop including WebKitSystemInterface.h for files that used to rely on it
+        for font-related features.
+        
+        Tested by existing Windows regression tests. There should be no change in behavior.
+
+        * platform/graphics/win/FontCacheWin.cpp:
+        * platform/graphics/win/FontCustomPlatformData.cpp:
+        * platform/graphics/win/FontPlatformDataCGWin.cpp:
+        * platform/network/cf/CookieStorageCFNet.cpp:
+        * platform/network/cf/CredentialStorageCFNet.cpp:
+        * platform/network/cf/NetworkStorageSessionCFNet.cpp:
+        (WebCore::createPrivateStorageSession):
+        (WebCore::NetworkStorageSession::switchToNewTestingSession):
+        (WebCore::NetworkStorageSession::ensureSession):
+        * platform/network/cf/ResourceError.h:
+        * platform/network/cf/ResourceErrorCF.cpp:
+        (WebCore::getSSLPeerCertificateData):
+        (WebCore::setSSLPeerCertificateData):
+        (WebCore::ResourceError::getSSLPeerCertificateDataBytePtr):
+        (WebCore::ResourceError::platformLazyInit):
+        (WebCore::ResourceError::cfError const):
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::setClientCertificateInSSLProperties):
+        (WebCore::ResourceHandle::createCFURLConnection):
+        * platform/network/cf/ResourceHandleCFURLConnectionDelegate.cpp:
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
+
 2018-11-16  Timothy Hatcher  <timothy@apple.com>
 
         Add html{color:text} to the simpleUserAgentStyleSheet on macOS.
index c522161..a1c517f 100644 (file)
@@ -1,3 +1,17 @@
+2018-11-16  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win] Reduce the use of WKSI library calls: CFNetwork
+        https://bugs.webkit.org/show_bug.cgi?id=191718
+        <rdar://problem/46108732>
+
+        Reviewed by Alex Christensen.
+
+        Add necessary declarations for CFNetwork SPI needed by the Apple Windows build.
+
+        * pal/PlatformAppleWin.cmake:
+        * pal/spi/cf/CFNetworkSPI.h:
+        * pal/spi/cf/CFNetworkSPIWin.cpp: Added.
+
 2018-11-16  Chris Dumez  <cdumez@apple.com>
 
         [Mac] Regression: WebContent process's display name is no longer set
index a1d2da2..e232b1e 100644 (file)
@@ -31,6 +31,8 @@ list(APPEND PAL_SOURCES
     cf/CoreMediaSoftLink.cpp
 
     crypto/win/CryptoDigestWin.cpp
+
+    spi/cf/CFNetworkSPIWin.cpp
 )
 
 list(APPEND PAL_PRIVATE_INCLUDE_DIRECTORIES
index d96bb1e..aa417da 100644 (file)
 #include <CFNetwork/CFURLResponsePriv.h>
 #include <CFNetwork/CFURLStorageSession.h>
 
+#if PLATFORM(WIN)
+
+WTF_EXTERN_C_BEGIN
+
+CFN_EXPORT CFStringRef _CFNetworkErrorGetLocalizedDescription(CFIndex);
+
+extern const CFStringRef _kCFWindowsSSLLocalCert;
+extern const CFStringRef _kCFStreamPropertyWindowsSSLCertInfo;
+extern const CFStringRef _kCFWindowsSSLPeerCert;
+
+WTF_EXTERN_C_END
+
+#endif
+
 // FIXME: Remove the defined(__OBJC__)-guard once we fix <rdar://problem/19033610>.
 #if defined(__OBJC__) && PLATFORM(COCOA)
 #import <CFNetwork/CFNSURLConnection.h>
diff --git a/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPIWin.cpp b/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPIWin.cpp
new file mode 100644 (file)
index 0000000..2dab105
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2018 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"
+
+#if PLATFORM(WIN) && USE(CFURLCONNECTION)
+
+#include <pal/spi/cf/CFNetworkSPI.h>
+
+const CFStringRef _kCFWindowsSSLLocalCert = CFSTR("_kCFWindowsSSLLocalCert");
+const CFStringRef _kCFWindowsSSLPeerCert = CFSTR("_kCFWindowsSSLPeerCert");
+const CFStringRef _kCFStreamPropertyWindowsSSLCertInfo = CFSTR("_kCFStreamPropertyWindowsSSLCertInfo");
+
+#endif // PLATFORM(WIN) && USE(CFURLCONNECTION)
index 2816cb5..7962876 100644 (file)
@@ -43,7 +43,6 @@
 #include <wtf/win/GDIObject.h>
 
 #if USE(CG)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <pal/spi/cg/CoreGraphicsSPI.h>
 #endif
 
index 2facb3f..1a62d33 100644 (file)
@@ -30,7 +30,7 @@
 #include <wtf/win/GDIObject.h>
 
 #if USE(CG)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cg/CoreGraphicsSPI.h>
 #endif
 
 #if USE(DIRECT2D)
index 31815f1..112bf95 100644 (file)
@@ -27,7 +27,7 @@
 #if USE(CG)
 
 #include "SharedGDIObject.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cg/CoreGraphicsSPI.h>
 #include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
index 43032dc..82d39bd 100644 (file)
@@ -29,7 +29,7 @@
 #include "LoaderRunLoopCF.h"
 #include "NetworkStorageSession.h"
 #include <CFNetwork/CFHTTPCookiesPriv.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #include <wtf/Function.h>
 #include <wtf/HashMap.h>
 #include <wtf/MainThread.h>
index 78ff203..2dd53ed 100644 (file)
@@ -31,7 +31,6 @@
 #include "AuthenticationCF.h"
 #include "Credential.h"
 #include "ProtectionSpace.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <pal/spi/cf/CFNetworkSPI.h>
 #include <wtf/RetainPtr.h>
 
index 4b6d43b..07dcf43 100644 (file)
@@ -34,8 +34,6 @@
 #if PLATFORM(COCOA)
 #include "PublicSuffix.h"
 #include "ResourceRequest.h"
-#else
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #endif
 #if USE(CFURLCONNECTION)
 #include "Cookie.h"
@@ -133,6 +131,42 @@ static std::unique_ptr<NetworkStorageSession>& defaultNetworkStorageSession()
     return session;
 }
 
+#if !PLATFORM(COCOA)
+static CFURLStorageSessionRef createPrivateStorageSession(CFStringRef identifier, CFURLStorageSessionRef defaultStorageSession)
+{
+    const void* sessionPropertyKeys[] = { _kCFURLStorageSessionIsPrivate };
+    const void* sessionPropertyValues[] = { kCFBooleanTrue };
+    CFDictionaryRef sessionProperties = CFDictionaryCreate(kCFAllocatorDefault, sessionPropertyKeys, sessionPropertyValues, sizeof(sessionPropertyKeys) / sizeof(*sessionPropertyKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    CFURLStorageSessionRef storageSession = _CFURLStorageSessionCreate(kCFAllocatorDefault, identifier, sessionProperties);
+
+    // The private storage session should have the same properties as the default storage session,
+    // with the exception that it should be in-memory only storage.
+    CFURLCacheRef cache = _CFURLStorageSessionCopyCache(kCFAllocatorDefault, storageSession);
+    CFURLCacheSetDiskCapacity(cache, 0);
+    CFURLCacheRef defaultCache;
+    if (defaultStorageSession)
+        defaultCache = _CFURLStorageSessionCopyCache(kCFAllocatorDefault, defaultStorageSession);
+    else 
+        defaultCache = CFURLCacheCopySharedURLCache();
+    CFURLCacheSetMemoryCapacity(cache, CFURLCacheMemoryCapacity(defaultCache));
+    CFRelease(defaultCache);
+    CFRelease(cache);
+
+    CFHTTPCookieStorageRef cookieStorage = _CFURLStorageSessionCopyCookieStorage(kCFAllocatorDefault, storageSession);
+    CFHTTPCookieStorageRef defaultCookieStorage;
+    if (defaultStorageSession)
+        defaultCookieStorage = _CFURLStorageSessionCopyCookieStorage(kCFAllocatorDefault, defaultStorageSession);
+    else
+        defaultCookieStorage = _CFHTTPCookieStorageGetDefault(kCFAllocatorDefault);
+    CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage, CFHTTPCookieStorageGetCookieAcceptPolicy(defaultCookieStorage));
+    if (defaultStorageSession)
+        CFRelease(defaultCookieStorage);
+    CFRelease(cookieStorage);
+
+    return storageSession;
+}
+#endif
+
 void NetworkStorageSession::switchToNewTestingSession()
 {
     // Session name should be short enough for shared memory region name to be under the limit, otehrwise sandbox rules won't work (see <rdar://problem/13642852>).
@@ -142,7 +176,7 @@ void NetworkStorageSession::switchToNewTestingSession()
 #if PLATFORM(COCOA)
     session = adoptCF(createPrivateStorageSession(sessionName.createCFString().get()));
 #else
-    session = adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get(), defaultStorageSession().platformSession()));
+    session = adoptCF(createPrivateStorageSession(sessionName.createCFString().get(), defaultStorageSession().platformSession()));
 #endif
 
     RetainPtr<CFHTTPCookieStorageRef> cookieStorage;
@@ -175,7 +209,7 @@ void NetworkStorageSession::ensureSession(PAL::SessionID sessionID, const String
 #if PLATFORM(COCOA)
         storageSession = adoptCF(createPrivateStorageSession(cfIdentifier.get()));
 #else
-        storageSession = adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get(), defaultNetworkStorageSession()->platformSession()));
+        storageSession = adoptCF(createPrivateStorageSession(cfIdentifier.get(), defaultNetworkStorageSession()->platformSession()));
 #endif
     } else
         storageSession = createCFStorageSessionForIdentifier(cfIdentifier.get());
index 40701ac..e444888 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2018 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -72,6 +72,8 @@ public:
     ResourceError(CFStreamError error);
     CFStreamError cfStreamError() const;
     operator CFStreamError() const;
+    static const void* getSSLPeerCertificateDataBytePtr(CFDictionaryRef);
+
 #endif
 
 #if PLATFORM(COCOA)
index ba3605b..289e597 100644 (file)
@@ -31,7 +31,7 @@
 #include "URL.h"
 #include <CoreFoundation/CFError.h>
 #include <CFNetwork/CFNetworkErrors.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #include <wtf/RetainPtr.h>
 
 namespace WebCore {
@@ -68,6 +68,30 @@ void ResourceError::setCertificate(CFDataRef certificate)
 const CFStringRef failingURLStringKey = CFSTR("NSErrorFailingURLStringKey");
 const CFStringRef failingURLKey = CFSTR("NSErrorFailingURLKey");
 
+static CFDataRef getSSLPeerCertificateData(CFDictionaryRef dict)
+{
+    if (!dict)
+        return nullptr;
+    return reinterpret_cast<CFDataRef>(CFDictionaryGetValue(dict, _kCFWindowsSSLPeerCert));
+}
+
+static void setSSLPeerCertificateData(CFMutableDictionaryRef dict, CFDataRef data)
+{
+    if (!dict)
+        return;
+    
+    if (!data)
+        CFDictionaryRemoveValue(dict, _kCFWindowsSSLPeerCert);
+    else
+        CFDictionarySetValue(dict, _kCFWindowsSSLPeerCert, data);
+}
+
+const void* ResourceError::getSSLPeerCertificateDataBytePtr(CFDictionaryRef dict)
+{
+    CFDataRef data = getSSLPeerCertificateData(dict);
+    return data ? reinterpret_cast<const void*>(CFDataGetBytePtr(data)) : nullptr;
+}
+
 void ResourceError::platformLazyInit()
 {
     if (m_dataIsUpToDate)
@@ -106,7 +130,7 @@ void ResourceError::platformLazyInit()
         }
         m_localizedDescription = (CFStringRef) CFDictionaryGetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey);
         
-        m_certificate = wkGetSSLPeerCertificateData(userInfo.get());
+        m_certificate = getSSLPeerCertificateData(userInfo.get());
     }
 
     m_dataIsUpToDate = true;
@@ -144,7 +168,7 @@ CFErrorRef ResourceError::cfError() const
         }
 
         if (m_certificate)
-            wkSetSSLPeerCertificateData(userInfo.get(), m_certificate.get());
+            setSSLPeerCertificateData(userInfo.get(), m_certificate.get());
         
         m_platformError = adoptCF(CFErrorCreate(0, m_domain.createCFString().get(), m_errorCode, userInfo.get()));
     }
index ab27248..81ae410 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -57,7 +57,6 @@
 #include <wtf/text/CString.h>
 
 #if PLATFORM(WIN)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <process.h>
 
 // FIXME: Remove this declaration once it's in WebKitSupportLibrary.
@@ -118,6 +117,20 @@ static inline CFStringRef shouldSniffConnectionProperty()
 #endif
 }
 
+#if PLATFORM(WIN)
+static void setClientCertificateInSSLProperties(CFMutableDictionaryRef sslProps, CFDataRef certData)
+{
+    if (!sslProps || !certData)
+        return;
+    CFMutableDictionaryRef certDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    if (!certDict)
+        return;
+    CFDictionarySetValue(certDict, _kCFWindowsSSLLocalCert, certData);
+    CFDictionarySetValue(sslProps, _kCFStreamPropertyWindowsSSLCertInfo, certDict);
+    CFRelease(certDict);
+}
+#endif
+
 void ResourceHandle::createCFURLConnection(bool shouldUseCredentialStorage, bool shouldContentSniff, bool shouldContentEncodingSniff, MessageQueue<Function<void()>>* messageQueue, CFDictionaryRef clientProperties)
 {
     if ((!d->m_user.isEmpty() || !d->m_pass.isEmpty()) && !firstRequest().url().protocolIsInHTTPFamily()) {
@@ -186,7 +199,7 @@ void ResourceHandle::createCFURLConnection(bool shouldUseCredentialStorage, bool
         if (!sslProps)
             sslProps = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
 #if PLATFORM(WIN)
-        wkSetClientCertificateInSSLProperties(sslProps.get(), (clientCert->value).get());
+        setClientCertificateInSSLProperties(sslProps.get(), (clientCert->value).get());
 #endif
     }
 #endif // PLATFORM(IOS_FAMILY)
index a7b9c81..4bfb401 100644 (file)
@@ -31,7 +31,6 @@
 #include "FormDataStreamCFNet.h"
 #include "NetworkingContext.h"
 #include "ResourceHandle.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <pal/spi/cf/CFNetworkSPI.h>
 
 namespace WebCore {
index 33b2093..c237904 100644 (file)
 #include <dlfcn.h>
 #endif
 
-#if PLATFORM(WIN)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#endif
-
 WTF_DECLARE_CF_TYPE_TRAIT(CFURL);
 
 namespace WebCore {
index 65df8c6..ca73b70 100644 (file)
@@ -50,7 +50,7 @@
 
 #if PLATFORM(WIN)
 #include "LoaderRunLoopCF.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #endif
 
 #if PLATFORM(IOS_FAMILY)
index 0934704..e4696d9 100644 (file)
@@ -1,3 +1,27 @@
+2018-11-16  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win] Reduce the use of WKSI library calls: CFNetwork
+        https://bugs.webkit.org/show_bug.cgi?id=191718
+        <rdar://problem/46108732>
+
+        Reviewed by Alex Christensen.
+
+        Remove custom WKSI CFNetwork calls, since the SPI is already documented in PAL. Just
+        make the same calls on Windows, like we did for iOS and macOS back in 2017.
+
+        * WebCache.cpp:
+        (WebCache::cacheFolder):
+        * WebCoreSupport/WebFrameNetworkingContext.cpp:
+        * WebCoreSupport/WebPlatformStrategies.cpp:
+        * WebError.cpp:
+        (WebError::localizedDescription):
+        (WebError::sslPeerCertificate):
+        * WebURLResponse.cpp:
+        (WebURLResponse::sslPeerCertificate):
+        (WebURLResponse::certificateDictionary const):
+        * WebView.cpp:
+        (WebView::setCacheModel):
+
 2018-11-15  Brent Fulgham  <bfulgham@apple.com>
 
         [Win] Reduce the use of WKSI library calls: Font Handling
index 4bf8ef0..b762fd6 100644 (file)
@@ -37,7 +37,7 @@
 #include <WebCore/CurlCacheManager.h>
 #elif USE(CFURLCONNECTION)
 #include <CFNetwork/CFURLCachePriv.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #endif
 
 using namespace WebCore;
@@ -249,7 +249,8 @@ HRESULT WebCache::cacheFolder(__deref_out_opt BSTR* location)
     *location = WebCore::BString(cacheFolder).release();
     return S_OK;
 #elif USE(CFURLCONNECTION)
-    RetainPtr<CFStringRef> cfurlCacheDirectory = adoptCF(wkCopyFoundationCacheDirectory(0));
+    RetainPtr<CFURLCacheRef> cache = adoptCF(CFURLCacheCopySharedURLCache());
+    RetainPtr<CFStringRef> cfurlCacheDirectory = adoptCF(_CFURLCacheCopyCacheDirectory(cache.get()));
     *location = BString(cfurlCacheDirectory.get()).release();
     return S_OK;
 #else
index adc1cb7..7ff8529 100644 (file)
@@ -36,7 +36,7 @@
 
 #if USE(CFURLCONNECTION)
 #include <CFNetwork/CFHTTPCookiesPriv.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #endif
 
 using namespace WebCore;
index fab4218..7eb6c56 100644 (file)
@@ -34,7 +34,7 @@
 #include <WebCore/PageGroup.h>
 
 #if USE(CFURLCONNECTION)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #endif
 
 using namespace WebCore;
index 3107573..7c2d10a 100644 (file)
@@ -34,7 +34,7 @@
 #endif
 
 #if USE(CFURLCONNECTION)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #endif
 
 using namespace WebCore;
@@ -138,7 +138,7 @@ HRESULT WebError::localizedDescription(__deref_opt_out BSTR* result)
 #if USE(CFURLCONNECTION)
     if (!*result) {
         if (int code = m_error.errorCode())
-            *result = BString(wkCFNetworkErrorGetLocalizedDescription(code)).release();
+            *result = BString(_CFNetworkErrorGetLocalizedDescription(code)).release();
     }
 #endif
 
@@ -229,10 +229,10 @@ HRESULT WebError::sslPeerCertificate(_Out_ ULONG_PTR* result)
     if (!m_cfErrorUserInfoDict)
         return E_FAIL;
 
-    void* data = wkGetSSLPeerCertificateDataBytePtr(m_cfErrorUserInfoDict.get());
+    const void* data = ResourceError::getSSLPeerCertificateDataBytePtr(m_cfErrorUserInfoDict.get());
     if (!data)
         return E_FAIL;
-    *result = reinterpret_cast<ULONG_PTR>(data);
+    *result = reinterpret_cast<ULONG_PTR>(const_cast<void*>(data));
 #endif
     return *result ? S_OK : E_FAIL;
 }
index 4576c22..a6082b4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2018 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #endif
 
 #if USE(CFURLCONNECTION)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #endif
 
 #include <WebCore/BString.h>
 #include <WebCore/URL.h>
 #include <WebCore/LocalizedStrings.h>
+#include <WebCore/ResourceError.h>
 #include <WebCore/ResourceHandle.h>
 #include <shlobj.h>
 #include <shlwapi.h>
@@ -410,10 +411,10 @@ HRESULT WebURLResponse::sslPeerCertificate(_Out_ ULONG_PTR* result)
     CFDictionaryRef dict = certificateDictionary();
     if (!dict)
         return E_FAIL;
-    void* data = wkGetSSLPeerCertificateDataBytePtr(dict);
+    const void* data = ResourceError::getSSLPeerCertificateDataBytePtr(dict);
     if (!data)
         return E_FAIL;
-    *result = reinterpret_cast<ULONG_PTR>(data);
+    *result = reinterpret_cast<ULONG_PTR>(const_cast<void*>(data));
 #endif
 
     return *result ? S_OK : E_FAIL;
@@ -484,7 +485,7 @@ CFDictionaryRef WebURLResponse::certificateDictionary() const
     CFURLResponseRef cfResponse = m_response.cfURLResponse();
     if (!cfResponse)
         return nullptr;
-    m_SSLCertificateInfo = wkGetSSLCertificateInfo(cfResponse);
+    m_SSLCertificateInfo = _CFURLResponseGetSSLCertificateContext(cfResponse);
     return m_SSLCertificateInfo.get();
 }
 #endif
index ec45e39..acad84e 100644 (file)
 #if USE(CFURLCONNECTION)
 #include <CFNetwork/CFURLCachePriv.h>
 #include <CFNetwork/CFURLProtocolPriv.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#include <WebCore/CFURLExtras.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #elif USE(CURL)
 #include <WebCore/CurlCacheManager.h>
 #endif
@@ -505,7 +506,7 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
 
 #if USE(CFURLCONNECTION)
     RetainPtr<CFURLCacheRef> cfurlCache = adoptCF(CFURLCacheCopySharedURLCache());
-    RetainPtr<CFStringRef> cfurlCacheDirectory = adoptCF(wkCopyFoundationCacheDirectory(0));
+    RetainPtr<CFStringRef> cfurlCacheDirectory = adoptCF(_CFURLCacheCopyCacheDirectory(cfurlCache.get()));
     if (!cfurlCacheDirectory) {
         RetainPtr<CFPropertyListRef> preference = adoptCF(CFPreferencesCopyAppValue(WebKitLocalCacheDefaultsKey, WebPreferences::applicationId()));
         if (preference && (CFStringGetTypeID() == CFGetTypeID(preference.get())))