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

Side by Side Diff: chrome/app/keystone_glue.mm

Issue 344002: Map update check failure to "update server not available." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/cocoa/about_window_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/app/keystone_glue.h" 5 #import "chrome/app/keystone_glue.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #import "base/worker_pool_mac.h" 9 #import "base/worker_pool_mac.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
11 11
12 namespace {
13
12 // Provide declarations of the Keystone registration bits needed here. From 14 // Provide declarations of the Keystone registration bits needed here. From
13 // KSRegistration.h. 15 // KSRegistration.h.
14 typedef enum { kKSPathExistenceChecker } KSExistenceCheckerType; 16 typedef enum { kKSPathExistenceChecker } KSExistenceCheckerType;
15 17
16 NSString *KSRegistrationCheckForUpdateNotification = 18 NSString *KSRegistrationCheckForUpdateNotification =
17 @"KSRegistrationCheckForUpdateNotification"; 19 @"KSRegistrationCheckForUpdateNotification";
18 NSString *KSRegistrationStatusKey = @"Status"; 20 NSString *KSRegistrationStatusKey = @"Status";
19 NSString *KSRegistrationVersionKey = @"Version"; 21 NSString *KSRegistrationVersionKey = @"Version";
22 NSString *KSRegistrationUpdateCheckErrorKey = @"Error";
20 23
21 NSString *KSRegistrationStartUpdateNotification = 24 NSString *KSRegistrationStartUpdateNotification =
22 @"KSRegistrationStartUpdateNotification"; 25 @"KSRegistrationStartUpdateNotification";
23 NSString *KSUpdateCheckSuccessfulKey = @"CheckSuccessful"; 26 NSString *KSUpdateCheckSuccessfulKey = @"CheckSuccessful";
24 NSString *KSUpdateCheckSuccessfullyInstalledKey = @"SuccessfullyInstalled"; 27 NSString *KSUpdateCheckSuccessfullyInstalledKey = @"SuccessfullyInstalled";
25 28
26 NSString *KSRegistrationRemoveExistingTag = @""; 29 NSString *KSRegistrationRemoveExistingTag = @"";
27 #define KSRegistrationPreserveExistingTag nil 30 #define KSRegistrationPreserveExistingTag nil
28 31
32 } // namespace
33
29 @interface KSRegistration : NSObject 34 @interface KSRegistration : NSObject
30 35
31 + (id)registrationWithProductID:(NSString*)productID; 36 + (id)registrationWithProductID:(NSString*)productID;
32 37
33 // Older API 38 // Older API
34 - (BOOL)registerWithVersion:(NSString*)version 39 - (BOOL)registerWithVersion:(NSString*)version
35 existenceCheckerType:(KSExistenceCheckerType)xctype 40 existenceCheckerType:(KSExistenceCheckerType)xctype
36 existenceCheckerString:(NSString*)xc 41 existenceCheckerString:(NSString*)xc
37 serverURLString:(NSString*)serverURLString; 42 serverURLString:(NSString*)serverURLString;
38 // Newer API 43 // Newer API
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 [self updateStatus:kAutoupdateChecking version:nil]; 251 [self updateStatus:kAutoupdateChecking version:nil];
247 252
248 [registration_ checkForUpdate]; 253 [registration_ checkForUpdate];
249 254
250 // Upon completion, KSRegistrationCheckForUpdateNotification will be posted, 255 // Upon completion, KSRegistrationCheckForUpdateNotification will be posted,
251 // and -checkForUpdateComplete: will be called. 256 // and -checkForUpdateComplete: will be called.
252 } 257 }
253 258
254 - (void)checkForUpdateComplete:(NSNotification*)notification { 259 - (void)checkForUpdateComplete:(NSNotification*)notification {
255 NSDictionary* userInfo = [notification userInfo]; 260 NSDictionary* userInfo = [notification userInfo];
256 BOOL updatesAvailable =
257 [[userInfo objectForKey:KSRegistrationStatusKey] boolValue];
258 261
259 if (updatesAvailable) { 262 if ([[userInfo objectForKey:KSRegistrationUpdateCheckErrorKey] boolValue]) {
263 [self updateStatus:kAutoupdateCheckFailed version:nil];
264 } else if ([[userInfo objectForKey:KSRegistrationStatusKey] boolValue]) {
260 // If an update is known to be available, go straight to 265 // If an update is known to be available, go straight to
261 // -updateStatus:version:. It doesn't matter what's currently on disk. 266 // -updateStatus:version:. It doesn't matter what's currently on disk.
262 NSString* version = [userInfo objectForKey:KSRegistrationVersionKey]; 267 NSString* version = [userInfo objectForKey:KSRegistrationVersionKey];
263 [self updateStatus:kAutoupdateAvailable version:version]; 268 [self updateStatus:kAutoupdateAvailable version:version];
264 } else { 269 } else {
265 // If no updates are available, check what's on disk, because an update 270 // If no updates are available, check what's on disk, because an update
266 // may have already been installed. This check happens on another thread, 271 // may have already been installed. This check happens on another thread,
267 // and -updateStatus:version: will be called on the main thread when done. 272 // and -updateStatus:version: will be called on the main thread when done.
268 [self determineUpdateStatusAsync]; 273 [self determineUpdateStatusAsync];
269 } 274 }
(...skipping 10 matching lines...) Expand all
280 [self updateStatus:kAutoupdateInstalling version:nil]; 285 [self updateStatus:kAutoupdateInstalling version:nil];
281 286
282 [registration_ startUpdate]; 287 [registration_ startUpdate];
283 288
284 // Upon completion, KSRegistrationStartUpdateNotification will be posted, 289 // Upon completion, KSRegistrationStartUpdateNotification will be posted,
285 // and -installUpdateComplete: will be called. 290 // and -installUpdateComplete: will be called.
286 } 291 }
287 292
288 - (void)installUpdateComplete:(NSNotification*)notification { 293 - (void)installUpdateComplete:(NSNotification*)notification {
289 NSDictionary* userInfo = [notification userInfo]; 294 NSDictionary* userInfo = [notification userInfo];
290 BOOL checkSuccessful =
291 [[userInfo objectForKey:KSUpdateCheckSuccessfulKey] boolValue];
292 int installs =
293 [[userInfo objectForKey:KSUpdateCheckSuccessfullyInstalledKey] intValue];
294 295
295 if (!checkSuccessful || !installs) { 296 if (![[userInfo objectForKey:KSUpdateCheckSuccessfulKey] boolValue] ||
297 ![[userInfo objectForKey:KSUpdateCheckSuccessfullyInstalledKey]
298 intValue]) {
296 [self updateStatus:kAutoupdateInstallFailed version:nil]; 299 [self updateStatus:kAutoupdateInstallFailed version:nil];
297 } else { 300 } else {
298 updateSuccessfullyInstalled_ = YES; 301 updateSuccessfullyInstalled_ = YES;
299 302
300 // Nothing in the notification dictionary reports the version that was 303 // Nothing in the notification dictionary reports the version that was
301 // installed. Figure it out based on what's on disk. 304 // installed. Figure it out based on what's on disk.
302 [self determineUpdateStatusAsync]; 305 [self determineUpdateStatusAsync];
303 } 306 }
304 } 307 }
305 308
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 return static_cast<AutoupdateStatus>( 398 return static_cast<AutoupdateStatus>(
396 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]); 399 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]);
397 } 400 }
398 401
399 - (BOOL)asyncOperationPending { 402 - (BOOL)asyncOperationPending {
400 AutoupdateStatus status = [self recentStatus]; 403 AutoupdateStatus status = [self recentStatus];
401 return status == kAutoupdateChecking || status == kAutoupdateInstalling; 404 return status == kAutoupdateChecking || status == kAutoupdateInstalling;
402 } 405 }
403 406
404 @end // @implementation KeystoneGlue 407 @end // @implementation KeystoneGlue
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/about_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698