diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 19:58:13 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 19:58:13 +0000 |
commit | 49aeee5080135d65173fb06f117cbb19f87ae867 (patch) | |
tree | 13ea17786c1cd4c59c833906f3d26ef92a50b091 /base | |
parent | 8dd8ea73b9fc2571777d841a85f0b27f82530455 (diff) | |
download | chromium_src-49aeee5080135d65173fb06f117cbb19f87ae867.zip chromium_src-49aeee5080135d65173fb06f117cbb19f87ae867.tar.gz chromium_src-49aeee5080135d65173fb06f117cbb19f87ae867.tar.bz2 |
About box auto-update improvements.
The About box now knows how to check to see if updates have been installed
in the background without anyone having to click the Update button in the box.
The About box no longer gets stuck in the "installed" state. Even if an
update has been installed, the About box will still check for new updates when
reopened.
BUG=13165, 20488
TEST=Play with the about box and auto-update a whole lot
Review URL: http://codereview.chromium.org/338012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30078 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gyp | 1 | ||||
-rw-r--r-- | base/worker_pool_mac.h | 26 | ||||
-rw-r--r-- | base/worker_pool_mac.mm | 45 |
3 files changed, 59 insertions, 13 deletions
diff --git a/base/base.gyp b/base/base.gyp index 6f6790c..d948e84 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -349,6 +349,7 @@ 'worker_pool.h', 'worker_pool_linux.cc', 'worker_pool_linux.h', + 'worker_pool_mac.h', 'worker_pool_mac.mm', 'worker_pool_win.cc', ], diff --git a/base/worker_pool_mac.h b/base/worker_pool_mac.h new file mode 100644 index 0000000..7c67e45 --- /dev/null +++ b/base/worker_pool_mac.h @@ -0,0 +1,26 @@ +// Copyright (c) 2009 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. + +#ifndef BASE_WORKER_POOL_MAC_H_ +#define BASE_WORKER_POOL_MAC_H_ + +#include "base/worker_pool.h" + +#import <Foundation/Foundation.h> + +// WorkerPoolObjC provides an Objective-C interface to the same WorkerPool +// used by the rest of the application. +@interface WorkerPoolObjC : NSObject + +// Returns the underlying NSOperationQueue back end that WorkerPool::PostTask +// would post tasks to. This can be used to add NSOperation subclasses +// directly to the same NSOperationQueue, by calling -[NSOperationQueue +// addOperation:]. Most Objective-C code wishing to dispatch tasks to the +// WorkerPool will find it handy to add an operation of type +// NSInvocationOperation. ++ (NSOperationQueue*)sharedOperationQueue; + +@end // @interface WorkerPoolObjC + +#endif // BASE_WORKER_POOL_MAC_H_ diff --git a/base/worker_pool_mac.mm b/base/worker_pool_mac.mm index 1147110..162509c 100644 --- a/base/worker_pool_mac.mm +++ b/base/worker_pool_mac.mm @@ -2,18 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/worker_pool.h" - -#import <Foundation/Foundation.h> +#include "base/worker_pool_mac.h" #include "base/logging.h" +#import "base/scoped_nsautorelease_pool.h" +#include "base/scoped_ptr.h" #import "base/singleton_objc.h" #include "base/task.h" +@implementation WorkerPoolObjC + ++ (NSOperationQueue*)sharedOperationQueue { + return SingletonObjC<NSOperationQueue>::get(); +} + +@end // @implementation WorkerPoolObjC + // TaskOperation adapts Task->Run() for use in an NSOperationQueue. @interface TaskOperation : NSOperation { @private - Task* task_; // (strong) + scoped_ptr<Task> task_; } // Returns an autoreleased instance of TaskOperation. See -initWithTask: for @@ -24,7 +32,7 @@ // this operation will call when executed. - (id)initWithTask:(Task*)task; -@end +@end // @interface TaskOperation @implementation TaskOperation @@ -38,34 +46,45 @@ - (id)initWithTask:(Task*)task { if ((self = [super init])) { - task_ = task; + task_.reset(task); } return self; } - (void)main { - DCHECK(task_) << "-[TaskOperation main] called with no task"; + DCHECK(task_.get()) << "-[TaskOperation main] called with no task"; + if (!task_.get()) { + return; + } + + base::ScopedNSAutoreleasePool autoreleasePool; + task_->Run(); - delete task_; - task_ = NULL; + task_.reset(NULL); } - (void)dealloc { - DCHECK(!task_) << "-[TaskOperation dealloc] called on unused TaskOperation"; - delete task_; + DCHECK(!task_.get()) + << "-[TaskOperation dealloc] called without running task"; + [super dealloc]; } -@end +@end // @implementation TaskOperation bool WorkerPool::PostTask(const tracked_objects::Location& from_here, Task* task, bool task_is_slow) { // Ignore |task_is_slow|, it doesn't map directly to any tunable aspect of // an NSOperation. + DCHECK(task) << "WorkerPool::PostTask called with no task"; + if (!task) { + return false; + } + task->SetBirthPlace(from_here); - NSOperationQueue* operation_queue = SingletonObjC<NSOperationQueue>::get(); + NSOperationQueue* operation_queue = [WorkerPoolObjC sharedOperationQueue]; [operation_queue addOperation:[TaskOperation taskOperationWithTask:task]]; return true; |