Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/installer/mac/app/NetworkCommunication.m

Issue 2094583004: Initial commit for Chrome metainstaller on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed all comments except main block comment from elly Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #import <Foundation/Foundation.h>
6 #include "NetworkCommunication.h"
Mark Mentovai 2016/07/11 17:56:16 #import "NetworkCommunication.h" (blank line)
7
8 @implementation NetworkCommunication : NSObject
9
10 @synthesize session = session_;
11 @synthesize request = request_;
12 @synthesize dataResponseHandler = dataResponseHandler_;
13 @synthesize downloadResponseHandler = downloadResponseHandler_;
14
15 - (id)init {
16 return [self initWithDelegate:nil];
17 }
18
19 - (id)initWithDelegate:(id)delegate {
20 if ((self = [super init])) {
21 NSURLSessionConfiguration* sessionConfig =
22 [NSURLSessionConfiguration defaultSessionConfiguration];
23 session_ = [NSURLSession sessionWithConfiguration:sessionConfig
24 delegate:delegate
25 delegateQueue:nil];
26 }
27 return self;
28 }
29
30 - (NSMutableURLRequest*)createRequestWithUrlAsString:(NSString*)urlString
31 andXMLBody:(NSXMLDocument*)body {
32 NSURL* requestURL = [NSURL URLWithString:urlString];
33 request_ = [NSMutableURLRequest requestWithURL:requestURL];
34 if (body) {
35 [request_ addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
36 NSData* requestBody =
37 [[body XMLString] dataUsingEncoding:NSUTF8StringEncoding];
38 request_.HTTPBody = requestBody;
39 }
40 return request_;
41 }
42
43 - (void)sendDataRequestWithCompletionHandler:
44 (DataTaskCompletionHandler)completionHandler {
45 dataResponseHandler_ = completionHandler;
46 NSURLSessionDataTask* dataTask =
47 [session_ dataTaskWithRequest:request_
48 completionHandler:dataResponseHandler_];
49
50 [dataTask resume];
51 return;
Elly Fong-Jones 2016/07/11 16:15:48 nit: superfluous return
52 }
53
54 - (void)sendDownloadRequest {
55 NSURLSessionDownloadTask* downloadTask;
56 if (downloadResponseHandler_) {
57 downloadTask = [session_ downloadTaskWithRequest:request_
58 completionHandler:downloadResponseHandler_];
59 } else {
60 downloadTask = [session_ downloadTaskWithRequest:request_];
61 }
62 [downloadTask resume];
63
64 return;
Elly Fong-Jones 2016/07/11 16:15:48 nit: this is superfluous
65 }
66
67 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698