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

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

Issue 2148293005: Migrate mac installer to delegate-driven model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Foundation/Foundation.h> 5 #import <Foundation/Foundation.h>
6 6
7 #import "Downloader.h" 7 #import "Downloader.h"
8 #import "OmahaCommunication.h" 8 #import "OmahaCommunication.h"
9 #import "OmahaXMLRequest.h" 9 #import "OmahaXMLRequest.h"
10 #import "SystemInfo.h" 10 #import "SystemInfo.h"
11 11
12 // TODO: add a class that takes care of what main is doing now 12 void talkToOmaha() {
13 void talkToOmahaThenExecuteBlock(OmahaRequestCompletionHandler block) {
14 NSXMLDocument* requestBody = [OmahaXMLRequest createXMLRequestBody]; 13 NSXMLDocument* requestBody = [OmahaXMLRequest createXMLRequestBody];
15 OmahaCommunication* messenger = 14 OmahaCommunication* messenger =
16 [[OmahaCommunication alloc] initWithBody:requestBody]; 15 [[OmahaCommunication alloc] initWithBody:requestBody];
17 [messenger sendRequestWithBlock:block]; 16 [messenger sendRequestWithBlock:^(NSData* data, NSError* error) {
18 }
19
20 int main() {
21 talkToOmahaThenExecuteBlock(^(NSData* data, NSError* error) {
22 if (error) { 17 if (error) {
23 NSLog(@"%@", [error localizedDescription]); 18 NSLog(@"%@", [error localizedDescription]);
24 return; 19 return;
25 } 20 }
26 Downloader* download = [[Downloader alloc] init]; 21
27 [download downloadChromeImageToDownloadsDirectory:data]; 22 downloadChrome();
Sidney San Martín 2016/07/18 18:28:52 It's confusing that talkToOmaha() also starts the
28 }); 23 }];
24 }
25
26 void downloadChrome() {
27 Downloader* download = [[Downloader alloc] init];
28 [download downloadChromeImageToDownloadsDirectory:data];
29 }
30
31 int main() {
32 talkToOmaha();
29 33
30 // [[NSRunLoop mainRunLoop] run]; 34 // [[NSRunLoop mainRunLoop] run];
31 [[NSRunLoop mainRunLoop] 35 [[NSRunLoop mainRunLoop]
32 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:3]]; 36 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:3]];
Sidney San Martín 2016/07/18 18:28:52 You should probably just call `run`, and then exit
33 return 1; 37 return 1;
34 } 38 }
OLDNEW
« chrome/installer/mac/app/DownloadDelegate.m ('K') | « chrome/installer/mac/app/DownloadDelegate.m ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698