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/worker_pool_mac.mm | |
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/worker_pool_mac.mm')
-rw-r--r-- | base/worker_pool_mac.mm | 45 |
1 files changed, 32 insertions, 13 deletions
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; |