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

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: Made small changes according to LGTM comments 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
« no previous file with comments | « chrome/installer/mac/app/NetworkCommunication.h ('k') | chrome/installer/mac/app/OWNERS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
7 #import "NetworkCommunication.h"
8
9 @implementation NetworkCommunication : NSObject
10
11 @synthesize session = session_;
12 @synthesize request = request_;
13 @synthesize dataResponseHandler = dataResponseHandler_;
14 @synthesize downloadResponseHandler = downloadResponseHandler_;
15
16 - (id)init {
17 return [self initWithDelegate:nil];
18 }
19
20 - (id)initWithDelegate:(id)delegate {
21 if ((self = [super init])) {
22 NSURLSessionConfiguration* sessionConfig =
23 [NSURLSessionConfiguration defaultSessionConfiguration];
24 session_ = [NSURLSession sessionWithConfiguration:sessionConfig
25 delegate:delegate
26 delegateQueue:nil];
27 }
28 return self;
29 }
30
31 - (NSMutableURLRequest*)createRequestWithUrlAsString:(NSString*)urlString
32 andXMLBody:(NSXMLDocument*)body {
33 NSURL* requestURL = [NSURL URLWithString:urlString];
34 request_ = [NSMutableURLRequest requestWithURL:requestURL];
35 if (body) {
36 [request_ addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
37 NSData* requestBody =
38 [[body XMLString] dataUsingEncoding:NSUTF8StringEncoding];
39 request_.HTTPBody = requestBody;
40 }
41 return request_;
42 }
43
44 - (void)sendDataRequestWithCompletionHandler:
45 (DataTaskCompletionHandler)completionHandler {
46 dataResponseHandler_ = completionHandler;
47 NSURLSessionDataTask* dataTask =
48 [session_ dataTaskWithRequest:request_
49 completionHandler:dataResponseHandler_];
50
51 [dataTask resume];
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
65 @end
OLDNEW
« no previous file with comments | « chrome/installer/mac/app/NetworkCommunication.h ('k') | chrome/installer/mac/app/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698