Chromium Code Reviews| Index: base/timer/timer.h |
| diff --git a/base/timer/timer.h b/base/timer/timer.h |
| index 6d282ee8e7ac84f3d6f5757650c08be70463f9e6..c9e9050e1f51416702f74e992b626cee0c32cda2 100644 |
| --- a/base/timer/timer.h |
| +++ b/base/timer/timer.h |
| @@ -55,6 +55,7 @@ |
| #include "base/bind_helpers.h" |
| #include "base/callback.h" |
| #include "base/location.h" |
| +#include "base/single_thread_task_runner.h" |
| #include "base/time/time.h" |
| namespace base { |
| @@ -87,6 +88,9 @@ class BASE_EXPORT Timer { |
| // Returns the current delay for this timer. |
| virtual TimeDelta GetCurrentDelay() const; |
| + // Set the task runner on which the task should be scheduled. |
|
Sami
2014/10/13 17:00:11
Please mention that this can only be changed befor
petrcermak
2014/10/13 17:21:40
Done.
|
| + virtual void SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner); |
| + |
| // Start the timer to run at the given |delay| from now. If the timer is |
| // already running, it will be replaced to call the given |user_task|. |
| virtual void Start(const tracked_objects::Location& posted_from, |
| @@ -122,6 +126,11 @@ class BASE_EXPORT Timer { |
| // and desired_run_time_ are reset to Now() + delay. |
| void PostNewScheduledTask(TimeDelta delay); |
| + // Returns the task runner on which the task should be scheduled. If the |
| + // corresponding task_runner_ field is NULL, the task runner for the current |
| + // thread is returned. |
| + scoped_refptr<SingleThreadTaskRunner> ResolveTaskRunner() const; |
| + |
| // Disable scheduled_task_ and abandon it so that it no longer refers back to |
| // this object. |
| void AbandonScheduledTask(); |
| @@ -139,6 +148,10 @@ class BASE_EXPORT Timer { |
| // RunScheduledTask() at scheduled_run_time_. |
| BaseTimerTaskInternal* scheduled_task_; |
| + // The task runner on which the task should be scheduled. If null, the |
| + // task runner for the current thread should be used. |
| + scoped_refptr<SingleThreadTaskRunner> task_runner_; |
|
Sami
2014/10/13 17:00:10
Could we initialize this to be ThreadTaskRunnerHan
petrcermak
2014/10/13 17:21:40
As discussed, this cannot be done in the construct
|
| + |
| // Location in user code. |
| tracked_objects::Location posted_from_; |
| // Delay requested by user. |