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

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

Issue 339010: Make the About box display existing pending operations instead of firing off a new update check (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 | « chrome/app/keystone_glue.h ('k') | 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"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 - (void)stopTimer { 234 - (void)stopTimer {
235 [timer_ invalidate]; 235 [timer_ invalidate];
236 } 236 }
237 237
238 - (void)markActive:(NSTimer*)timer { 238 - (void)markActive:(NSTimer*)timer {
239 KSRegistration* ksr = [timer userInfo]; 239 KSRegistration* ksr = [timer userInfo];
240 [ksr setActive]; 240 [ksr setActive];
241 } 241 }
242 242
243 - (void)checkForUpdate { 243 - (void)checkForUpdate {
244 DCHECK(![self asyncOperationPending]);
245
244 if (!registration_) { 246 if (!registration_) {
245 [self updateStatus:kAutoupdateCheckFailed version:nil]; 247 [self updateStatus:kAutoupdateCheckFailed version:nil];
246 return; 248 return;
247 } 249 }
248 250
251 [self updateStatus:kAutoupdateChecking version:nil];
252
249 [registration_ checkForUpdate]; 253 [registration_ checkForUpdate];
250 254
251 // Upon completion, KSRegistrationCheckForUpdateNotification will be posted, 255 // Upon completion, KSRegistrationCheckForUpdateNotification will be posted,
252 // and -checkForUpdateComplete: will be called. 256 // and -checkForUpdateComplete: will be called.
253 } 257 }
254 258
255 - (void)checkForUpdateComplete:(NSNotification*)notification { 259 - (void)checkForUpdateComplete:(NSNotification*)notification {
256 NSDictionary* userInfo = [notification userInfo]; 260 NSDictionary* userInfo = [notification userInfo];
257 BOOL updatesAvailable = 261 BOOL updatesAvailable =
258 [[userInfo objectForKey:KSRegistrationStatusKey] boolValue]; 262 [[userInfo objectForKey:KSRegistrationStatusKey] boolValue];
259 263
260 if (updatesAvailable) { 264 if (updatesAvailable) {
261 // If an update is known to be available, go straight to 265 // If an update is known to be available, go straight to
262 // -updateStatus:version:. It doesn't matter what's currently on disk. 266 // -updateStatus:version:. It doesn't matter what's currently on disk.
263 NSString* version = [userInfo objectForKey:KSRegistrationVersionKey]; 267 NSString* version = [userInfo objectForKey:KSRegistrationVersionKey];
264 [self updateStatus:kAutoupdateAvailable version:version]; 268 [self updateStatus:kAutoupdateAvailable version:version];
265 } else { 269 } else {
266 // 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
267 // may have already been installed. This check happens on another thread, 271 // may have already been installed. This check happens on another thread,
268 // 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.
269 [self determineUpdateStatusAsync]; 273 [self determineUpdateStatusAsync];
270 } 274 }
271 } 275 }
272 276
273 - (void)installUpdate { 277 - (void)installUpdate {
278 DCHECK(![self asyncOperationPending]);
279
274 if (!registration_) { 280 if (!registration_) {
275 [self updateStatus:kAutoupdateInstallFailed version:nil]; 281 [self updateStatus:kAutoupdateInstallFailed version:nil];
276 return; 282 return;
277 } 283 }
278 284
285 [self updateStatus:kAutoupdateInstalling version:nil];
286
279 [registration_ startUpdate]; 287 [registration_ startUpdate];
280 288
281 // Upon completion, KSRegistrationStartUpdateNotification will be posted, 289 // Upon completion, KSRegistrationStartUpdateNotification will be posted,
282 // and -installUpdateComplete: will be called. 290 // and -installUpdateComplete: will be called.
283 } 291 }
284 292
285 - (void)installUpdateComplete:(NSNotification*)notification { 293 - (void)installUpdateComplete:(NSNotification*)notification {
286 NSDictionary* userInfo = [notification userInfo]; 294 NSDictionary* userInfo = [notification userInfo];
287 BOOL checkSuccessful = 295 BOOL checkSuccessful =
288 [[userInfo objectForKey:KSUpdateCheckSuccessfulKey] boolValue]; 296 [[userInfo objectForKey:KSUpdateCheckSuccessfulKey] boolValue];
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 392 }
385 393
386 - (NSNotification*)recentNotification { 394 - (NSNotification*)recentNotification {
387 return [[recentNotification_ retain] autorelease]; 395 return [[recentNotification_ retain] autorelease];
388 } 396 }
389 397
390 - (void)clearRecentNotification { 398 - (void)clearRecentNotification {
391 recentNotification_.reset(nil); 399 recentNotification_.reset(nil);
392 } 400 }
393 401
402 - (AutoupdateStatus)recentStatus {
403 NSDictionary* dictionary = [recentNotification_ userInfo];
404 return static_cast<AutoupdateStatus>(
405 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]);
406 }
407
408 - (BOOL)asyncOperationPending {
409 AutoupdateStatus status = [self recentStatus];
410 return status == kAutoupdateChecking || status == kAutoupdateInstalling;
411 }
412
394 @end // @implementation KeystoneGlue 413 @end // @implementation KeystoneGlue
OLDNEW
« no previous file with comments | « chrome/app/keystone_glue.h ('k') | chrome/browser/cocoa/about_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698