Title: [221986] trunk/Source
Revision
221986
Author
aes...@apple.com
Date
2017-09-13 13:02:11 -0700 (Wed, 13 Sep 2017)

Log Message

[CF] Upstream CFNetwork-related WebKitSystemInterface functions
https://bugs.webkit.org/show_bug.cgi?id=176729

Reviewed by Alex Christensen.

Source/WebCore:

* platform/ios/WebCoreSystemInterfaceIOS.mm:
* platform/mac/PublicSuffixMac.mm:
(WebCore::isPublicSuffix):
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:
* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::ResourceRequest::doUpdatePlatformRequest):
(WebCore::ResourceRequest::doUpdateResourceRequest):
* platform/network/cf/SocketStreamHandleImplCFNet.cpp:
(WebCore::setCONNECTProxyForStream):
(WebCore::SocketStreamHandleImpl::createStreams):
(WebCore::setCONNECTProxyAuthorizationForStream):
(WebCore::SocketStreamHandleImpl::addCONNECTCredentials):
(WebCore::copyCONNECTProxyResponse):
(WebCore::SocketStreamHandleImpl::readStreamCallback):
(WebCore::SocketStreamHandleImpl::writeStreamCallback):
* platform/network/cocoa/ResourceRequestCocoa.mm:
(WebCore::ResourceRequest::doUpdateResourceRequest):
(WebCore::ResourceRequest::doUpdatePlatformRequest):

Source/WebCore/PAL:

* pal/spi/cf/CFNetworkSPI.h:

Source/WebKit:

* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::createSerializableRepresentation):
(IPC::dictionaryValueOfType):
(IPC::createArchiveList):
(IPC::createCFURLRequestFromSerializableRepresentation):
(IPC::createNSURLRequestFromSerializableRepresentation):
(IPC::ArgumentCoder<ResourceRequest>::encodePlatformData):
(IPC::ArgumentCoder<ResourceRequest>::decodePlatformData):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::legacyPlatformDefaultCacheStorageDirectory):
(WebKit::WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory):
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
* WebView/WebView.mm:
(+[WebView _setCacheModel:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221985 => 221986)


--- trunk/Source/WebCore/ChangeLog	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/ChangeLog	2017-09-13 20:02:11 UTC (rev 221986)
@@ -1,3 +1,30 @@
+2017-09-13  Andy Estes  <aes...@apple.com>
+
+        [CF] Upstream CFNetwork-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176729
+
+        Reviewed by Alex Christensen.
+
+        * platform/ios/WebCoreSystemInterfaceIOS.mm:
+        * platform/mac/PublicSuffixMac.mm:
+        (WebCore::isPublicSuffix):
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        (WebCore::ResourceRequest::doUpdateResourceRequest):
+        * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
+        (WebCore::setCONNECTProxyForStream):
+        (WebCore::SocketStreamHandleImpl::createStreams):
+        (WebCore::setCONNECTProxyAuthorizationForStream):
+        (WebCore::SocketStreamHandleImpl::addCONNECTCredentials):
+        (WebCore::copyCONNECTProxyResponse):
+        (WebCore::SocketStreamHandleImpl::readStreamCallback):
+        (WebCore::SocketStreamHandleImpl::writeStreamCallback):
+        * platform/network/cocoa/ResourceRequestCocoa.mm:
+        (WebCore::ResourceRequest::doUpdateResourceRequest):
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+
 2017-09-13  Antti Koivisto  <an...@apple.com>
 
         Make more of the CSS animation system internals element based

Modified: trunk/Source/WebCore/PAL/ChangeLog (221985 => 221986)


--- trunk/Source/WebCore/PAL/ChangeLog	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/PAL/ChangeLog	2017-09-13 20:02:11 UTC (rev 221986)
@@ -1,3 +1,12 @@
+2017-09-13  Andy Estes  <aes...@apple.com>
+
+        [CF] Upstream CFNetwork-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176729
+
+        Reviewed by Alex Christensen.
+
+        * pal/spi/cf/CFNetworkSPI.h:
+
 2017-09-12  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Unskip fast/text/system-font-synthetic-italic.html

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


--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2017-09-13 20:02:11 UTC (rev 221986)
@@ -194,6 +194,7 @@
 extern CFStringRef const kCFHTTPCookieLocalFileDomain;
 extern const CFStringRef kCFHTTPVersion1_1;
 extern const CFStringRef kCFURLRequestAllowAllPOSTCaching;
+extern const CFStringRef _kCFURLCachePartitionKey;
 extern const CFStringRef _kCFURLConnectionPropertyShouldSniff;
 extern const CFStringRef _kCFURLStorageSessionIsPrivate;
 
@@ -236,9 +237,22 @@
 void CFHTTPCookieStorageSetCookies(CFHTTPCookieStorageRef, CFArrayRef cookies, CFURLRef, CFURLRef mainDocumentURL);
 void CFHTTPCookieStorageDeleteCookie(CFHTTPCookieStorageRef, CFHTTPCookieRef);
 CFMutableURLRequestRef CFURLRequestCreateMutableCopy(CFAllocatorRef, CFURLRequestRef);
+CFStringRef _CFURLCacheCopyCacheDirectory(CFURLCacheRef);
+Boolean _CFHostIsDomainTopLevel(CFStringRef domain);
+void _CFURLRequestCreateArchiveList(CFAllocatorRef, CFURLRequestRef, CFIndex* version, CFTypeRef** objects, CFIndex* objectCount, CFDictionaryRef* protocolProperties);
+CFMutableURLRequestRef _CFURLRequestCreateFromArchiveList(CFAllocatorRef, CFIndex version, CFTypeRef* objects, CFIndex objectCount, CFDictionaryRef protocolProperties);
 
 #endif // !PLATFORM(WIN)
 
+CFN_EXPORT const CFStringRef kCFStreamPropertyCONNECTProxy;
+CFN_EXPORT const CFStringRef kCFStreamPropertyCONNECTProxyHost;
+CFN_EXPORT const CFStringRef kCFStreamPropertyCONNECTProxyPort;
+CFN_EXPORT const CFStringRef kCFStreamPropertyCONNECTAdditionalHeaders;
+CFN_EXPORT const CFStringRef kCFStreamPropertyCONNECTResponse;
+
+CFN_EXPORT void _CFHTTPMessageSetResponseURL(CFHTTPMessageRef, CFURLRef);
+CFN_EXPORT void _CFHTTPMessageSetResponseProxyURL(CFHTTPMessageRef, CFURLRef);
+
 WTF_EXTERN_C_END
 
 #if defined(__OBJC__) && !USE(APPLE_INTERNAL_SDK)

Modified: trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm (221985 => 221986)


--- trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm	2017-09-13 20:02:11 UTC (rev 221986)
@@ -29,10 +29,7 @@
 WEBCORE_EXPORT void (*wkClearGlyphVector)(void* glyphs);
 WEBCORE_EXPORT OSStatus (*wkConvertCharToGlyphs)(void* styleGroup, const UniChar*, unsigned numCharacters, void* glyphs);
 WEBCORE_EXPORT id (*wkCreateNSURLConnectionDelegateProxy)(void);
-WEBCORE_EXPORT void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
-WEBCORE_EXPORT void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
 WEBCORE_EXPORT void (*wkSetCookieStoragePrivateBrowsingEnabled)(BOOL);
-WEBCORE_EXPORT CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL, CFStringRef proxyHost, CFNumberRef proxyPort);
 WEBCORE_EXPORT void (*wkSetLayerContentsScale)(CALayer *);
 
 WEBCORE_EXPORT bool (*wkCaptionAppearanceHasUserPreferences)(void);
@@ -48,12 +45,6 @@
 WEBCORE_EXPORT int(*wkCaptionAppearanceGetTextEdgeStyle)(void);
 WEBCORE_EXPORT CFStringRef(*wkCaptionAppearanceGetSettingsChangedNotification)(void);
 
-#if ENABLE(PUBLIC_SUFFIX_LIST)
-WEBCORE_EXPORT bool (*wkIsPublicSuffix)(NSString *host);
-#endif
-
-WEBCORE_EXPORT CFStringRef (*wkCachePartitionKey)(void);
-
 WEBCORE_EXPORT int (*wkExernalDeviceTypeForPlayer)(AVPlayer *);
 WEBCORE_EXPORT NSString *(*wkExernalDeviceDisplayNameForPlayer)(AVPlayer *);
 

Modified: trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm (221985 => 221986)


--- trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm	2017-09-13 20:02:11 UTC (rev 221986)
@@ -26,11 +26,11 @@
 #import "config.h"
 #import "PublicSuffix.h"
 
-#import "WebCoreSystemInterface.h"
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+
 #import "WebCoreNSURLExtras.h"
+#import <pal/spi/cf/CFNetworkSPI.h>
 
-#if ENABLE(PUBLIC_SUFFIX_LIST)
-
 @interface NSString (WebCoreNSURLExtras)
 - (BOOL)_web_looksLikeIPAddress;
 @end
