From a784e84497395f0ddbd787bc95194f6037dd6dc4 Mon Sep 17 00:00:00 2001 From: George Kola Date: Wed, 8 Mar 2017 22:32:33 -0800 Subject: Use NSURLSession if the min version we support is iOS 7+. Because many apps still support iOS 8, they were defaulting to deprecated NSURLConnection even if the code ran on iOS 10. NSURLConnection requires a run loop and hence the code did not always upload if the queue ran on a thread without a Run Loop. This should improve break pad uploads BUG= Change-Id: I7bff80ea977fd1ab13c8812ed933ef842dab417f Reviewed-on: https://chromium-review.googlesource.com/451880 Reviewed-by: Sylvain Defresne Reviewed-by: Mark Mentovai --- src/common/mac/HTTPMultipartUpload.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/common') diff --git a/src/common/mac/HTTPMultipartUpload.m b/src/common/mac/HTTPMultipartUpload.m index 9ac886d5..f6d081e4 100644 --- a/src/common/mac/HTTPMultipartUpload.m +++ b/src/common/mac/HTTPMultipartUpload.m @@ -49,13 +49,13 @@ static NSString *PercentEncodeNSString(NSString *key) { // As -[NSURLConnection sendSynchronousRequest:returningResponse:error:] has // been deprecated with iOS 9.0 / OS X 10.11 SDKs, this function re-implements -// it using -[NSURLSession dataTaskWithRequest:completionHandler:] when using -// those SDKs. +// it using -[NSURLSession dataTaskWithRequest:completionHandler:] which is +// available on iOS 7+. static NSData *SendSynchronousNSURLRequest(NSURLRequest *req, NSURLResponse **out_response, NSError **out_error) { -#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_9_0) && \ - __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0) || \ +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_7_0) && \ + __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0) || \ (defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ defined(MAC_OS_X_VERSION_10_11) && \ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11) @@ -223,9 +223,7 @@ static NSData *SendSynchronousNSURLRequest(NSURLRequest *req, // Add any files to the message NSArray *fileNames = [files_ allKeys]; - count = [fileNames count]; - for (NSInteger i = 0; i < count; ++i) { - NSString *name = [fileNames objectAtIndex:i]; + for (NSString *name in fileNames) { id fileOrData = [files_ objectForKey:name]; NSData *fileData; -- cgit v1.2.1