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 "MainDelegate.h" | 5 #import "MainDelegate.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | |
8 | |
9 extern dispatch_semaphore_t mount_semaphore; | |
Sidney San Martín
2016/08/08 18:43:17
As discussed: a random extern definitely shouldn't
Anna Zeng
2016/08/12 22:56:18
Done.
| |
10 | |
7 @implementation MainDelegate | 11 @implementation MainDelegate |
8 | 12 |
9 - (void)runApplication { | 13 - (void)runApplication { |
10 OmahaCommunication* messenger = [[OmahaCommunication alloc] init]; | 14 OmahaCommunication* messenger = [[OmahaCommunication alloc] init]; |
11 messenger.delegate = self; | 15 messenger.delegate = self; |
12 | 16 |
13 [messenger sendRequest]; | 17 [messenger sendRequest]; |
14 } | 18 } |
15 | 19 |
16 - (void)onOmahaSuccessWithResponseBody:(NSData*)responseBody | 20 - (void)onOmahaSuccessWithResponseBody:(NSData*)responseBody |
17 AndError:(NSError*)error { | 21 AndError:(NSError*)error { |
18 if (error) { | 22 if (error) { |
19 NSLog(@"error: %@", [error localizedDescription]); | 23 NSLog(@"error: %@", [error localizedDescription]); |
20 exit(1); | 24 exit(1); |
21 } | 25 } |
22 Downloader* download = [[Downloader alloc] init]; | 26 Downloader* download = [[Downloader alloc] init]; |
23 download.delegate = self; | 27 download.delegate = self; |
24 | 28 |
25 [download downloadChromeImageToDownloadsDirectory:responseBody]; | 29 [download downloadChromeImageToDownloadsDirectory:responseBody]; |
26 } | 30 } |
27 | 31 |
28 - (void)onDownloadSuccess { | 32 - (void)onDownloadSuccess { |
29 // TODO: replace the line of code below with real code someday to unpack dmg | 33 Unpacker* unpack = [[Unpacker alloc] init]; |
34 unpack.delegate = self; | |
35 mount_semaphore = dispatch_semaphore_create(0); | |
36 | |
37 [unpack mountDMG]; | |
38 dispatch_semaphore_wait(mount_semaphore, DISPATCH_TIME_FOREVER); | |
39 [unpack unmountDMG]; | |
40 dispatch_semaphore_wait(mount_semaphore, DISPATCH_TIME_FOREVER); | |
Sidney San Martín
2016/08/08 18:43:17
As discussed:
1. mountDMG and unmountDMG are imple
Anna Zeng
2016/08/12 22:56:18
#2 is taken care of; #1 is acknowledged and still
| |
41 } | |
42 | |
43 - (void)onUnpackSuccess { | |
44 if (![[NSWorkspace sharedWorkspace] launchApplication:@"Google Chromo"]) { | |
45 NSLog(@"Chromo failed to launch"); | |
46 } | |
30 exit(0); | 47 exit(0); |
31 } | 48 } |
32 | 49 |
33 - (void)onUnpackSuccess { | |
34 } | |
35 | |
36 @end | 50 @end |
OLD | NEW |