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

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: 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
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 #include "OmahaCommunication.h"
8
9 @implementation OmahaCommunication : NSObject
10
11 @synthesize requestXMLBody = requestXMLBody_;
12 @synthesize sessionHelper = sessionHelper_;
13
14 - (id)init {
15 return [self initWithBody:[[NSXMLDocument alloc] init]];
16 }
17
18 - (id)initWithBody:(NSXMLDocument*)xmlBody {
19 if ((self = [super init])) {
20 sessionHelper_ = [[NetworkCommunication alloc] init];
21 requestXMLBody_ = xmlBody;
22 [self createOmahaRequest];
23 }
24 return self;
25 }
26
27 - (NSURLRequest*)createOmahaRequest {
28 // TODO: turn this string to a comand-line flag
29 NSMutableURLRequest* request = [sessionHelper_
30 createRequestWithUrlAsString:@"https://tools.google.com/service/update2"
31 andXMLBody:requestXMLBody_];
32 request.HTTPMethod = @"POST";
33 return request;
34 }
35
36 - (void)sendRequestWithBlock:(OmahaRequestCompletionHandler)block {
37 DataTaskCompletionHandler cHandler =
38 ^(NSData* _Nullable data, NSURLResponse* _Nullable response,
39 NSError* _Nullable error) {
40 if (error) {
41 NSLog(@"%@", error);
42 block(data, error);
43 return;
44 }
45
46 NSHTTPURLResponse* HTTPResponse = (NSHTTPURLResponse*)response;
47 if (HTTPResponse.statusCode != 200) {
48 // TODO: make these logging statements more rare
49 NSLog(@"HTTP response: %ld", (unsigned long)HTTPResponse.statusCode);
50 }
51
52 block(data, error);
53
54 };
55
56 [sessionHelper_ sendDataRequestWithCompletionHandler:cHandler];
57 }
58
59 @end
OLDNEW
« no previous file with comments | « chrome/installer/mac/app/OmahaCommunication.h ('k') | chrome/installer/mac/app/OmahaXMLParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698