summaryrefslogtreecommitdiffstats
path: root/chrome/app
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/app')
-rw-r--r--chrome/app/keystone_glue.h18
-rw-r--r--chrome/app/keystone_glue.mm19
2 files changed, 34 insertions, 3 deletions
diff --git a/chrome/app/keystone_glue.h b/chrome/app/keystone_glue.h
index f8d2a53..604e4e2 100644
--- a/chrome/app/keystone_glue.h
+++ b/chrome/app/keystone_glue.h
@@ -11,10 +11,14 @@
// Possible outcomes of -checkForUpdate and -installUpdate. A version may
// accompany some of these, but beware: a version is never required. For
// statuses that can be accompanied by a version, the comment indicates what
-// version is referenced.
+// version is referenced. A notification posted containing an asynchronous
+// status will always be followed by a notification with a terminal status.
enum AutoupdateStatus {
- kAutoupdateCurrent = 0, // version of the running application
+ kAutoupdateNone = 0, // no version (initial state only)
+ kAutoupdateChecking, // no version (asynchronous operation in progress)
+ kAutoupdateCurrent, // version of the running application
kAutoupdateAvailable, // version of the update that is available
+ kAutoupdateInstalling, // no version (asynchronous operation in progress)
kAutoupdateInstalled, // version of the update that was installed
kAutoupdateCheckFailed, // no version
kAutoupdateInstallFailed // no version
@@ -75,7 +79,7 @@ extern const NSString* const kAutoupdateStatusVersion;
// -checkForUpdate launches a check for updates, and -installUpdate begins
// installing an available update. For each, status will be communicated via
// a kAutoupdateStatusNotification notification, and will also be available
-// through -recentUpdateStatus.
+// through -recentNotification.
- (void)checkForUpdate;
- (void)installUpdate;
@@ -85,6 +89,14 @@ extern const NSString* const kAutoupdateStatusVersion;
// Clears the saved recentNotification_.
- (void)clearRecentNotification;
+// Accessor for the kAutoupdateStatusStatus field of recentNotification_'s
+// userInfo dictionary.
+- (AutoupdateStatus)recentStatus;
+
+// Returns YES if an asynchronous operation is pending: if an update check or
+// installation attempt is currently in progress.
+- (BOOL)asyncOperationPending;
+
@end // @interface KeystoneGlue
@interface KeystoneGlue(ExposedForTesting)
diff --git a/chrome/app/keystone_glue.mm b/chrome/app/keystone_glue.mm
index 689cfdb..6a91b9c 100644
--- a/chrome/app/keystone_glue.mm
+++ b/chrome/app/keystone_glue.mm
@@ -241,11 +241,15 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked
}
- (void)checkForUpdate {
+ DCHECK(![self asyncOperationPending]);
+
if (!registration_) {
[self updateStatus:kAutoupdateCheckFailed version:nil];
return;
}
+ [self updateStatus:kAutoupdateChecking version:nil];
+
[registration_ checkForUpdate];
// Upon completion, KSRegistrationCheckForUpdateNotification will be posted,
@@ -271,11 +275,15 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked
}
- (void)installUpdate {
+ DCHECK(![self asyncOperationPending]);
+
if (!registration_) {
[self updateStatus:kAutoupdateInstallFailed version:nil];
return;
}
+ [self updateStatus:kAutoupdateInstalling version:nil];
+
[registration_ startUpdate];
// Upon completion, KSRegistrationStartUpdateNotification will be posted,
@@ -391,4 +399,15 @@ static KeystoneGlue* sDefaultKeystoneGlue = nil; // leaked
recentNotification_.reset(nil);
}
+- (AutoupdateStatus)recentStatus {
+ NSDictionary* dictionary = [recentNotification_ userInfo];
+ return static_cast<AutoupdateStatus>(
+ [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]);
+}
+
+- (BOOL)asyncOperationPending {
+ AutoupdateStatus status = [self recentStatus];
+ return status == kAutoupdateChecking || status == kAutoupdateInstalling;
+}
+
@end // @implementation KeystoneGlue