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

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

Issue 2094583004: Initial commit for Chrome metainstaller on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed majority of comments excluding refactoring for blocks in main. 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 "OmahaCommunication.h"
7
8 @implementation OmahaCommunication : NSObject
9
10 @synthesize requestXMLBody;
11 @synthesize sessionHelper;
12
13 - (id)init {
14 return [self initWithBody:[[NSXMLDocument alloc] init]];
15 }
16 - (id)initWithBody:(NSXMLDocument*) xmlBody {
17 if ((self = [super init])) {
18 sessionHelper = [[NetworkCommunication alloc] init];
19 requestXMLBody = xmlBody;
20 [self createOmahaRequest];
21 }
22 return self;
23 }
24
25 - (NSURLRequest*)createOmahaRequest {
26 NSMutableURLRequest* request = [sessionHelper
27 createRequestWithURLasString:@"https://tools.google.com/service/update2"
28 andXMLBody:requestXMLBody];
29 request.HTTPMethod = @"POST";
30 return request;
31 }
32
33 - (void)sendRequestWithBlock:(OmahaRequestCompletionHandler) block {
34 DataTaskCompletionHandler cHandler = ^(NSData* _Nullable data,
35 NSURLResponse* _Nullable response,
36 NSError* _Nullable error) {
37 if (error) {
38 NSLog(@"%@", error);
39 block(data, error);
40 return;
41 }
42
43 NSHTTPURLResponse* HTTPResponse = (NSHTTPURLResponse*)response;
44 if (HTTPResponse.statusCode != 200) {
45 NSLog(@"HTTP response: %ld", (unsigned long)HTTPResponse.statusCode);
46 }
47
48 block(data, error);
49
50 };
51
52 [sessionHelper sendDataRequestWithCompletionHandler:cHandler];
53 }
54
55 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698