@@ -40,7 +40,7 @@
 bool isPublicSuffix(const String& domain)
 {
     NSString *host = decodeHostName(domain);
-    return host && wkIsPublicSuffix(host);
+    return host && _CFHostIsDomainTopLevel((CFStringRef)host);
 }
 
 String topPrivatelyControlledDomain(const String& domain)

Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h (221985 => 221986)


--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h	2017-09-13 20:02:11 UTC (rev 221986)
@@ -133,12 +133,6 @@
 extern void (*wkMeasureMediaUIPart)(int part, CGRect *bounds, CGSize *naturalSize);
 
 extern void (*wkSetCookieStoragePrivateBrowsingEnabled)(BOOL);
-#endif
-extern void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
-extern void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
-extern CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL, CFStringRef proxyHost, CFNumberRef proxyPort);
-
-#if !PLATFORM(IOS)
 extern void* wkGetHyphenationLocationBeforeIndex;
 #endif
 
@@ -167,12 +161,6 @@
 extern CGFloat (*wkNSReboundDeltaForElasticDelta)(CGFloat delta);
 #endif
 
-#if ENABLE(PUBLIC_SUFFIX_LIST)
-extern bool (*wkIsPublicSuffix)(NSString *host);
-#endif
-
-extern CFStringRef (*wkCachePartitionKey)(void);
-
 typedef enum {
     wkExternalPlaybackTypeNone,
     wkExternalPlaybackTypeAirPlay,

Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm (221985 => 221986)


--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm	2017-09-13 20:02:11 UTC (rev 221986)
@@ -40,10 +40,6 @@
 BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
 void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*, NSControlSize controlSize, bool usesCustomAppearance);
 
-void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
-void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
-CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL, CFStringRef proxyHost, CFNumberRef proxyPort);
-
 void* wkGetHyphenationLocationBeforeIndex;
 
 bool (*wkExecutableWasLinkedOnOrBeforeSnowLeopard)(void);
@@ -62,12 +58,6 @@
 CGFloat (*wkNSReboundDeltaForElasticDelta)(CGFloat delta);
 #endif
 
-#if ENABLE(PUBLIC_SUFFIX_LIST)
-bool (*wkIsPublicSuffix)(NSString *host);
-#endif
-
-CFStringRef (*wkCachePartitionKey)(void);
-
 int (*wkExernalDeviceTypeForPlayer)(AVPlayer *);
 NSString *(*wkExernalDeviceDisplayNameForPlayer)(AVPlayer *);
 

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


--- trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp	2017-09-13 20:02:11 UTC (rev 221986)
@@ -180,7 +180,7 @@
     if (!partition.isNull() && !partition.isEmpty()) {
         CString utf8String = partition.utf8();
         RetainPtr<CFStringRef> partitionValue = adoptCF(CFStringCreateWithBytes(0, reinterpret_cast<const UInt8*>(utf8String.data()), utf8String.length(), kCFStringEncodingUTF8, false));
-        _CFURLRequestSetProtocolProperty(cfRequest, wkCachePartitionKey(), partitionValue.get());
+        _CFURLRequestSetProtocolProperty(cfRequest, kCFURLCachePartitionKey, partitionValue.get());
     }
 #endif
 
@@ -292,7 +292,7 @@
     }
 
 #if ENABLE(CACHE_PARTITIONING)
-    RetainPtr<CFStringRef> cachePartition = adoptCF(static_cast<CFStringRef>(_CFURLRequestCopyProtocolPropertyForKey(m_cfRequest.get(), wkCachePartitionKey())));
+    RetainPtr<CFStringRef> cachePartition = adoptCF(static_cast<CFStringRef>(_CFURLRequestCopyProtocolPropertyForKey(m_cfRequest.get(), kCFURLCachePartitionKey)));
     if (cachePartition)
         m_cachePartition = cachePartition.get();
 #endif

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


--- trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp	2017-09-13 20:02:11 UTC (rev 221986)
@@ -44,6 +44,7 @@
 #include <wtf/Condition.h>
 #include <wtf/Lock.h>
 #include <wtf/MainThread.h>
+#include <wtf/SoftLinking.h>
 #include <wtf/text/WTFString.h>
 
 #if PLATFORM(WIN)
@@ -62,6 +63,11 @@
 #import <pal/spi/cf/CFNetworkSPI.h>
 #endif
 
