diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-11 22:00:14 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-11 22:00:14 +0000 |
commit | fd23eec1a1887f02bacf1d8a045a2804b6166089 (patch) | |
tree | c724a0cdc1a82ee5c9b987e592e530738956ce42 /chrome/browser/cocoa | |
parent | 8d0a2d717c070cf766c2664883cac91c510ff4fa (diff) | |
download | chromium_src-fd23eec1a1887f02bacf1d8a045a2804b6166089.zip chromium_src-fd23eec1a1887f02bacf1d8a045a2804b6166089.tar.gz chromium_src-fd23eec1a1887f02bacf1d8a045a2804b6166089.tar.bz2 |
[Mac] Remove some unneeded code to run Tasks in Cocoa run loops.
BUG=none
TEST=Click to open Wrench menu. Click the +/- buttons. Page zooms and percentage updates.
Review URL: http://codereview.chromium.org/6488016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74680 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/task_helpers.h | 29 | ||||
-rw-r--r-- | chrome/browser/cocoa/task_helpers.mm | 57 |
2 files changed, 0 insertions, 86 deletions
diff --git a/chrome/browser/cocoa/task_helpers.h b/chrome/browser/cocoa/task_helpers.h deleted file mode 100644 index ecc40f3..0000000 --- a/chrome/browser/cocoa/task_helpers.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2010 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 CHROME_BROWSER_COCOA_TASK_HELPERS_H_ -#define CHROME_BROWSER_COCOA_TASK_HELPERS_H_ -#pragma once - -class Task; - -namespace tracked_objects { -class Location; -} // namespace tracked_objects - -namespace cocoa_utils { - -// This can be used in place of BrowserThread::PostTask(BrowserThread::UI, ...). -// The purpose of this function is to be able to execute Task work alongside -// native work when a MessageLoop is blocked by a nested run loop. This function -// will run the Task in both NSEventTrackingRunLoopMode and NSDefaultRunLoopMode -// for the purpose of executing work while a menu is open. See -// http://crbug.com/48679 for the full rationale. -bool PostTaskInEventTrackingRunLoopMode( - const tracked_objects::Location& from_here, - Task* task); - -} // namespace cocoa_utils - -#endif // CHROME_BROWSER_COCOA_TASK_HELPERS_H_ diff --git a/chrome/browser/cocoa/task_helpers.mm b/chrome/browser/cocoa/task_helpers.mm deleted file mode 100644 index 7cc458b..0000000 --- a/chrome/browser/cocoa/task_helpers.mm +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2010 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. - -#include "chrome/browser/cocoa/task_helpers.h" - -#import <Cocoa/Cocoa.h> - -#include "base/scoped_ptr.h" -#include "base/task.h" - -// This is a wrapper for running Task objects from within a native run loop. -// This can run specific tasks in that nested loop. This owns the task and will -// delete it and itself when done. -@interface NativeTaskRunner : NSObject { - @private - scoped_ptr<Task> task_; -} -- (id)initWithTask:(Task*)task; -- (void)runTask; -@end - -@implementation NativeTaskRunner -- (id)initWithTask:(Task*)task { - if ((self = [super init])) { - task_.reset(task); - } - return self; -} - -- (void)runTask { - task_->Run(); - [self autorelease]; -} -@end - -namespace cocoa_utils { - -bool PostTaskInEventTrackingRunLoopMode( - const tracked_objects::Location& from_here, - Task* task) { - // This deletes itself and the task after the task runs. - NativeTaskRunner* runner = [[NativeTaskRunner alloc] initWithTask:task]; - - // Schedule the selector in multiple modes in case this was called while a - // menu was not running. - NSArray* modes = [NSArray arrayWithObjects:NSEventTrackingRunLoopMode, - NSDefaultRunLoopMode, - nil]; - [runner performSelectorOnMainThread:@selector(runTask) - withObject:nil - waitUntilDone:NO - modes:modes]; - return true; -} - -} // namespace cocoa_utils |