Commit 6e42784f authored by tzik's avatar tzik Committed by Commit bot

Migrate base::TaskRunner from Closure to OnceClosure

After this CL, TaskRunner::PostTask and its family can take OnceClosure
in addition to Closure.

Most of the changes are mechanical replacement of Closure with OnceClosure
on TaskRunner family. Others are:
 - Limit CriticalClosure from Closure to OnceClosure as no caller call
   the resulting callback more than once
 - Add several PostTaskAndReplyWithResult overloads for old Callback
   version, for compatibility. (in base/task_scheduler/post_task.h)
 - Update SequencedWorkerPool implementation for OnceClosure.
 - Update task handling code in app_state.mm for OnceClosure, which is
   needed to bring OnceClosure into a ObjC block.

BUG=704027
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2637843002
Cr-Commit-Position: refs/heads/master@{#462023}
parent 317a8e0e
......@@ -29,13 +29,13 @@ bool IsMultiTaskingSupported();
// |ios::ScopedCriticalAction|.
class CriticalClosure {
public:
explicit CriticalClosure(Closure closure);
explicit CriticalClosure(OnceClosure closure);
~CriticalClosure();
void Run();
private:
ios::ScopedCriticalAction critical_action_;
Closure closure_;
OnceClosure closure_;
DISALLOW_COPY_AND_ASSIGN(CriticalClosure);
};
......@@ -57,13 +57,14 @@ class CriticalClosure {
// background running time, |MakeCriticalClosure| should be applied on them
// before posting.
#if defined(OS_IOS)
inline Closure MakeCriticalClosure(Closure closure) {
inline OnceClosure MakeCriticalClosure(OnceClosure closure) {
DCHECK(internal::IsMultiTaskingSupported());
return base::Bind(&internal::CriticalClosure::Run,
Owned(new internal::CriticalClosure(std::move(closure))));
return base::BindOnce(
&internal::CriticalClosure::Run,
Owned(new internal::CriticalClosure(std::move(closure))));
}
#else // defined(OS_IOS)
inline Closure MakeCriticalClosure(Closure closure) {
inline OnceClosure MakeCriticalClosure(OnceClosure closure) {
// No-op for platforms where the application does not need to acquire
// background time for closures to finish when it goes into the background.
return closure;
......
......@@ -13,13 +13,13 @@ bool IsMultiTaskingSupported() {
return [[UIDevice currentDevice] isMultitaskingSupported];
}
CriticalClosure::CriticalClosure(Closure closure)
CriticalClosure::CriticalClosure(OnceClosure closure)
: closure_(std::move(closure)) {}
CriticalClosure::~CriticalClosure() {}
void CriticalClosure::Run() {
closure_.Run();
std::move(closure_).Run();
}
} // namespace internal
......
......@@ -34,7 +34,7 @@ DeferredSequencedTaskRunner::~DeferredSequencedTaskRunner() {
bool DeferredSequencedTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay) {
AutoLock lock(lock_);
if (started_) {
......@@ -54,7 +54,7 @@ bool DeferredSequencedTaskRunner::RunsTasksOnCurrentThread() const {
bool DeferredSequencedTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay) {
AutoLock lock(lock_);
if (started_) {
......@@ -69,7 +69,7 @@ bool DeferredSequencedTaskRunner::PostNonNestableDelayedTask(
void DeferredSequencedTaskRunner::QueueDeferredTask(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay,
bool is_non_nestable) {
DCHECK(task);
......
......@@ -28,13 +28,13 @@ class BASE_EXPORT DeferredSequencedTaskRunner : public SequencedTaskRunner {
// TaskRunner implementation
bool PostDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
// SequencedTaskRunner implementation
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay) override;
// Start the execution - posts all queued tasks to the target executor. The
......@@ -51,7 +51,7 @@ class BASE_EXPORT DeferredSequencedTaskRunner : public SequencedTaskRunner {
DeferredTask& operator=(DeferredTask&& other);
tracked_objects::Location posted_from;
Closure task;
OnceClosure task;
// The delay this task was initially posted with.
TimeDelta delay;
bool is_non_nestable;
......@@ -61,7 +61,7 @@ class BASE_EXPORT DeferredSequencedTaskRunner : public SequencedTaskRunner {
// Creates a |Task| object and adds it to |deferred_tasks_queue_|.
void QueueDeferredTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay,
bool is_non_nestable);
......
......@@ -60,7 +60,7 @@ IncomingTaskQueue::IncomingTaskQueue(MessageLoop* message_loop)
bool IncomingTaskQueue::AddToIncomingQueue(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay,
bool nestable) {
DCHECK(task);
......
......@@ -36,7 +36,7 @@ class BASE_EXPORT IncomingTaskQueue
// returns false. In all cases, the ownership of |task| is transferred to the
// called method.
bool AddToIncomingQueue(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay,
bool nestable);
......
......@@ -26,7 +26,7 @@ void MessageLoopTaskRunner::BindToCurrentThread() {
bool MessageLoopTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
base::TimeDelta delay) {
DCHECK(!task.is_null()) << from_here.ToString();
return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay,
......@@ -35,7 +35,7 @@ bool MessageLoopTaskRunner::PostDelayedTask(
bool MessageLoopTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
base::TimeDelta delay) {
DCHECK(!task.is_null()) << from_here.ToString();
return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay,
......
......@@ -32,10 +32,10 @@ class BASE_EXPORT MessageLoopTaskRunner : public SingleThreadTaskRunner {
// SingleThreadTaskRunner implementation
bool PostDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
base::TimeDelta delay) override;
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
base::TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
......
......@@ -16,16 +16,15 @@ namespace internal {
// Adapts a function that produces a result via a return value to
// one that returns via an output parameter.
template <typename ReturnType>
void ReturnAsParamAdapter(const Callback<ReturnType(void)>& func,
ReturnType* result) {
*result = func.Run();
void ReturnAsParamAdapter(OnceCallback<ReturnType()> func, ReturnType* result) {
*result = std::move(func).Run();
}
// Adapts a T* result to a callblack that expects a T.
template <typename TaskReturnType, typename ReplyArgType>
void ReplyAdapter(const Callback<void(ReplyArgType)>& callback,
void ReplyAdapter(OnceCallback<void(ReplyArgType)> callback,
TaskReturnType* result) {
callback.Run(std::move(*result));
std::move(callback).Run(std::move(*result));
}
} // namespace internal
......
......@@ -12,7 +12,7 @@ namespace base {
bool SequencedTaskRunner::PostNonNestableTask(
const tracked_objects::Location& from_here,
Closure task) {
OnceClosure task) {
return PostNonNestableDelayedTask(from_here, std::move(task),
base::TimeDelta());
}
......
......@@ -110,11 +110,11 @@ class BASE_EXPORT SequencedTaskRunner : public TaskRunner {
// below.
bool PostNonNestableTask(const tracked_objects::Location& from_here,
Closure task);
OnceClosure task);
virtual bool PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
base::TimeDelta delay) = 0;
// Submits a non-nestable task to delete the given object. Returns
......
......@@ -23,7 +23,7 @@ class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl {
private:
bool PostTask(const tracked_objects::Location& from_here,
Closure task) override;
OnceClosure task) override;
// Non-owning.
TaskRunner* destination_;
......@@ -36,20 +36,20 @@ PostTaskAndReplyTaskRunner::PostTaskAndReplyTaskRunner(
bool PostTaskAndReplyTaskRunner::PostTask(
const tracked_objects::Location& from_here,
Closure task) {
OnceClosure task) {
return destination_->PostTask(from_here, std::move(task));
}
} // namespace
bool TaskRunner::PostTask(const tracked_objects::Location& from_here,
Closure task) {
OnceClosure task) {
return PostDelayedTask(from_here, std::move(task), base::TimeDelta());
}
bool TaskRunner::PostTaskAndReply(const tracked_objects::Location& from_here,
Closure task,
Closure reply) {
OnceClosure task,
OnceClosure reply) {
return PostTaskAndReplyTaskRunner(this).PostTaskAndReply(
from_here, std::move(task), std::move(reply));
}
......
......@@ -61,7 +61,7 @@ class BASE_EXPORT TaskRunner
// will not be run.
//
// Equivalent to PostDelayedTask(from_here, task, 0).
bool PostTask(const tracked_objects::Location& from_here, Closure task);
bool PostTask(const tracked_objects::Location& from_here, OnceClosure task);
// Like PostTask, but tries to run the posted task only after
// |delay_ms| has passed.
......@@ -69,7 +69,7 @@ class BASE_EXPORT TaskRunner
// It is valid for an implementation to ignore |delay_ms|; that is,
// to have PostDelayedTask behave the same as PostTask.
virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
base::TimeDelta delay) = 0;
// Returns true if the current thread is a thread on which a task
......@@ -122,8 +122,8 @@ class BASE_EXPORT TaskRunner
// and the reply will cancel itself safely because it is bound to a
// WeakPtr<>.
bool PostTaskAndReply(const tracked_objects::Location& from_here,
Closure task,
Closure reply);
OnceClosure task,
OnceClosure reply);
protected:
friend struct TaskRunnerTraits;
......
......@@ -21,7 +21,7 @@ class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl {
private:
bool PostTask(const tracked_objects::Location& from_here,
Closure task) override {
OnceClosure task) override {
PostTaskWithTraits(from_here, traits_, std::move(task));
return true;
}
......@@ -32,43 +32,43 @@ class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl {
} // namespace
void PostTask(const tracked_objects::Location& from_here, Closure task) {
void PostTask(const tracked_objects::Location& from_here, OnceClosure task) {
PostDelayedTask(from_here, std::move(task), TimeDelta());
}
void PostDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay) {
PostDelayedTaskWithTraits(from_here, TaskTraits(), std::move(task), delay);
}
void PostTaskAndReply(const tracked_objects::Location& from_here,
Closure task,
Closure reply) {
OnceClosure task,
OnceClosure reply) {
PostTaskWithTraitsAndReply(from_here, TaskTraits(), std::move(task),
std::move(reply));
}
void PostTaskWithTraits(const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task) {
OnceClosure task) {
PostDelayedTaskWithTraits(from_here, traits, std::move(task), TimeDelta());
}
void PostDelayedTaskWithTraits(const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task,
OnceClosure task,
TimeDelta delay) {
DCHECK(TaskScheduler::GetInstance())
<< "Ref. Prerequisite section of post_task.h";
TaskScheduler::GetInstance()->PostDelayedTaskWithTraits(
from_here, traits, std::move(task), delay);
from_here, traits, std::move(task), std::move(delay));
}
void PostTaskWithTraitsAndReply(const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task,
Closure reply) {
OnceClosure task,
OnceClosure reply) {
PostTaskAndReplyTaskRunner(traits).PostTaskAndReply(
from_here, std::move(task), std::move(reply));
}
......
......@@ -71,7 +71,7 @@ namespace base {
// Posts |task| to the TaskScheduler. Calling this is equivalent to calling
// PostTaskWithTraits with plain TaskTraits.
BASE_EXPORT void PostTask(const tracked_objects::Location& from_here,
Closure task);
OnceClosure task);
// Posts |task| to the TaskScheduler. |task| will not run before |delay|
// expires. Calling this is equivalent to calling PostDelayedTaskWithTraits with
......@@ -80,7 +80,7 @@ BASE_EXPORT void PostTask(const tracked_objects::Location& from_here,
// Use PostDelayedTaskWithTraits to specify a BACKGROUND priority if the task
// doesn't have to run as soon as |delay| expires.
BASE_EXPORT void PostDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay);
// Posts |task| to the TaskScheduler and posts |reply| on the caller's execution
......@@ -89,8 +89,8 @@ BASE_EXPORT void PostDelayedTask(const tracked_objects::Location& from_here,
// PostTaskWithTraitsAndReply with plain TaskTraits. Can only be called when
// SequencedTaskRunnerHandle::IsSet().
BASE_EXPORT void PostTaskAndReply(const tracked_objects::Location& from_here,
Closure task,
Closure reply);
OnceClosure task,
OnceClosure reply);
// Posts |task| to the TaskScheduler and posts |reply| with the return value of
// |task| as argument on the caller's execution context (i.e. same sequence or
......@@ -99,16 +99,30 @@ BASE_EXPORT void PostTaskAndReply(const tracked_objects::Location& from_here,
// TaskTraits. Can only be called when SequencedTaskRunnerHandle::IsSet().
template <typename TaskReturnType, typename ReplyArgType>
void PostTaskAndReplyWithResult(const tracked_objects::Location& from_here,
Callback<TaskReturnType(void)> task,
Callback<void(ReplyArgType)> reply) {
OnceCallback<TaskReturnType()> task,
OnceCallback<void(ReplyArgType)> reply) {
PostTaskWithTraitsAndReplyWithResult(from_here, TaskTraits(), std::move(task),
std::move(reply));
}
// Callback version of PostTaskAndReplyWithResult above.
// Though RepeatingCallback is convertible to OnceCallback, we need this since
// we can not use template deduction and object conversion at once on the
// overload resolution.
// TODO(tzik): Update all callers of the Callback version to use OnceCallback.
template <typename TaskReturnType, typename ReplyArgType>
void PostTaskAndReplyWithResult(const tracked_objects::Location& from_here,
Callback<TaskReturnType()> task,
Callback<void(ReplyArgType)> reply) {
PostTaskAndReplyWithResult(
from_here, OnceCallback<TaskReturnType()>(std::move(task)),
OnceCallback<void(ReplyArgType)>(std::move(reply)));
}
// Posts |task| with specific |traits| to the TaskScheduler.
BASE_EXPORT void PostTaskWithTraits(const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task);
OnceClosure task);
// Posts |task| with specific |traits| to the TaskScheduler. |task| will not run
// before |delay| expires.
......@@ -118,7 +132,7 @@ BASE_EXPORT void PostTaskWithTraits(const tracked_objects::Location& from_here,
BASE_EXPORT void PostDelayedTaskWithTraits(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task,
OnceClosure task,
TimeDelta delay);
// Posts |task| with specific |traits| to the TaskScheduler and posts |reply| on
......@@ -128,8 +142,8 @@ BASE_EXPORT void PostDelayedTaskWithTraits(
BASE_EXPORT void PostTaskWithTraitsAndReply(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task,
Closure reply);
OnceClosure task,
OnceClosure reply);
// Posts |task| with specific |traits| to the TaskScheduler and posts |reply|
// with the return value of |task| as argument on the caller's execution context
......@@ -139,14 +153,31 @@ template <typename TaskReturnType, typename ReplyArgType>
void PostTaskWithTraitsAndReplyWithResult(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
Callback<TaskReturnType()> task,
Callback<void(ReplyArgType)> reply) {
OnceCallback<TaskReturnType()> task,
OnceCallback<void(ReplyArgType)> reply) {
TaskReturnType* result = new TaskReturnType();
return PostTaskWithTraitsAndReply(
from_here, traits, Bind(&internal::ReturnAsParamAdapter<TaskReturnType>,
std::move(task), result),
Bind(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>,
std::move(reply), Owned(result)));
from_here, traits,
BindOnce(&internal::ReturnAsParamAdapter<TaskReturnType>, std::move(task),
result),
BindOnce(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>,
std::move(reply), Owned(result)));
}
// Callback version of PostTaskWithTraitsAndReplyWithResult above.
// Though RepeatingCallback is convertible to OnceCallback, we need this since
// we can not use template deduction and object conversion at once on the
// overload resolution.
// TODO(tzik): Update all callers of the Callback version to use OnceCallback.
template <typename TaskReturnType, typename ReplyArgType>
void PostTaskWithTraitsAndReplyWithResult(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
Callback<TaskReturnType()> task,
Callback<void(ReplyArgType)> reply) {
PostTaskWithTraitsAndReplyWithResult(
from_here, traits, OnceCallback<TaskReturnType()>(std::move(task)),
OnceCallback<void(ReplyArgType)>(std::move(reply)));
}
// Returns a TaskRunner whose PostTask invocations result in scheduling tasks
......
......@@ -253,7 +253,7 @@ class SchedulerSingleThreadTaskRunnerManager::SchedulerSingleThreadTaskRunner
// SingleThreadTaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
Closure closure,
OnceClosure closure,
TimeDelta delay) override {
auto task = MakeUnique<Task>(from_here, std::move(closure), traits_, delay);
task->single_thread_task_runner_ref = this;
......@@ -272,7 +272,7 @@ class SchedulerSingleThreadTaskRunnerManager::SchedulerSingleThreadTaskRunner
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
Closure closure,
OnceClosure closure,
TimeDelta delay) override {
// Tasks are never nested within the task scheduler.
return PostDelayedTask(from_here, std::move(closure), delay);
......
......@@ -58,7 +58,7 @@ class SchedulerParallelTaskRunner : public TaskRunner {
// TaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
Closure closure,
OnceClosure closure,
TimeDelta delay) override {
// Post the task as part of a one-off single-task Sequence.
return worker_pool_->PostTaskWithSequence(
......@@ -93,7 +93,7 @@ class SchedulerSequencedTaskRunner : public SequencedTaskRunner {
// SequencedTaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
Closure closure,
OnceClosure closure,
TimeDelta delay) override {
std::unique_ptr<Task> task(
new Task(from_here, std::move(closure), traits_, delay));
......@@ -104,7 +104,7 @@ class SchedulerSequencedTaskRunner : public SequencedTaskRunner {
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
Closure closure,
OnceClosure closure,
base::TimeDelta delay) override {
// Tasks are never nested within the task scheduler.
return PostDelayedTask(from_here, std::move(closure), delay);
......
......@@ -12,7 +12,7 @@ namespace base {
namespace internal {
Task::Task(const tracked_objects::Location& posted_from,
Closure task,
OnceClosure task,
const TaskTraits& traits,
TimeDelta delay)
: PendingTask(
......
......@@ -28,7 +28,7 @@ struct BASE_EXPORT Task : public PendingTask {
// behavior in |traits| is BLOCK_SHUTDOWN, the shutdown behavior is
// automatically adjusted to SKIP_ON_SHUTDOWN.
Task(const tracked_objects::Location& posted_from,
Closure task,
OnceClosure task,
const TaskTraits& traits,
TimeDelta delay);
~Task();
......
......@@ -70,7 +70,7 @@ class BASE_EXPORT TaskScheduler {
virtual void PostDelayedTaskWithTraits(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task,
OnceClosure task,
TimeDelta delay) = 0;
// Returns a TaskRunner whose PostTask invocations result in scheduling tasks
......
......@@ -122,7 +122,7 @@ TaskSchedulerImpl::~TaskSchedulerImpl() {
void TaskSchedulerImpl::PostDelayedTaskWithTraits(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task,
OnceClosure task,
TimeDelta delay) {
// Post |task| as part of a one-off single-task Sequence.
GetWorkerPoolForTraits(traits)->PostTaskWithSequence(
......
......@@ -62,7 +62,7 @@ class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler {
// TaskScheduler:
void PostDelayedTaskWithTraits(const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task,
OnceClosure task,
TimeDelta delay) override;
scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
const TaskTraits& traits) override;
......
......@@ -11,14 +11,14 @@ NullTaskRunner::NullTaskRunner() {}
NullTaskRunner::~NullTaskRunner() {}
bool NullTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
base::TimeDelta delay) {
return false;
}
bool NullTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
base::TimeDelta delay) {
return false;
}
......
......@@ -20,10 +20,10 @@ class NullTaskRunner : public base::SingleThreadTaskRunner {
NullTaskRunner();
bool PostDelayedTask(const tracked_objects::Location& from_here,
base::Closure task,
base::OnceClosure task,
base::TimeDelta delay) override;
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
base::Closure task,
base::OnceClosure task,
base::TimeDelta delay) override;
// Always returns true to avoid triggering DCHECKs.
bool RunsTasksOnCurrentThread() const override;
......
......@@ -49,7 +49,7 @@ class TestTaskScheduler : public TaskScheduler {
// TaskScheduler:
void PostDelayedTaskWithTraits(const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task,
OnceClosure task,
TimeDelta delay) override;
scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
const TaskTraits& traits) override;
......@@ -134,10 +134,10 @@ class TestTaskSchedulerTaskRunner : public SingleThreadTaskRunner {
// SingleThreadTaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
Closure closure,
OnceClosure closure,
TimeDelta delay) override;
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
Closure closure,
OnceClosure closure,
TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
......@@ -167,7 +167,7 @@ TestTaskScheduler::~TestTaskScheduler() {
void TestTaskScheduler::PostDelayedTaskWithTraits(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
Closure task,
OnceClosure task,
TimeDelta delay) {
CreateTaskRunnerWithTraits(traits)->PostDelayedTask(from_here,
std::move(task), delay);
......@@ -280,7 +280,7 @@ TestTaskSchedulerTaskRunner::TestTaskSchedulerTaskRunner(
bool TestTaskSchedulerTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
Closure closure,
OnceClosure closure,
TimeDelta delay) {
auto task =
MakeUnique<internal::Task>(from_here, std::move(closure), traits_, delay);
......@@ -293,7 +293,7 @@ bool TestTaskSchedulerTaskRunner::PostDelayedTask(
bool TestTaskSchedulerTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
Closure closure,
OnceClosure closure,
TimeDelta delay) {
// Tasks are never nested within the task scheduler.
return PostDelayedTask(from_here, std::move(closure), delay);
......
......@@ -81,7 +81,7 @@ struct TestMockTimeTaskRunner::TestOrderedPendingTask
: public base::TestPendingTask {
TestOrderedPendingTask();
TestOrderedPendingTask(const tracked_objects::Location& location,
Closure task,
OnceClosure task,
TimeTicks post_time,
TimeDelta delay,
size_t ordinal,
......@@ -106,7 +106,7 @@ TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask(
TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask(
const tracked_objects::Location& location,
Closure task,
OnceClosure task,
TimeTicks post_time,
TimeDelta delay,
size_t ordinal,
......@@ -240,7 +240,7 @@ bool TestMockTimeTaskRunner::RunsTasksOnCurrentThread() const {
bool TestMockTimeTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay) {
AutoLock scoped_lock(tasks_lock_);
tasks_.push(TestOrderedPendingTask(from_here, std::move(task), now_ticks_,
......@@ -251,7 +251,7 @@ bool TestMockTimeTaskRunner::PostDelayedTask(
bool TestMockTimeTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay) {
return PostDelayedTask(from_here, std::move(task), delay);
}
......
......@@ -141,10 +141,10 @@ class TestMockTimeTaskRunner : public SingleThreadTaskRunner {
// SingleThreadTaskRunner:
bool RunsTasksOnCurrentThread() const override;
bool PostDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay) override;
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
Closure task,
OnceClosure task,
TimeDelta delay) override;
protected:
......
......@@ -12,7 +12,7 @@ namespace base {
TestPendingTask::TestPendingTask() : nestability(NESTABLE) {}
TestPendingTask::TestPendingTask(const tracked_objects::Location& location,
Closure task,