Merge branch 'experimental-1.0RC1' into experimental-pause-resume
Conflicts: AFNetworking/AFURLConnectionOperation.h AFNetworking/AFURLConnectionOperation.m
This commit is contained in:
commit
7e16e13a3a
3 changed files with 53 additions and 2 deletions
|
|
@ -161,6 +161,19 @@ extern NSString * const AFNetworkingOperationDidFinishNotification;
|
||||||
|
|
||||||
- (void)resume;
|
- (void)resume;
|
||||||
|
|
||||||
|
///----------------------------------------------
|
||||||
|
/// @name Configuring Backgrounding Task Behavior
|
||||||
|
///----------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task.
|
||||||
|
|
||||||
|
@param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified.
|
||||||
|
*/
|
||||||
|
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||||
|
- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler;
|
||||||
|
#endif
|
||||||
|
|
||||||
///---------------------------------
|
///---------------------------------
|
||||||
/// @name Setting Progress Callbacks
|
/// @name Setting Progress Callbacks
|
||||||
///---------------------------------
|
///---------------------------------
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,15 @@ typedef enum {
|
||||||
|
|
||||||
typedef signed short AFOperationState;
|
typedef signed short AFOperationState;
|
||||||
|
|
||||||
|
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||||
|
typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier;
|
||||||
|
#else
|
||||||
|
typedef id AFBackgroundTaskIdentifier;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static NSUInteger const kAFHTTPMinimumInitialDataCapacity = 1024;
|
||||||
|
static NSUInteger const kAFHTTPMaximumInitialDataCapacity = 1024 * 1024 * 8;
|
||||||
|
|
||||||
static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock";
|
static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock";
|
||||||
|
|
||||||
NSString * const AFNetworkingErrorDomain = @"com.alamofire.networking.error";
|
NSString * const AFNetworkingErrorDomain = @"com.alamofire.networking.error";
|
||||||
|
|
@ -98,6 +107,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
|
||||||
@property (readwrite, nonatomic, retain) NSData *responseData;
|
@property (readwrite, nonatomic, retain) NSData *responseData;
|
||||||
@property (readwrite, nonatomic, copy) NSString *responseString;
|
@property (readwrite, nonatomic, copy) NSString *responseString;
|
||||||
@property (readwrite, nonatomic, assign) long long totalBytesRead;
|
@property (readwrite, nonatomic, assign) long long totalBytesRead;
|
||||||
|
@property (readwrite, nonatomic, assign) AFBackgroundTaskIdentifier backgroundTaskIdentifier;
|
||||||
@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress;
|
@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress;
|
||||||
@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress;
|
@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress;
|
||||||
@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationAgainstProtectionSpaceBlock authenticationAgainstProtectionSpace;
|
@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationAgainstProtectionSpaceBlock authenticationAgainstProtectionSpace;
|
||||||
|
|
@ -121,6 +131,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
|
||||||
@synthesize totalBytesRead = _totalBytesRead;
|
@synthesize totalBytesRead = _totalBytesRead;
|
||||||
@dynamic inputStream;
|
@dynamic inputStream;
|
||||||
@synthesize outputStream = _outputStream;
|
@synthesize outputStream = _outputStream;
|
||||||
|
@synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier;
|
||||||
@synthesize uploadProgress = _uploadProgress;
|
@synthesize uploadProgress = _uploadProgress;
|
||||||
@synthesize downloadProgress = _downloadProgress;
|
@synthesize downloadProgress = _downloadProgress;
|
||||||
@synthesize authenticationAgainstProtectionSpace = _authenticationAgainstProtectionSpace;
|
@synthesize authenticationAgainstProtectionSpace = _authenticationAgainstProtectionSpace;
|
||||||
|
|
@ -186,6 +197,13 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
|
||||||
_outputStream = nil;
|
_outputStream = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||||
|
if (_backgroundTaskIdentifier) {
|
||||||
|
[[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier];
|
||||||
|
_backgroundTaskIdentifier = UIBackgroundTaskInvalid;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
[_uploadProgress release];
|
[_uploadProgress release];
|
||||||
[_downloadProgress release];
|
[_downloadProgress release];
|
||||||
[_authenticationChallenge release];
|
[_authenticationChallenge release];
|
||||||
|
|
@ -240,6 +258,26 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||||
|
- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler {
|
||||||
|
[self.lock lock];
|
||||||
|
if (!self.backgroundTaskIdentifier) {
|
||||||
|
UIApplication *application = [UIApplication sharedApplication];
|
||||||
|
self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{
|
||||||
|
if (handler) {
|
||||||
|
handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
[self cancel];
|
||||||
|
|
||||||
|
[application endBackgroundTask:self.backgroundTaskIdentifier];
|
||||||
|
self.backgroundTaskIdentifier = UIBackgroundTaskInvalid;
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
[self.lock unlock];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
- (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block {
|
- (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block {
|
||||||
self.uploadProgress = block;
|
self.uploadProgress = block;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue