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

Unified 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: Fully addressed making the .dmg download asynchronously Created 4 years, 6 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/OmahaCommunication.m
diff --git a/chrome/installer/mac/app/OmahaCommunication.m b/chrome/installer/mac/app/OmahaCommunication.m
new file mode 100644
index 0000000000000000000000000000000000000000..2e3c22834189e8e8904b23181bb8f46ccda9ea59
--- /dev/null
+++ b/chrome/installer/mac/app/OmahaCommunication.m
@@ -0,0 +1,59 @@
+// 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 <Foundation/Foundation.h>
+#include "OmahaCommunication.h"
+
+@implementation OmahaCommunication : NSObject
+
+@synthesize requestXMLBody;
+@synthesize sessionHelper;
+
+- (id)init {
+ return [self initWithBody:[[NSXMLDocument alloc] init]];
+}
+- (id)initWithBody:(NSXMLDocument*) xmlBody {
+ if ((self = [super init])) {
+ sessionHelper = [[NetworkCommunication alloc] init];
+ requestXMLBody = xmlBody;
+ }
+ return self;
+}
+
+- (NSURLRequest*)createOmahaRequest {
+ NSMutableURLRequest* request = [sessionHelper
Elly Fong-Jones 2016/07/06 15:22:01 Hm, is there a reason for this function to be sepa
+ createRequestWithURLasString:@"https://tools.google.com/service/update2"
Elly Fong-Jones 2016/07/06 15:22:02 this should probably be a constant somewhere, and
Anna Zeng 2016/07/07 15:24:53 how do we accomplish this?
+ andXMLBody:requestXMLBody];
+ request.HTTPMethod = @"POST";
+ return request;
+}
+
+- (void)setResponseHandlingWithBlock:(AfterBlock)blockToRunAfter {
+ DataTaskCompletionHandler cHandler = ^(NSData* _Nullable data,
+ NSURLResponse* _Nullable response,
+ NSError* _Nullable error) {
+ if(error) {
Elly Fong-Jones 2016/07/06 15:22:02 I think we need to notify the user of this class t
+ NSLog(@"%@", error);
+ return;
+ }
+
+ NSHTTPURLResponse* HTTPResponse = (NSHTTPURLResponse*)response;
+ if(HTTPResponse.statusCode != 200) {
+ NSLog(@"HTTP response: %ld", (unsigned long)HTTPResponse.statusCode);
+ return;
Elly Fong-Jones 2016/07/06 15:22:01 same comment - we need a better way to indicate th
+ }
+
+ // run block here
Elly Fong-Jones 2016/07/06 15:22:01 this comment doesn't seem like it adds much to und
+ blockToRunAfter(data);
+
+ };
+
+ [sessionHelper setDataResponseHandler:cHandler];
+}
+
+- (void)sendRequest {
+ [sessionHelper sendDataRequest];
Elly Fong-Jones 2016/07/06 15:22:01 I could collapse this and setResponseHandlingWithB
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698