+#if PLATFORM(WIN)
+SOFT_LINK_LIBRARY(CFNetwork);
+SOFT_LINK_OPTIONAL(CFNetwork, _CFHTTPMessageSetResponseProxyURL, void, __cdecl, (CFHTTPMessageRef, CFURLRef));
+#endif
+
 namespace WebCore {
 
 SocketStreamHandleImpl::SocketStreamHandleImpl(const URL& url, SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& credentialPartition, SourceApplicationAuditToken&& auditData)
@@ -302,6 +308,13 @@
     m_connectionType = Direct;
 }
 
+static void setCONNECTProxyForStream(CFReadStreamRef stream, CFStringRef proxyHost, CFNumberRef proxyPort)
+{
+    const void* proxyKeys[] = { kCFStreamPropertyCONNECTProxyHost, kCFStreamPropertyCONNECTProxyPort };
+    const void* proxyValues[] = { proxyHost, proxyPort };
+    auto connectDictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, proxyKeys, proxyValues, sizeof(proxyKeys) / sizeof(*proxyKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+    CFReadStreamSetProperty(stream, kCFStreamPropertyCONNECTProxy, connectDictionary.get());
+}
 
 void SocketStreamHandleImpl::createStreams()
 {
@@ -347,7 +360,7 @@
         break;
         }
     case CONNECTProxy:
-        wkSetCONNECTProxyForStream(m_readStream.get(), m_proxyHost.get(), m_proxyPort.get());
+        setCONNECTProxyForStream(m_readStream.get(), m_proxyHost.get(), m_proxyPort.get());
         break;
     }
 
@@ -395,7 +408,20 @@
     ASSERT_NOT_REACHED();
     return ProtectionSpaceAuthenticationSchemeUnknown;
 }
+    
+static void setCONNECTProxyAuthorizationForStream(CFReadStreamRef stream, CFStringRef proxyAuthorizationString)
+{
+    auto originalCONNECTDictionary = adoptCF((CFDictionaryRef)CFReadStreamCopyProperty(stream, kCFStreamPropertyCONNECTProxy));
+    auto connectDictionary = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, originalCONNECTDictionary.get()));
 
+    const void* headerFieldNames[] = { CFSTR("Proxy-Authorization") };
+    const void* headerFieldValues[] = { proxyAuthorizationString };
+    auto additionalHeaderFields = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, headerFieldNames, headerFieldValues, sizeof(headerFieldNames) / sizeof(*headerFieldValues), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+
+    CFDictionarySetValue(connectDictionary.get(), kCFStreamPropertyCONNECTAdditionalHeaders, additionalHeaderFields.get());
+    CFReadStreamSetProperty(stream, kCFStreamPropertyCONNECTProxy, connectDictionary.get());
+}
+
 void SocketStreamHandleImpl::addCONNECTCredentials(CFHTTPMessageRef proxyResponse)
 {
     RetainPtr<CFHTTPAuthenticationRef> authentication = adoptCF(CFHTTPAuthenticationCreateFromResponse(0, proxyResponse));
@@ -437,7 +463,7 @@
         }
 
         // Setting the authorization results in a new connection attempt.
-        wkSetCONNECTProxyAuthorizationForStream(m_readStream.get(), proxyAuthorizationString.get());
+        setCONNECTProxyAuthorizationForStream(m_readStream.get(), proxyAuthorizationString.get());
         m_sentStoredCredentials = true;
         return;
     }
@@ -493,6 +519,38 @@
 #endif
 }
 
+#if !PLATFORM(IOS)
+static void setResponseProxyURL(CFHTTPMessageRef message, CFURLRef proxyURL)
+{
+#if PLATFORM(WIN)
+    if (_CFHTTPMessageSetResponseProxyURLPtr())
+        _CFHTTPMessageSetResponseProxyURLPtr()(message, proxyURL);
+#else
+    _CFHTTPMessageSetResponseProxyURL(message, proxyURL);
+#endif
+}
+#endif
+
+static RetainPtr<CFHTTPMessageRef> copyCONNECTProxyResponse(CFReadStreamRef stream, CFURLRef responseURL, CFStringRef proxyHost, CFNumberRef proxyPort)
+{
+    auto message = adoptCF((CFHTTPMessageRef)CFReadStreamCopyProperty(stream, kCFStreamPropertyCONNECTResponse));
+    // CFNetwork needs URL to be set on response in order to handle authentication - even though it doesn't seem to make sense to provide ultimate target URL when authenticating to a proxy.
+    // This is set by CFNetwork internally for normal HTTP responses, but not for proxies.
+    _CFHTTPMessageSetResponseURL(message.get(), responseURL);
+
+#if !PLATFORM(IOS)
+    // Ditto for proxy URL.
+    auto proxyURLString = adoptCF(CFStringCreateWithFormat(kCFAllocatorDefault, nullptr, CFSTR("https://%@:%@"), proxyHost, proxyPort));
+    auto proxyURL = adoptCF(CFURLCreateWithString(kCFAllocatorDefault, proxyURLString.get(), nullptr));
+    setResponseProxyURL(message.get(), proxyURL.get());
+#else
+    UNUSED_PARAM(proxyHost);
+    UNUSED_PARAM(proxyPort);
+#endif
+
+    return message;
+}
+
 void SocketStreamHandleImpl::readStreamCallback(CFStreamEventType type)
 {
     switch (type) {
@@ -506,7 +564,7 @@
 
         if (m_connectingSubstate == WaitingForConnect) {
             if (m_connectionType == CONNECTProxy) {
-                RetainPtr<CFHTTPMessageRef> proxyResponse = adoptCF(wkCopyCONNECTProxyResponse(m_readStream.get(), m_httpsURL.get(), m_proxyHost.get(), m_proxyPort.get()));
+                RetainPtr<CFHTTPMessageRef> proxyResponse = copyCONNECTProxyResponse(m_readStream.get(), m_httpsURL.get(), m_proxyHost.get(), m_proxyPort.get());
                 if (!proxyResponse)
                     return;
 
@@ -588,7 +646,7 @@
 
         if (m_connectingSubstate == WaitingForConnect) {
             if (m_connectionType == CONNECTProxy) {
-                RetainPtr<CFHTTPMessageRef> proxyResponse = adoptCF(wkCopyCONNECTProxyResponse(m_readStream.get(), m_httpsURL.get(), m_proxyHost.get(), m_proxyPort.get()));
+                RetainPtr<CFHTTPMessageRef> proxyResponse = copyCONNECTProxyResponse(m_readStream.get(), m_httpsURL.get(), m_proxyHost.get(), m_proxyPort.get());
                 if (!proxyResponse)
                     return;
 

Modified: trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm (221985 => 221986)


--- trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm	2017-09-13 20:02:11 UTC (rev 221986)
@@ -138,7 +138,7 @@
     }
 
     if (m_nsRequest) {
-        NSString* cachePartition = [NSURLProtocol propertyForKey:(NSString *)wkCachePartitionKey() inRequest:m_nsRequest.get()];
+        NSString* cachePartition = [NSURLProtocol propertyForKey:(NSString *)_kCFURLCachePartitionKey inRequest:m_nsRequest.get()];
         if (cachePartition)
             m_cachePartition = cachePartition;
     }
@@ -208,7 +208,7 @@
     String partition = cachePartition();
     if (!partition.isNull() && !partition.isEmpty()) {
         NSString *partitionValue = [NSString stringWithUTF8String:partition.utf8().data()];
-        [NSURLProtocol setProperty:partitionValue forKey:(NSString *)wkCachePartitionKey() inRequest:nsRequest];
+        [NSURLProtocol setProperty:partitionValue forKey:(NSString *)_kCFURLCachePartitionKey inRequest:nsRequest];
     }
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)

Modified: trunk/Source/WebKit/ChangeLog (221985 => 221986)


--- trunk/Source/WebKit/ChangeLog	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebKit/ChangeLog	2017-09-13 20:02:11 UTC (rev 221986)
@@ -1,3 +1,24 @@
+2017-09-13  Andy Estes  <aes...@apple.com>
+
+        [CF] Upstream CFNetwork-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176729
+
+        Reviewed by Alex Christensen.
+
+        * Shared/mac/WebCoreArgumentCodersMac.mm:
+        (IPC::createSerializableRepresentation):
+        (IPC::dictionaryValueOfType):
+        (IPC::createArchiveList):
+        (IPC::createCFURLRequestFromSerializableRepresentation):
+        (IPC::createNSURLRequestFromSerializableRepresentation):
+        (IPC::ArgumentCoder<ResourceRequest>::encodePlatformData):
+        (IPC::ArgumentCoder<ResourceRequest>::decodePlatformData):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::legacyPlatformDefaultCacheStorageDirectory):
+        (WebKit::WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory):
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2017-09-13  Alex Christensen  <achristen...@webkit.org>
 
         Add WKUIDelegatePrivate equivalent of WKPageUIClient's setIsResizable, getWindowFrame, and setWindowFrame

Modified: trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm (221985 => 221986)


--- trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm	2017-09-13 20:02:11 UTC (rev 221986)
@@ -38,6 +38,7 @@
 #import <WebCore/ProtectionSpace.h>
 #import <WebCore/ResourceError.h>
 #import <WebCore/ResourceRequest.h>
+#import <pal/spi/cf/CFNetworkSPI.h>
 
 #if USE(CFURLCONNECTION)
 #import <CFNetwork/CFURLRequest.h>
@@ -57,6 +58,136 @@
 
 namespace IPC {
 
+static RetainPtr<CFMutableDictionaryRef> createSerializableRepresentation(CFIndex version, CFTypeRef* objects, CFIndex objectCount, CFDictionaryRef protocolProperties, CFNumberRef expectedContentLength, CFStringRef mimeType, CFTypeRef tokenNull)
+{
+    auto archiveListArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
+
+    for (CFIndex i = 0; i < objectCount; ++i) {
+        CFTypeRef object = objects[i];
+        if (object) {
+            CFArrayAppendValue(archiveListArray.get(), object);
+            CFRelease(object);
+        } else {
+            // Append our token null representation.
+            CFArrayAppendValue(archiveListArray.get(), tokenNull);
+        }
+    }
+
+    auto dictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+
+    auto versionNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &version));
+    CFDictionarySetValue(dictionary.get(), CFSTR("version"), versionNumber.get());
+    CFDictionarySetValue(dictionary.get(), CFSTR("archiveList"), archiveListArray.get());
+
+    if (protocolProperties) {
+        CFDictionarySetValue(dictionary.get(), CFSTR("protocolProperties"), protocolProperties);
+        CFRelease(protocolProperties);
+    }
+
+    if (expectedContentLength) {
+        CFDictionarySetValue(dictionary.get(), CFSTR("expectedContentLength"), expectedContentLength);
+        CFRelease(expectedContentLength);
+    }
+
+    if (mimeType) {
+        CFDictionarySetValue(dictionary.get(), CFSTR("mimeType"), mimeType);
+        CFRelease(mimeType);
+    }
+
+    CFAllocatorDeallocate(kCFAllocatorDefault, objects);
+
+    return dictionary;
+}
+
+static CFTypeRef dictionaryValueOfType(CFDictionaryRef dictionary, CFStringRef key, CFTypeID type)
+{
+    CFTypeRef value = CFDictionaryGetValue(dictionary, key);
+    if (value && CFGetTypeID(value) == type)
+        return value;
+    return nullptr;
+}
+
+static bool createArchiveList(CFDictionaryRef representation, CFTypeRef tokenNull, CFIndex* version, CFTypeRef** objects, CFIndex* objectCount, CFDictionaryRef* protocolProperties, CFNumberRef* expectedContentLength, CFStringRef* mimeType)
+{
+    CFNumberRef versionNumber = (CFNumberRef)dictionaryValueOfType(representation, CFSTR("version"), CFNumberGetTypeID());
+    if (!versionNumber)
+        return false;
+
+    if (!CFNumberGetValue(versionNumber, kCFNumberCFIndexType, version))
+        return false;
+
+    CFArrayRef archiveListArray = (CFArrayRef)dictionaryValueOfType(representation, CFSTR("archiveList"), CFArrayGetTypeID());
+    if (!archiveListArray)
+        return false;
+
+    *objectCount = CFArrayGetCount(archiveListArray);
+    *objects = (CFTypeRef*)malloc(sizeof(CFTypeRef) * *objectCount);
+    for (CFIndex i = 0; i < *objectCount; ++i) {
+        CFTypeRef object = CFArrayGetValueAtIndex(archiveListArray, i);
+        if (object == tokenNull)
+            (*objects)[i] = nullptr;
+        else
+            (*objects)[i] = object;
+    }
+
+    if (protocolProperties)
+        *protocolProperties = (CFDictionaryRef)dictionaryValueOfType(representation, CFSTR("protocolProperties"), CFDictionaryGetTypeID());
+
+    if (expectedContentLength)
+        *expectedContentLength = (CFNumberRef)dictionaryValueOfType(representation, CFSTR("expectedContentLength"), CFNumberGetTypeID());
+
+    if (mimeType)
+        *mimeType = (CFStringRef)dictionaryValueOfType(representation, CFSTR("mimeType"), CFStringGetTypeID());
+
+    return true;
+}
+
+static RetainPtr<CFDictionaryRef> createSerializableRepresentation(CFURLRequestRef cfRequest, CFTypeRef tokenNull)
+{
+    CFIndex version;
+    CFTypeRef* objects;
+    CFIndex objectCount;
+    CFDictionaryRef protocolProperties;
+
+    // FIXME (12889518): Do not serialize HTTP message body.
+    // 1. It can be large and thus costly to send across.
+    // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all.
+
+    _CFURLRequestCreateArchiveList(kCFAllocatorDefault, cfRequest, &version, &objects, &objectCount, &protocolProperties);
+
+    // This will deallocate the passed in arguments.
+    return createSerializableRepresentation(version, objects, objectCount, protocolProperties, nullptr, nullptr, tokenNull);
+}
+
+static RetainPtr<CFURLRequestRef> createCFURLRequestFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull)
+{
+    CFIndex version;
+    CFTypeRef* objects;
+    CFIndex objectCount;
+    CFDictionaryRef protocolProperties;
+
+    if (!createArchiveList(representation, tokenNull, &version, &objects, &objectCount, &protocolProperties, nullptr, nullptr))
+        return nullptr;
+
+    auto cfRequest = adoptCF(_CFURLRequestCreateFromArchiveList(kCFAllocatorDefault, version, objects, objectCount, protocolProperties));
+    free(objects);
+    return WTFMove(cfRequest);
+}
+
+static RetainPtr<CFDictionaryRef> createSerializableRepresentation(NSURLRequest *request, CFTypeRef tokenNull)
+{
+    return createSerializableRepresentation([request _CFURLRequest], tokenNull);
+}
+
+static RetainPtr<NSURLRequest> createNSURLRequestFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull)
+{
+    auto cfRequest = createCFURLRequestFromSerializableRepresentation(representation, tokenNull);
+    if (!cfRequest)
+        return nullptr;
+
+    return adoptNS([[NSURLRequest alloc] _initWithCFURLRequest:cfRequest.get()]);
+}
+
 #if USE(CFURLCONNECTION)
 void ArgumentCoder<ResourceRequest>::encodePlatformData(Encoder& encoder, const ResourceRequest& resourceRequest)
 {
@@ -79,7 +210,7 @@
         CFURLRequestSetHTTPRequestBodyStream(mutableRequest, nil);
     }
 
