| 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 #ifndef CHROME_INSTALLER_MAC_APP_NETWORKCOMMUNICATION_H_ | 5 #ifndef CHROME_INSTALLER_MAC_APP_NETWORKCOMMUNICATION_H_ |
| 6 #define CHROME_INSTALLER_MAC_APP_NETWORKCOMMUNICATION_H_ | 6 #define CHROME_INSTALLER_MAC_APP_NETWORKCOMMUNICATION_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 // TODO: talk to @sdy about this class |
| 11 @interface NetworkCommunication : NSObject |
| 12 |
| 10 typedef void (^DataTaskCompletionHandler)(NSData*, NSURLResponse*, NSError*); | 13 typedef void (^DataTaskCompletionHandler)(NSData*, NSURLResponse*, NSError*); |
| 11 typedef void (^DownloadTaskCompletionHandler)(NSURL*, NSURLResponse*, NSError*); | |
| 12 | |
| 13 @interface NetworkCommunication : NSObject | |
| 14 | 14 |
| 15 @property(nonatomic, copy) NSMutableURLRequest* request; | 15 @property(nonatomic, copy) NSMutableURLRequest* request; |
| 16 @property(nonatomic, copy) NSURLSession* session; | 16 @property(nonatomic, copy) NSURLSession* session; |
| 17 @property(nonatomic, copy) DataTaskCompletionHandler dataResponseHandler; | 17 @property(nonatomic, copy) DataTaskCompletionHandler dataResponseHandler; |
| 18 @property(nonatomic, copy) | |
| 19 DownloadTaskCompletionHandler downloadResponseHandler; | |
| 20 | 18 |
| 21 - (id)init; | 19 - (id)init; |
| 22 - (id)initWithDelegate:(id)delegate; | 20 - (id)initWithDelegate:(id)delegate; |
| 23 | 21 |
| 24 // Creates a mutable URLRequest object as an instance variable, then returns it | 22 // Creates a mutable URLRequest object as an instance variable, then returns it |
| 25 // so the caller has a chance to edit it before sending the request out. | 23 // so the caller has a chance to edit it before sending the request out. |
| 26 - (NSMutableURLRequest*)createRequestWithUrlAsString:(NSString*)urlString | 24 - (NSMutableURLRequest*)createRequestWithUrlAsString:(NSString*)urlString |
| 27 andXMLBody:(NSXMLDocument*)body; | 25 andXMLBody:(NSXMLDocument*)body; |
| 28 // Adds a data task to the run loop using the request instance variable. | 26 // Adds a data task to the run loop using the request instance variable. |
| 29 - (void)sendDataRequestWithCompletionHandler: | 27 - (void)sendDataRequest; |
| 30 (DataTaskCompletionHandler)completionHandler; | |
| 31 // Adds a download task to the run loop using the request instance variable. | 28 // Adds a download task to the run loop using the request instance variable. |
| 32 - (void)sendDownloadRequest; | 29 - (void)sendDownloadRequest; |
| 33 | 30 |
| 34 @end | 31 @end |
| 35 | 32 |
| 36 #endif // CHROME_INSTALLER_MAC_APP_NETWORKCOMMUNICATION_H_ | 33 #endif // CHROME_INSTALLER_MAC_APP_NETWORKCOMMUNICATION_H_ |
| OLD | NEW |