Add missing Objective-C versions of downloads SPI
authordavid_quesada@apple.com <david_quesada@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Oct 2018 20:38:47 +0000 (20:38 +0000)
committerdavid_quesada@apple.com <david_quesada@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Oct 2018 20:38:47 +0000 (20:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190149
rdar://problem/44915592

Reviewed by Alex Christensen.

* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _downloadURLRequest:]):
(-[WKProcessPool _resumeDownloadFromData:path:]):
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* UIProcess/API/Cocoa/_WKDownload.h:
* UIProcess/API/Cocoa/_WKDownload.mm:
(-[_WKDownload resumeData]):
* UIProcess/API/Cocoa/_WKDownloadInternal.h:
* UIProcess/Cocoa/DownloadClient.mm:
    Move the DownloadProxy's WrapperTraits out of DownloadClient, and into the internal
    header so it can be used from other classes (i.e. WKProcessPool here).

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
Source/WebKit/UIProcess/API/Cocoa/_WKDownload.h
Source/WebKit/UIProcess/API/Cocoa/_WKDownload.mm
Source/WebKit/UIProcess/API/Cocoa/_WKDownloadInternal.h
Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

index 1072a09..4220e50 100644 (file)
@@ -1,3 +1,23 @@
+2018-10-01  David Quesada  <david_quesada@apple.com>
+
+        Add missing Objective-C versions of downloads SPI
+        https://bugs.webkit.org/show_bug.cgi?id=190149
+        rdar://problem/44915592
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool _downloadURLRequest:]):
+        (-[WKProcessPool _resumeDownloadFromData:path:]):
+        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
+        * UIProcess/API/Cocoa/_WKDownload.h:
+        * UIProcess/API/Cocoa/_WKDownload.mm:
+        (-[_WKDownload resumeData]):
+        * UIProcess/API/Cocoa/_WKDownloadInternal.h:
+        * UIProcess/Cocoa/DownloadClient.mm:
+            Move the DownloadProxy's WrapperTraits out of DownloadClient, and into the internal
+            header so it can be used from other classes (i.e. WKProcessPool here).
+
 2018-10-01  Alex Christensen  <achristensen@webkit.org>
 
         Fix internal build after r236665
index 899c85f..573d10b 100644 (file)
@@ -43,6 +43,7 @@
 #import "_WKAutomationDelegate.h"
 #import "_WKAutomationSessionInternal.h"
 #import "_WKDownloadDelegate.h"
+#import "_WKDownloadInternal.h"
 #import "_WKProcessPoolConfigurationInternal.h"
 #import <WebCore/CertificateInfo.h>
 #import <WebCore/PluginData.h>
@@ -573,6 +574,16 @@ static NSDictionary *policiesHashMapToDictionary(const HashMap<String, HashMap<S
 }
 #endif // PLATFORM(IOS)
 
+- (_WKDownload *)_downloadURLRequest:(NSURLRequest *)request
+{
+    return (_WKDownload *)_processPool->download(nullptr, request)->wrapper();
+}
+
+- (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData path:(NSString *)path
+{
+    return wrapper(_processPool->resumeDownload(API::Data::createWithoutCopying(resumeData).ptr(), path));
+}
+
 @end
 
 #endif // WK_API_ENABLED
index 0d61570..2e712cf 100644 (file)
@@ -29,6 +29,7 @@
 #if WK_API_ENABLED
 
 @class _WKAutomationSession;
+@class _WKDownload;
 @class _WKProcessPoolConfiguration;
 @protocol _WKAutomationDelegate;
 @protocol _WKDownloadDelegate;
@@ -79,6 +80,9 @@
 
 - (void)_registerURLSchemeAsCanDisplayOnlyIfCanRequest:(NSString *)scheme WK_API_AVAILABLE(macosx(10.14), ios(12.0));
 
+- (_WKDownload *)_downloadURLRequest:(NSURLRequest *)request WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData path:(NSString *)path WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 // Test only. Should be called only while no web content processes are running.
 - (void)_terminateStorageProcess;
 - (void)_terminateNetworkProcess;
index 8128261..acfd834 100644 (file)
@@ -40,6 +40,7 @@ WK_CLASS_AVAILABLE(macosx(10.10), ios(8.0))
 @property (nonatomic, readonly, weak) WKWebView *originatingWebView;
 @property (nonatomic, readonly, copy) NSArray<NSURL *> *redirectChain WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));
 @property (nonatomic, readonly) BOOL wasUserInitiated WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));
+@property (nonatomic, readonly) NSData *resumeData WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @end
 
index 569e033..16ad810 100644 (file)
@@ -29,6 +29,7 @@
 #if WK_API_ENABLED
 
 #import "DownloadProxy.h"
+#import "WKNSData.h"
 #import "WKWebViewInternal.h"
 #import <wtf/WeakObjCPtr.h>
 
     return _download->wasUserInitiated();
 }
 
+- (NSData *)resumeData
+{
+    return WebKit::wrapper(_download->resumeData());
+}
+
 #pragma mark WKObject protocol implementation
 
 - (API::Object&)_apiObject
index 0a226c3..d51db52 100644 (file)
 
 #if WK_API_ENABLED
 
+#import "DownloadProxy.h"
 #import "WKObject.h"
 
+namespace WebKit {
+
+template<> struct WrapperTraits<DownloadProxy> {
+    using WrapperClass = _WKDownload;
+};
+
+}
+
 @interface _WKDownload () <WKObject>
 @end
 
index 9ab5472..6ff1b47 100644 (file)
 
 namespace WebKit {
 
-template<> struct WrapperTraits<DownloadProxy> {
-    using WrapperClass = _WKDownload;
-};
-
 DownloadClient::DownloadClient(id <_WKDownloadDelegate> delegate)
     : m_delegate(delegate)
 {