-    RetainPtr<CFDictionaryRef> dictionary = adoptCF(WKCFURLRequestCreateSerializableRepresentation(requestToSerialize.get(), IPC::tokenNullTypeRef()));
+    RetainPtr<CFDictionaryRef> dictionary = createSerializableRepresentation(requestToSerialize.get(), IPC::tokenNullTypeRef());
     IPC::encode(encoder, dictionary.get());
 
     // The fallback array is part of CFURLRequest, but it is not encoded by WKCFURLRequestCreateSerializableRepresentation.
@@ -106,7 +237,7 @@
         [(NSMutableURLRequest *)requestToSerialize setHTTPBodyStream:nil];
     }
 
-    RetainPtr<CFDictionaryRef> dictionary = adoptCF(WKNSURLRequestCreateSerializableRepresentation(requestToSerialize.get(), IPC::tokenNullTypeRef()));
+    RetainPtr<CFDictionaryRef> dictionary = createSerializableRepresentation(requestToSerialize.get(), IPC::tokenNullTypeRef());
     IPC::encode(encoder, dictionary.get());
 
     // The fallback array is part of NSURLRequest, but it is not encoded by WKNSURLRequestCreateSerializableRepresentation.
@@ -132,13 +263,13 @@
         return false;
 
 #if USE(CFURLCONNECTION)
