OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
6 | 6 |
7 #import "NetworkCommunication.h" | 7 #import "NetworkCommunication.h" |
8 | 8 |
| 9 @interface NSURLSession (PartialAvailability) |
| 10 - (NSURLSessionDataTask*)dataTaskWithRequest:(NSURLRequest*)request |
| 11 completionHandler: |
| 12 (void (^)(NSData* data, |
| 13 NSURLResponse* response, |
| 14 NSError* error))completionHandler; |
| 15 - (NSURLSessionDownloadTask*) |
| 16 downloadTaskWithRequest:(NSURLRequest*)request |
| 17 completionHandler:(void (^)(NSURL* location, |
| 18 NSURLResponse* response, |
| 19 NSError* error))completionHandler; |
| 20 @end |
| 21 |
9 @implementation NetworkCommunication : NSObject | 22 @implementation NetworkCommunication : NSObject |
10 | 23 |
11 @synthesize session = session_; | 24 @synthesize session = session_; |
12 @synthesize request = request_; | 25 @synthesize request = request_; |
13 @synthesize dataResponseHandler = dataResponseHandler_; | 26 @synthesize dataResponseHandler = dataResponseHandler_; |
14 @synthesize downloadResponseHandler = downloadResponseHandler_; | 27 @synthesize downloadResponseHandler = downloadResponseHandler_; |
15 | 28 |
16 - (id)init { | 29 - (id)init { |
17 return [self initWithDelegate:nil]; | 30 return [self initWithDelegate:nil]; |
18 } | 31 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (downloadResponseHandler_) { | 69 if (downloadResponseHandler_) { |
57 downloadTask = [session_ downloadTaskWithRequest:request_ | 70 downloadTask = [session_ downloadTaskWithRequest:request_ |
58 completionHandler:downloadResponseHandler_]; | 71 completionHandler:downloadResponseHandler_]; |
59 } else { | 72 } else { |
60 downloadTask = [session_ downloadTaskWithRequest:request_]; | 73 downloadTask = [session_ downloadTaskWithRequest:request_]; |
61 } | 74 } |
62 [downloadTask resume]; | 75 [downloadTask resume]; |
63 } | 76 } |
64 | 77 |
65 @end | 78 @end |
OLD | NEW |