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

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: 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/OmahaCommunication.m
diff --git a/chrome/installer/mac/app/OmahaCommunication.m b/chrome/installer/mac/app/OmahaCommunication.m
new file mode 100644
index 0000000000000000000000000000000000000000..819f323d1e3bb990fc830ed613991f16aab42f3a
--- /dev/null
+++ b/chrome/installer/mac/app/OmahaCommunication.m
@@ -0,0 +1,55 @@
+// 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;
+ [self createOmahaRequest];
+ }
+ return self;
+}
+
+- (NSURLRequest*)createOmahaRequest {
+ NSMutableURLRequest* request = [sessionHelper
+ createRequestWithURLasString:@"https://tools.google.com/service/update2"
+ andXMLBody:requestXMLBody];
+ request.HTTPMethod = @"POST";
+ return request;
+}
+
+- (void)sendRequestWithBlock:(OmahaRequestCompletionHandler) block {
+ DataTaskCompletionHandler cHandler = ^(NSData* _Nullable data,
+ NSURLResponse* _Nullable response,
+ NSError* _Nullable error) {
+ if (error) {
+ NSLog(@"%@", error);
+ block(data, error);
+ return;
+ }
+
+ NSHTTPURLResponse* HTTPResponse = (NSHTTPURLResponse*)response;
+ if (HTTPResponse.statusCode != 200) {
+ NSLog(@"HTTP response: %ld", (unsigned long)HTTPResponse.statusCode);
+ }
+
+ block(data, error);
+
+ };
+
+ [sessionHelper sendDataRequestWithCompletionHandler:cHandler];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698