-    RetainPtr<CFURLRequestRef> cfURLRequest = adoptCF(WKCreateCFURLRequestFromSerializableRepresentation(dictionary.get(), IPC::tokenNullTypeRef()));
+    RetainPtr<CFURLRequestRef> cfURLRequest = createCFURLRequestFromSerializableRepresentation(dictionary.get(), IPC::tokenNullTypeRef());
     if (!cfURLRequest)
         return false;
 
     resourceRequest = ResourceRequest(cfURLRequest.get());
 #else
-    RetainPtr<NSURLRequest> nsURLRequest = WKNSURLRequestFromSerializableRepresentation(dictionary.get(), IPC::tokenNullTypeRef());
+    RetainPtr<NSURLRequest> nsURLRequest = createNSURLRequestFromSerializableRepresentation(dictionary.get(), IPC::tokenNullTypeRef());
     if (!nsURLRequest)
         return false;
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (221985 => 221986)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2017-09-13 20:02:11 UTC (rev 221986)
@@ -455,7 +455,7 @@
 
 String WebProcessPool::legacyPlatformDefaultCacheStorageDirectory()
 {
-    RetainPtr<NSString> cacheStoragePath = adoptNS((NSString *)WKCopyFoundationCacheDirectory());
+    RetainPtr<NSString> cacheStoragePath = adoptNS((NSString *)_CFURLCacheCopyCacheDirectory([[NSURLCache sharedURLCache] _CFURLCache]));
     if (!cacheStoragePath)
         cacheStoragePath = @"~/Library/WebKit/CacheStorage";
 
@@ -464,7 +464,7 @@
 
 String WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory()
 {
-    RetainPtr<NSString> cachePath = adoptNS((NSString *)WKCopyFoundationCacheDirectory());
+    RetainPtr<NSString> cachePath = adoptNS((NSString *)_CFURLCacheCopyCacheDirectory([[NSURLCache sharedURLCache] _CFURLCache]));
     if (!cachePath)
         cachePath = @"~/Library/Caches/com.apple.WebKit.WebProcess";
 

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm (221985 => 221986)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm	2017-09-13 20:02:11 UTC (rev 221986)
@@ -36,7 +36,6 @@
     static dispatch_once_t initOnce;
     
     dispatch_once(&initOnce, ^{
-        INIT(CopyCONNECTProxyResponse);
 #if !PLATFORM(IOS)
         INIT(DrawBezeledTextArea);
         INIT(DrawMediaSliderTrack);
@@ -43,11 +42,6 @@
         INIT(DrawMediaUIPart);
         INIT(HitTestMediaUIPart);
         INIT(MeasureMediaUIPart);
-#endif
-        INIT(SetCONNECTProxyAuthorizationForStream);
-        INIT(SetCONNECTProxyForStream);
-
-#if !PLATFORM(IOS)
         INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
         INIT(CopyDefaultSearchProviderDisplayName);
         INIT(Cursor);
@@ -58,12 +52,6 @@
         INIT(NSReboundDeltaForElasticDelta);
 #endif
 
-#if ENABLE(PUBLIC_SUFFIX_LIST)
-        INIT(IsPublicSuffix);
-#endif
-
-        INIT(CachePartitionKey);
-
         INIT(ExernalDeviceTypeForPlayer);
         INIT(ExernalDeviceDisplayNameForPlayer);
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (221985 => 221986)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-09-13 20:02:11 UTC (rev 221986)
@@ -1,3 +1,15 @@
+2017-09-13  Andy Estes  <aes...@apple.com>
+
+        [CF] Upstream CFNetwork-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176729
+
+        Reviewed by Alex Christensen.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+        * WebView/WebView.mm:
+        (+[WebView _setCacheModel:]):
+
 2017-09-13  Ryosuke Niwa  <rn...@webkit.org>
 
         Refactor WebContentReader out of EditorMac and EditorIOS

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm (221985 => 221986)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm	2017-09-13 20:02:11 UTC (rev 221986)
@@ -42,7 +42,6 @@
     if (didInit)
         return;
 
-    INIT(CopyCONNECTProxyResponse);
 #if !PLATFORM(IOS)
     INIT(DrawBezeledTextArea);
     INIT(DrawMediaUIPart);
@@ -50,8 +49,6 @@
     INIT(HitTestMediaUIPart);
     INIT(MeasureMediaUIPart);
 #endif
-    INIT(SetCONNECTProxyAuthorizationForStream);
-    INIT(SetCONNECTProxyForStream);
 
 #if !PLATFORM(IOS)
     INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
@@ -67,12 +64,6 @@
     INIT(NSReboundDeltaForElasticDelta);
 #endif
 
-#if ENABLE(PUBLIC_SUFFIX_LIST)
-    INIT(IsPublicSuffix);
-#endif
-
-    INIT(CachePartitionKey);
-
     INIT(ExernalDeviceTypeForPlayer);
     INIT(ExernalDeviceDisplayNameForPlayer);
 

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (221985 => 221986)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-09-13 19:54:06 UTC (rev 221985)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-09-13 20:02:11 UTC (rev 221986)
@@ -8573,7 +8573,7 @@
     if (s_didSetCacheModel && cacheModel == s_cacheModel)
         return;
 
-    NSString *nsurlCacheDirectory = CFBridgingRelease(WKCopyFoundationCacheDirectory());
+    NSString *nsurlCacheDirectory = CFBridgingRelease(_CFURLCacheCopyCacheDirectory([[NSURLCache sharedURLCache] _CFURLCache]));
     if (!nsurlCacheDirectory)
         nsurlCacheDirectory = NSHomeDirectory();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to