Title: [238298] trunk/Source
Revision
238298
Author
bfulg...@apple.com
Date
2018-11-16 13:43:11 -0800 (Fri, 16 Nov 2018)

Log Message

[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.

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):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (238297 => 238298)


--- trunk/Source/WebCore/ChangeLog	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/ChangeLog	2018-11-16 21:43:11 UTC (rev 238298)
@@ -1,3 +1,42 @@
+2018-11-16  Brent Fulgham  <bfulg...@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  <timo...@apple.com>
 
         Add html{color:text} to the simpleUserAgentStyleSheet on macOS.

Modified: trunk/Source/WebCore/PAL/ChangeLog (238297 => 238298)


--- trunk/Source/WebCore/PAL/ChangeLog	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/PAL/ChangeLog	2018-11-16 21:43:11 UTC (rev 238298)
@@ -1,3 +1,17 @@
+2018-11-16  Brent Fulgham  <bfulg...@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  <cdu...@apple.com>
 
         [Mac] Regression: WebContent process's display name is no longer set

Modified: trunk/Source/WebCore/PAL/pal/PlatformAppleWin.cmake (238297 => 238298)


--- trunk/Source/WebCore/PAL/pal/PlatformAppleWin.cmake	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/PAL/pal/PlatformAppleWin.cmake	2018-11-16 21:43:11 UTC (rev 238298)
@@ -31,6 +31,8 @@
     cf/CoreMediaSoftLink.cpp
 
     crypto/win/CryptoDigestWin.cpp
+
+    spi/cf/CFNetworkSPIWin.cpp
 )
 
 list(APPEND PAL_PRIVATE_INCLUDE_DIRECTORIES

Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (238297 => 238298)


--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2018-11-16 21:43:11 UTC (rev 238298)
@@ -50,6 +50,20 @@
 #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>

Added: trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPIWin.cpp (0 => 238298)


--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPIWin.cpp	                        (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPIWin.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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)

Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -43,7 +43,6 @@
 #include <wtf/win/GDIObject.h>
 
 #if USE(CG)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <pal/spi/cg/CoreGraphicsSPI.h>
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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)

Modified: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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>

Modified: trunk/Source/WebCore/platform/network/cf/CookieStorageCFNet.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/network/cf/CookieStorageCFNet.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/network/cf/CookieStorageCFNet.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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>

Modified: trunk/Source/WebCore/platform/network/cf/CredentialStorageCFNet.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/network/cf/CredentialStorageCFNet.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/network/cf/CredentialStorageCFNet.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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>
 

Modified: trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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 @@
     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 @@
 #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 @@
 #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());

Modified: trunk/Source/WebCore/platform/network/cf/ResourceError.h (238297 => 238298)


--- trunk/Source/WebCore/platform/network/cf/ResourceError.h	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/network/cf/ResourceError.h	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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 @@
     ResourceError(CFStreamError error);
     CFStreamError cfStreamError() const;
     operator CFStreamError() const;
+    static const void* getSSLPeerCertificateDataBytePtr(CFDictionaryRef);
+
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebCore/platform/network/cf/ResourceErrorCF.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/network/cf/ResourceErrorCF.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/network/cf/ResourceErrorCF.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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 @@
 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 = ""
+    return data ? reinterpret_cast<const void*>(CFDataGetBytePtr(data)) : nullptr;
+}
+
 void ResourceError::platformLazyInit()
 {
     if (m_dataIsUpToDate)
@@ -106,7 +130,7 @@
         }
         m_localizedDescription = (CFStringRef) CFDictionaryGetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey);
         
-        m_certificate = wkGetSSLPeerCertificateData(userInfo.get());
+        m_certificate = getSSLPeerCertificateData(userInfo.get());
     }
 
     m_dataIsUpToDate = true;
@@ -144,7 +168,7 @@
         }
 
         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()));
     }

Modified: trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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 @@
 #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 @@
         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)

Modified: trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegate.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegate.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegate.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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 {

Modified: trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -46,10 +46,6 @@
 #include <dlfcn.h>
 #endif
 
-#if PLATFORM(WIN)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#endif
-
 WTF_DECLARE_CF_TYPE_TRAIT(CFURL);
 
 namespace WebCore {

Modified: trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp (238297 => 238298)


--- trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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)

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (238297 => 238298)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2018-11-16 21:43:11 UTC (rev 238298)
@@ -1,3 +1,27 @@
+2018-11-16  Brent Fulgham  <bfulg...@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  <bfulg...@apple.com>
 
         [Win] Reduce the use of WKSI library calls: Font Handling

Modified: trunk/Source/WebKitLegacy/win/WebCache.cpp (238297 => 238298)


--- trunk/Source/WebKitLegacy/win/WebCache.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebKitLegacy/win/WebCache.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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 @@
     *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

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameNetworkingContext.cpp (238297 => 238298)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameNetworkingContext.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameNetworkingContext.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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;

Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp (238297 => 238298)


--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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;

Modified: trunk/Source/WebKitLegacy/win/WebError.cpp (238297 => 238298)


--- trunk/Source/WebKitLegacy/win/WebError.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebKitLegacy/win/WebError.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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 @@
 #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 @@
     if (!m_cfErrorUserInfoDict)
         return E_FAIL;
 
-    void* data = ""
+    const void* data = ""
     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;
 }

Modified: trunk/Source/WebKitLegacy/win/WebURLResponse.cpp (238297 => 238298)


--- trunk/Source/WebKitLegacy/win/WebURLResponse.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebKitLegacy/win/WebURLResponse.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -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
@@ -36,12 +36,13 @@
 #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 @@
     CFDictionaryRef dict = certificateDictionary();
     if (!dict)
         return E_FAIL;
-    void* data = ""
+    const void* data = ""
     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 @@
     CFURLResponseRef cfResponse = m_response.cfURLResponse();
     if (!cfResponse)
         return nullptr;
-    m_SSLCertificateInfo = wkGetSSLCertificateInfo(cfResponse);
+    m_SSLCertificateInfo = _CFURLResponseGetSSLCertificateContext(cfResponse);
     return m_SSLCertificateInfo.get();
 }
 #endif

Modified: trunk/Source/WebKitLegacy/win/WebView.cpp (238297 => 238298)


--- trunk/Source/WebKitLegacy/win/WebView.cpp	2018-11-16 20:42:51 UTC (rev 238297)
+++ trunk/Source/WebKitLegacy/win/WebView.cpp	2018-11-16 21:43:11 UTC (rev 238298)
@@ -186,7 +186,8 @@
 #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 @@
 
 #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())))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to