Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_INSTALLER_MAC_APP_NETWORKCOMMUNICATION_H_ | |
| 6 #define CHROME_INSTALLER_MAC_APP_NETWORKCOMMUNICATION_H_ | |
| 7 | |
| 8 #import <Foundation/Foundation.h> | |
| 9 | |
| 10 typedef void (^DataTaskCompletionHandler)(NSData*, NSURLResponse*, NSError*); | |
| 11 typedef void (^DownloadTaskCompletionHandler)(NSURL*, NSURLResponse*, NSError*); | |
| 12 | |
| 13 @interface NetworkCommunication : NSObject | |
| 14 | |
| 15 @property(nonatomic, copy) NSMutableURLRequest* request; | |
| 16 // Question: Our current design of the project thus far involves having one | |
| 17 // NSURLSession run the whole show. Thoughts? Is this one of those | |
| 18 // things that don't really matter, or does it have a positive / | |
|
Elly Fong-Jones
2016/07/06 15:22:01
I think it's fine to just have one NSURLSession, b
| |
| 19 // negative impact on our project? | |
| 20 @property(nonatomic, copy) NSURLSession* session; | |
| 21 // The user of this class must set these handlers if functionality is needed at | |
| 22 // the completion of a URLSession task. | |
| 23 @property(nonatomic, copy) DataTaskCompletionHandler dataResponseHandler; | |
| 24 @property(nonatomic, copy) DownloadTaskCompletionHandler downloadResponseHandler ; | |
| 25 | |
| 26 - (id)init; | |
| 27 - (id)initWithDelegate:(id) delegate; | |
| 28 | |
| 29 // Creates a mutable URLRequest object as an instance variable, then returns it | |
| 30 // so the caller has a chance to edit it before sending the request out. | |
| 31 // Contrary to the assumption in Objective-C that all return values are returned | |
| 32 // by VALUE, it seems that changes made to the returned object outside of this | |
| 33 // class are retained. | |
| 34 - (NSMutableURLRequest*)createRequestWithURLasString:(NSString*) urlString | |
| 35 andXMLBody:(NSXMLDocument*) body; | |
| 36 // Adds a data task to the run loop using the request instance variable. | |
| 37 - (NSURLSessionDataTask*)sendDataRequest; | |
|
Elly Fong-Jones
2016/07/06 15:22:01
Hm... sendDataRequestWithCompletionHandler:? Will
Anna Zeng
2016/07/07 15:24:53
including the completion handler means that delega
| |
| 38 // Adds a download task to the run loop using the request instance variable. | |
| 39 - (NSURLSessionDownloadTask*)sendDownloadRequest; | |
| 40 | |
| 41 @end | |
| 42 | |
| 43 #endif // CHROME_INSTALLER_MAC_APP_NETWORKCOMMUNICATION_H_ | |
| OLD | NEW |