diff options
author | tedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-26 08:17:37 +0000 |
---|---|---|
committer | tedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-26 08:17:37 +0000 |
commit | 17dc674a9c9be676ebe13014d4e2c406e0c0c1ad (patch) | |
tree | a860c9c606eb2698f5e7af9479c704ad69e25a4a /base | |
parent | b703d26d2ed97aa5c59fa70fd78821e1fe78dbf1 (diff) | |
download | chromium_src-17dc674a9c9be676ebe13014d4e2c406e0c0c1ad.zip chromium_src-17dc674a9c9be676ebe13014d4e2c406e0c0c1ad.tar.gz chromium_src-17dc674a9c9be676ebe13014d4e2c406e0c0c1ad.tar.bz2 |
Add functions to expand PostDelayedTask interface.
These functions add TimeDelta interfaces in addition to the int ms interfaces,
which will be removed at a later date.
BUG=108171
Review URL: http://codereview.chromium.org/9427023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/message_loop_proxy_impl.cc | 25 | ||||
-rw-r--r-- | base/message_loop_proxy_impl.h | 9 | ||||
-rw-r--r-- | base/sequenced_task_runner.h | 5 | ||||
-rw-r--r-- | base/task_runner.h | 6 |
4 files changed, 39 insertions, 6 deletions
diff --git a/base/message_loop_proxy_impl.cc b/base/message_loop_proxy_impl.cc index eeeb1db..9f6cb1f 100644 --- a/base/message_loop_proxy_impl.cc +++ b/base/message_loop_proxy_impl.cc @@ -12,18 +12,36 @@ namespace base { MessageLoopProxyImpl::~MessageLoopProxyImpl() { } +// This function will be removed later in the fixing of CR Bug #108171. bool MessageLoopProxyImpl::PostDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) { - return PostTaskHelper(from_here, task, delay_ms, true); + return PostDelayedTask( + from_here, task, base::TimeDelta::FromMilliseconds(delay_ms)); } +// This function will be removed later in the fixing of CR Bug #108171. bool MessageLoopProxyImpl::PostNonNestableDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) { - return PostTaskHelper(from_here, task, delay_ms, false); + return PostNonNestableDelayedTask( + from_here, task, base::TimeDelta::FromMilliseconds(delay_ms)); +} + +bool MessageLoopProxyImpl::PostDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) { + return PostTaskHelper(from_here, task, delay, true); +} + +bool MessageLoopProxyImpl::PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) { + return PostTaskHelper(from_here, task, delay, false); } bool MessageLoopProxyImpl::RunsTasksOnCurrentThread() const { @@ -68,10 +86,9 @@ MessageLoopProxyImpl::MessageLoopProxyImpl() bool MessageLoopProxyImpl::PostTaskHelper( const tracked_objects::Location& from_here, const base::Closure& task, - int64 delay_ms, bool nestable) { + base::TimeDelta delay, bool nestable) { AutoLock lock(message_loop_lock_); if (target_message_loop_) { - base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); if (nestable) { target_message_loop_->PostDelayedTask(from_here, task, delay); } else { diff --git a/base/message_loop_proxy_impl.h b/base/message_loop_proxy_impl.h index 847ee4c..88e1d45 100644 --- a/base/message_loop_proxy_impl.h +++ b/base/message_loop_proxy_impl.h @@ -25,10 +25,17 @@ class BASE_EXPORT MessageLoopProxyImpl virtual bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) OVERRIDE; + virtual bool PostDelayedTask(const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) OVERRIDE; virtual bool PostNonNestableDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) OVERRIDE; + virtual bool PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) OVERRIDE; virtual bool RunsTasksOnCurrentThread() const OVERRIDE; protected: @@ -45,7 +52,7 @@ class BASE_EXPORT MessageLoopProxyImpl bool PostTaskHelper(const tracked_objects::Location& from_here, const base::Closure& task, - int64 delay_ms, + base::TimeDelta delay, bool nestable); // Allow the messageLoop to create a MessageLoopProxyImpl. diff --git a/base/sequenced_task_runner.h b/base/sequenced_task_runner.h index a280522..f44b622 100644 --- a/base/sequenced_task_runner.h +++ b/base/sequenced_task_runner.h @@ -116,6 +116,11 @@ class BASE_EXPORT SequencedTaskRunner : public TaskRunner { const Closure& task, int64 delay_ms) = 0; + virtual bool PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const Closure& task, + base::TimeDelta delay) = 0; + // Submits a non-nestable task to delete the given object. Returns // true if the object may be deleted at some point in the future, // and false if the object definitely will not be deleted. diff --git a/base/task_runner.h b/base/task_runner.h index 7527031..894eb87 100644 --- a/base/task_runner.h +++ b/base/task_runner.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/callback_forward.h" #include "base/memory/ref_counted.h" +#include "base/time.h" namespace tracked_objects { class Location; @@ -72,10 +73,13 @@ class BASE_EXPORT TaskRunner // It is valid for an implementation to ignore |delay_ms|; that is, // to have PostDelayedTask behave the same as PostTask. // - // TODO(akalin): Make PostDelayedTask use TimeDelta instead. + // TODO(tedv): Make PostDelayedTask use TimeDelta instead. virtual bool PostDelayedTask(const tracked_objects::Location& from_here, const Closure& task, int64 delay_ms) = 0; + virtual bool PostDelayedTask(const tracked_objects::Location& from_here, + const Closure& task, + base::TimeDelta delay) = 0; // Returns true if the current thread is a thread on which a task // may be run, and false if no task will be run on the current |