OLD | NEW |
---|---|
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 "MainDelegate.h" |
8 #import "OmahaCommunication.h" | |
9 #import "OmahaXMLRequest.h" | |
10 #import "SystemInfo.h" | |
11 | 8 |
12 // TODO: add a class that takes care of what main is doing now | 9 int main(int argc, const char* argv[]) { |
13 void talkToOmahaThenExecuteBlock(OmahaRequestCompletionHandler block) { | 10 MainDelegate* delegate = [[MainDelegate alloc] init]; |
14 NSXMLDocument* requestBody = [OmahaXMLRequest createXMLRequestBody]; | 11 [delegate runApplication]; |
15 OmahaCommunication* messenger = | |
16 [[OmahaCommunication alloc] initWithBody:requestBody]; | |
17 [messenger sendRequestWithBlock:block]; | |
18 } | |
19 | 12 |
20 int main() { | 13 [[NSRunLoop mainRunLoop] run]; |
21 talkToOmahaThenExecuteBlock(^(NSData* data, NSError* error) { | 14 // [[NSRunLoop mainRunLoop] |
22 if (error) { | 15 // runUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]]; |
Sidney San Martín
2016/07/22 02:30:17
Maybe delete this, instead of leaving it commented
| |
23 NSLog(@"%@", [error localizedDescription]); | |
24 return; | |
25 } | |
26 Downloader* download = [[Downloader alloc] init]; | |
27 [download downloadChromeImageToDownloadsDirectory:data]; | |
28 }); | |
29 | |
30 // [[NSRunLoop mainRunLoop] run]; | |
31 [[NSRunLoop mainRunLoop] | |
32 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:3]]; | |
33 return 1; | 16 return 1; |
34 } | 17 } |
OLD | NEW |