WebCoreNSURLSession.h [plain text]
#ifndef WebCoreNSURLSession_h
#define WebCoreNSURLSession_h
#import <Foundation/NSURLSession.h>
#import <wtf/HashSet.h>
#import <wtf/Lock.h>
#import <wtf/OSObjectPtr.h>
#import <wtf/RefPtr.h>
#import <wtf/RetainPtr.h>
@class NSNetService;
@class NSOperationQueue;
@class NSURL;
@class NSURLRequest;
@class NSURLResponse;
@class WebCoreNSURLSessionDataTask;
namespace WebCore {
class CachedResourceRequest;
class PlatformMediaResource;
class PlatformMediaResourceLoader;
class WebCoreNSURLSessionDataTaskClient;
}
enum class WebCoreNSURLSessionCORSAccessCheckResults {
Unknown,
Pass,
Fail,
};
NS_ASSUME_NONNULL_BEGIN
WEBCORE_EXPORT @interface WebCoreNSURLSession : NSObject {
@private
RefPtr<WebCore::PlatformMediaResourceLoader> _loader;
RetainPtr<id<NSURLSessionDelegate>> _delegate;
RetainPtr<NSOperationQueue> _queue;
NSString *_sessionDescription;
HashSet<RetainPtr<WebCoreNSURLSessionDataTask>> _dataTasks;
Lock _dataTasksLock;
BOOL _invalidated;
NSUInteger _nextTaskIdentifier;
OSObjectPtr<dispatch_queue_t> _internalQueue;
WebCoreNSURLSessionCORSAccessCheckResults _corsResults;
}
- (id)initWithResourceLoader:(WebCore::PlatformMediaResourceLoader&)loader delegate:(id<NSURLSessionTaskDelegate>)delegate delegateQueue:(NSOperationQueue*)queue;
@property (readonly, retain) NSOperationQueue *delegateQueue;
@property (nullable, readonly, retain) id <NSURLSessionDelegate> delegate;
@property (readonly, copy) NSURLSessionConfiguration *configuration;
@property (copy) NSString *sessionDescription;
@property (readonly) BOOL didPassCORSAccessChecks;
- (void)finishTasksAndInvalidate;
- (void)invalidateAndCancel;
- (void)resetWithCompletionHandler:(void (^)(void))completionHandler;
- (void)flushWithCompletionHandler:(void (^)(void))completionHandler;
- (void)getTasksWithCompletionHandler:(void (^)(NSArray<NSURLSessionDataTask *> *dataTasks, NSArray<NSURLSessionUploadTask *> *uploadTasks, NSArray<NSURLSessionDownloadTask *> *downloadTasks))completionHandler;
- (void)getAllTasksWithCompletionHandler:(void (^)(NSArray<__kindof NSURLSessionTask *> *tasks))completionHandler;
- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request;
- (NSURLSessionDataTask *)dataTaskWithURL:(NSURL *)url;
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL;
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromData:(NSData *)bodyData;
- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request;
- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request;
- (NSURLSessionDownloadTask *)downloadTaskWithURL:(NSURL *)url;
- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData;
- (NSURLSessionStreamTask *)streamTaskWithHostName:(NSString *)hostname port:(NSInteger)port;
- (NSURLSessionStreamTask *)streamTaskWithNetService:(NSNetService *)service;
@end
@interface WebCoreNSURLSession (NSURLSessionAsynchronousConvenience)
- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request completionHandler:(void (^)(NSData * data, NSURLResponse * response, NSError * error))completionHandler;
- (NSURLSessionDataTask *)dataTaskWithURL:(NSURL *)url completionHandler:(void (^)(NSData * data, NSURLResponse * response, NSError * error))completionHandler;
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL completionHandler:(void (^)(NSData * data, NSURLResponse * response, NSError * error))completionHandler;
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromData:(nullable NSData *)bodyData completionHandler:(void (^)(NSData * data, NSURLResponse * response, NSError * error))completionHandler;
- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request completionHandler:(void (^)(NSURL * location, NSURLResponse * response, NSError * error))completionHandler;
- (NSURLSessionDownloadTask *)downloadTaskWithURL:(NSURL *)url completionHandler:(void (^)(NSURL * location, NSURLResponse * response, NSError * error))completionHandler;
- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData completionHandler:(void (^)(NSURL * location, NSURLResponse * response, NSError * error))completionHandler;
@end
@interface WebCoreNSURLSessionDataTask : NSObject {
WebCoreNSURLSession *_session;
RefPtr<WebCore::PlatformMediaResource> _resource;
RetainPtr<NSURLResponse> _response;
NSUInteger _taskIdentifier;
NSURLRequest *_originalRequest;
NSURLRequest *_currentRequest;
int64_t _countOfBytesReceived;
int64_t _countOfBytesSent;
int64_t _countOfBytesExpectedToSend;
int64_t _countOfBytesExpectedToReceive;
NSURLSessionTaskState _state;
NSError *_error;
NSString *_taskDescription;
float _priority;
}
@property NSUInteger taskIdentifier;
@property (copy) NSURLRequest *originalRequest;
@property (copy) NSURLRequest *currentRequest;
@property (readonly, copy) NSURLResponse *response;
@property int64_t countOfBytesReceived;
@property int64_t countOfBytesSent;
@property int64_t countOfBytesExpectedToSend;
@property int64_t countOfBytesExpectedToReceive;
@property NSURLSessionTaskState state;
@property (copy) NSError *error;
@property (copy) NSString *taskDescription;
@property float priority;
- (void)cancel;
- (void)suspend;
- (void)resume;
@end
NS_ASSUME_NONNULL_END
#endif