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

Unified Diff: chrome/installer/mac/app/DownloadDelegate.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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/mac/app/DownloadDelegate.m
diff --git a/chrome/installer/mac/app/DownloadDelegate.m b/chrome/installer/mac/app/DownloadDelegate.m
new file mode 100644
index 0000000000000000000000000000000000000000..f8da51ad45dc069c685799904eb569849de7736c
--- /dev/null
+++ b/chrome/installer/mac/app/DownloadDelegate.m
@@ -0,0 +1,45 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "DownloadDelegate.h"
+#import "downloader.h"
+
+@implementation DownloadDelegate : NSObject
+
+// Skeleton of delegate method to provide download progress updates.
+// TODO: Make use of (totalBytesWritten/totalBytesExpectedToWrite)*100
+// to generate download progress percentage.
+- (void)URLSession:(NSURLSession*)session
+ downloadTask:(NSURLSessionDownloadTask*)downloadTask
+ didWriteData:(int64_t)bytesWritten
+ totalBytesWritten:(int64_t)totalBytesWritten
+totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite{
+
+}
+
+// Delegate method to move downloaded disk image to user's Download directory.
+- (void)URLSession:(NSURLSession*)session
+ downloadTask:(NSURLSessionDownloadTask*)downloadTask
+didFinishDownloadingToURL:(NSURL*)location{
+ NSFileManager* manager = [[NSFileManager alloc] init];
Mark Mentovai 2016/07/07 17:53:48 Background reading on scoped_nsobject<>, although
+ NSString* temporaryDownloadDirectory = [NSString stringWithFormat:@"%@",
Mark Mentovai 2016/07/07 17:53:48 location.path should give you an NSString*, you do
+ location.path];
+ NSURL* downloadsDirectory = [[NSURL alloc] initFileURLWithPath:[Downloader
+ getDownloadsFilePath]];
+ if ( [manager fileExistsAtPath:temporaryDownloadDirectory] ){
+ [manager copyItemAtURL:location toURL:downloadsDirectory error:nil];
Mark Mentovai 2016/07/07 17:53:48 What happens to the original temporary copy?
+ NSLog(@"File was downloaded to Downloads.");
Mark Mentovai 2016/07/07 17:53:48 We shouldn’t check in logging like this.
+ } else {
+ // TODO: Error Handling
+ }
+
+}
+
+- (void)URLSession:(NSURLSession *)session
+ task:(NSURLSessionTask *)task
+didCompleteWithError:(NSError *)error{
+ // TODO: Error Handling
+}
+@end
+

Powered by Google App Engine
This is Rietveld 408576698