Commit 070c8ffb authored by tzik's avatar tzik Committed by Commit bot

Pass Callback to TaskRunner by value and consume it on invocation

This is a preparation CL for http://crrev.com/2637843002, which replaces
the Callback parameter of TaskRunner::PostTask with OnceCallback.
This one replaces the passed-by-const-ref Callback parameter of
TaskRunner::PostTask() with pass-by-value.

With the pass-by-const-ref manner as the old code does, we can't avoid
leaving a reference to the callback object on the original thread. That
is, the callback object may be destroyed either on the target thread or
the original thread. That's problematic when a non-thread-safe object is
bound to the callback.

Pass-by-value and move() in this CL mitigate the nondeterminism: if the
caller of TaskRunner::PostTask() passes the callback object as rvalue,
TaskRunner::PostTask() leaves no reference on the original thread.
I.e. the reference is not left if the callback is passed directly from
Bind(), or passed with std::move() as below.

  task_runner->PostTask(FROM_HERE, base::Bind(&Foo));

  base::Closure cb = base::Bind(&Foo);
  task_runner->PostTask(FROM_HERE, std::move(cb));

Otherwise, if the caller passes the callback as lvalue, a reference to
the callback is left on the original thread as we do in the previous code.
I.e. a reference is left if the callback is passed from other non-temporary
variable.

  base::Closure cb = base::Bind(&Foo);
  task_runner->PostTask(FROM_HERE, cb);

This is less controversial part of http://crrev.com/2637843002. This CL
is mainly to land it incrementally.

TBR=shrike@chromium.org
BUG=704027
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2726523002
Cr-Commit-Position: refs/heads/master@{#460288}
parent 4cc1dcc2
......@@ -5,6 +5,8 @@
#ifndef BASE_CRITICAL_CLOSURE_H_
#define BASE_CRITICAL_CLOSURE_H_
#include <utility>
#include "base/callback.h"
#include "base/macros.h"
#include "build/build_config.h"
......@@ -27,7 +29,7 @@ bool IsMultiTaskingSupported();
// |ios::ScopedCriticalAction|.
class CriticalClosure {
public:
explicit CriticalClosure(const Closure& closure);
explicit CriticalClosure(Closure closure);
~CriticalClosure();
void Run();
......@@ -55,13 +57,13 @@ class CriticalClosure {
// background running time, |MakeCriticalClosure| should be applied on them
// before posting.
#if defined(OS_IOS)
inline Closure MakeCriticalClosure(const Closure& closure) {
inline Closure MakeCriticalClosure(Closure closure) {
DCHECK(internal::IsMultiTaskingSupported());
return base::Bind(&internal::CriticalClosure::Run,
Owned(new internal::CriticalClosure(closure)));
Owned(new internal::CriticalClosure(std::move(closure))));
}
#else // defined(OS_IOS)
inline Closure MakeCriticalClosure(const Closure& closure) {
inline Closure MakeCriticalClosure(Closure 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,7 +13,8 @@ bool IsMultiTaskingSupported() {
return [[UIDevice currentDevice] isMultitaskingSupported];
}
CriticalClosure::CriticalClosure(const Closure& closure) : closure_(closure) {}
CriticalClosure::CriticalClosure(Closure closure)
: closure_(std::move(closure)) {}
CriticalClosure::~CriticalClosure() {}
......
......@@ -4,6 +4,8 @@
#include "base/deferred_sequenced_task_runner.h"
#include <utility>
#include "base/bind.h"
#include "base/logging.h"
......@@ -13,12 +15,16 @@ DeferredSequencedTaskRunner::DeferredTask::DeferredTask()
: is_non_nestable(false) {
}
DeferredSequencedTaskRunner::DeferredTask::DeferredTask(
const DeferredTask& other) = default;
DeferredSequencedTaskRunner::DeferredTask::DeferredTask(DeferredTask&& other) =
default;
DeferredSequencedTaskRunner::DeferredTask::~DeferredTask() {
}
DeferredSequencedTaskRunner::DeferredTask&
DeferredSequencedTaskRunner::DeferredTask::operator=(DeferredTask&& other) =
default;
DeferredSequencedTaskRunner::DeferredSequencedTaskRunner(
scoped_refptr<SequencedTaskRunner> target_task_runner)
: started_(false), target_task_runner_(std::move(target_task_runner)) {}
......@@ -28,15 +34,17 @@ DeferredSequencedTaskRunner::~DeferredSequencedTaskRunner() {
bool DeferredSequencedTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
Closure task,
TimeDelta delay) {
AutoLock lock(lock_);
if (started_) {
DCHECK(deferred_tasks_queue_.empty());
return target_task_runner_->PostDelayedTask(from_here, task, delay);
return target_task_runner_->PostDelayedTask(from_here, std::move(task),
delay);
}
QueueDeferredTask(from_here, task, delay, false /* is_non_nestable */);
QueueDeferredTask(from_here, std::move(task), delay,
false /* is_non_nestable */);
return true;
}
......@@ -46,33 +54,32 @@ bool DeferredSequencedTaskRunner::RunsTasksOnCurrentThread() const {
bool DeferredSequencedTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
Closure task,
TimeDelta delay) {
AutoLock lock(lock_);
if (started_) {
DCHECK(deferred_tasks_queue_.empty());
return target_task_runner_->PostNonNestableDelayedTask(from_here,
task,
delay);
return target_task_runner_->PostNonNestableDelayedTask(
from_here, std::move(task), delay);
}
QueueDeferredTask(from_here, task, delay, true /* is_non_nestable */);
QueueDeferredTask(from_here, std::move(task), delay,
true /* is_non_nestable */);
return true;
}
void DeferredSequencedTaskRunner::QueueDeferredTask(
const tracked_objects::Location& from_here,
const Closure& task,
Closure task,
TimeDelta delay,
bool is_non_nestable) {
DeferredTask deferred_task;
deferred_task.posted_from = from_here;
deferred_task.task = task;
deferred_task.task = std::move(task);
deferred_task.delay = delay;
deferred_task.is_non_nestable = is_non_nestable;
deferred_tasks_queue_.push_back(deferred_task);
deferred_tasks_queue_.push_back(std::move(deferred_task));
}
void DeferredSequencedTaskRunner::Start() {
AutoLock lock(lock_);
DCHECK(!started_);
......@@ -80,20 +87,14 @@ void DeferredSequencedTaskRunner::Start() {
for (std::vector<DeferredTask>::iterator i = deferred_tasks_queue_.begin();
i != deferred_tasks_queue_.end();
++i) {
const DeferredTask& task = *i;
DeferredTask& task = *i;
if (task.is_non_nestable) {
target_task_runner_->PostNonNestableDelayedTask(task.posted_from,
task.task,
task.delay);
target_task_runner_->PostNonNestableDelayedTask(
task.posted_from, std::move(task.task), task.delay);
} else {
target_task_runner_->PostDelayedTask(task.posted_from,
task.task,
task.delay);
std::move(task.task), task.delay);
}
// Replace the i-th element in the |deferred_tasks_queue_| with an empty
// |DelayedTask| to ensure that |task| is destroyed before the next task
// is posted.
*i = DeferredTask();
}
deferred_tasks_queue_.clear();
}
......
......@@ -28,13 +28,13 @@ class BASE_EXPORT DeferredSequencedTaskRunner : public SequencedTaskRunner {
// TaskRunner implementation
bool PostDelayedTask(const tracked_objects::Location& from_here,
const Closure& task,
Closure task,
TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
// SequencedTaskRunner implementation
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
const Closure& task,
Closure task,
TimeDelta delay) override;
// Start the execution - posts all queued tasks to the target executor. The
......@@ -46,8 +46,9 @@ class BASE_EXPORT DeferredSequencedTaskRunner : public SequencedTaskRunner {
private:
struct DeferredTask {
DeferredTask();
DeferredTask(const DeferredTask& other);
DeferredTask(DeferredTask&& other);
~DeferredTask();
DeferredTask& operator=(DeferredTask&& other);
tracked_objects::Location posted_from;
Closure task;
......@@ -60,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,
const Closure& task,
Closure task,
TimeDelta delay,
bool is_non_nestable);
......
......@@ -5,6 +5,7 @@
#include "base/message_loop/incoming_task_queue.h"
#include <limits>
#include <utility>
#include "base/location.h"
#include "base/message_loop/message_loop.h"
......@@ -59,7 +60,7 @@ IncomingTaskQueue::IncomingTaskQueue(MessageLoop* message_loop)
bool IncomingTaskQueue::AddToIncomingQueue(
const tracked_objects::Location& from_here,
const Closure& task,
Closure task,
TimeDelta delay,
bool nestable) {
DLOG_IF(WARNING,
......@@ -67,8 +68,8 @@ bool IncomingTaskQueue::AddToIncomingQueue(
<< "Requesting super-long task delay period of " << delay.InSeconds()
<< " seconds from here: " << from_here.ToString();
PendingTask pending_task(from_here, task, CalculateDelayedRuntime(delay),
nestable);
PendingTask pending_task(from_here, std::move(task),
CalculateDelayedRuntime(delay), nestable);
#if defined(OS_WIN)
// We consider the task needs a high resolution timer if the delay is
// more than 0 and less than 32ms. This caps the relative error to
......
......@@ -6,6 +6,7 @@
#define BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_
#include "base/base_export.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/pending_task.h"
......@@ -35,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,
const Closure& task,
Closure task,
TimeDelta delay,
bool nestable);
......
......@@ -4,6 +4,8 @@
#include "base/message_loop/message_loop_task_runner.h"
#include <utility>
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/incoming_task_queue.h"
......@@ -24,18 +26,20 @@ void MessageLoopTaskRunner::BindToCurrentThread() {
bool MessageLoopTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
Closure task,
base::TimeDelta delay) {
DCHECK(!task.is_null()) << from_here.ToString();
return incoming_queue_->AddToIncomingQueue(from_here, task, delay, true);
return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay,
true);
}
bool MessageLoopTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
Closure task,
base::TimeDelta delay) {
DCHECK(!task.is_null()) << from_here.ToString();
return incoming_queue_->AddToIncomingQueue(from_here, task, delay, false);
return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay,
false);
}
bool MessageLoopTaskRunner::RunsTasksOnCurrentThread() const {
......
......@@ -6,6 +6,7 @@
#define BASE_MESSAGE_LOOP_MESSAGE_LOOP_TASK_RUNNER_H_
#include "base/base_export.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/pending_task.h"
......@@ -31,10 +32,10 @@ class BASE_EXPORT MessageLoopTaskRunner : public SingleThreadTaskRunner {
// SingleThreadTaskRunner implementation
bool PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
Closure task,
base::TimeDelta delay) override;
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
Closure task,
base::TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
......
......@@ -4,14 +4,17 @@
#include "base/sequenced_task_runner.h"
#include <utility>
#include "base/bind.h"
namespace base {
bool SequencedTaskRunner::PostNonNestableTask(
const tracked_objects::Location& from_here,
const Closure& task) {
return PostNonNestableDelayedTask(from_here, task, base::TimeDelta());
Closure task) {
return PostNonNestableDelayedTask(from_here, std::move(task),
base::TimeDelta());
}
bool SequencedTaskRunner::DeleteOrReleaseSoonInternal(
......
......@@ -6,6 +6,7 @@
#define BASE_SEQUENCED_TASK_RUNNER_H_
#include "base/base_export.h"
#include "base/callback.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/task_runner.h"
......@@ -109,11 +110,11 @@ class BASE_EXPORT SequencedTaskRunner : public TaskRunner {
// below.
bool PostNonNestableTask(const tracked_objects::Location& from_here,
const Closure& task);
Closure task);
virtual bool PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
Closure 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,
const Closure& task) override;
Closure task) override;
// Non-owning.
TaskRunner* destination_;
......@@ -36,15 +36,15 @@ PostTaskAndReplyTaskRunner::PostTaskAndReplyTaskRunner(
bool PostTaskAndReplyTaskRunner::PostTask(
const tracked_objects::Location& from_here,
const Closure& task) {
return destination_->PostTask(from_here, task);
Closure task) {
return destination_->PostTask(from_here, std::move(task));
}
} // namespace
bool TaskRunner::PostTask(const tracked_objects::Location& from_here,
const Closure& task) {
return PostDelayedTask(from_here, task, base::TimeDelta());
Closure task) {
return PostDelayedTask(from_here, std::move(task), base::TimeDelta());
}
bool TaskRunner::PostTaskAndReply(const tracked_objects::Location& from_here,
......
......@@ -61,8 +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,
const Closure& task);
bool PostTask(const tracked_objects::Location& from_here, Closure task);
// Like PostTask, but tries to run the posted task only after
// |delay_ms| has passed.
......@@ -70,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,
const Closure& task,
Closure task,
base::TimeDelta delay) = 0;
// Returns true if the current thread is a thread on which a task
......
......@@ -21,8 +21,8 @@ class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl {
private:
bool PostTask(const tracked_objects::Location& from_here,
const Closure& task) override {
PostTaskWithTraits(from_here, traits_, task);
Closure task) override {
PostTaskWithTraits(from_here, traits_, std::move(task));
return true;
}
......@@ -32,14 +32,14 @@ class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl {
} // namespace
void PostTask(const tracked_objects::Location& from_here, const Closure& task) {
PostDelayedTask(from_here, task, TimeDelta());
void PostTask(const tracked_objects::Location& from_here, Closure task) {
PostDelayedTask(from_here, std::move(task), TimeDelta());
}
void PostDelayedTask(const tracked_objects::Location& from_here,
const Closure& task,
Closure task,
TimeDelta delay) {
PostDelayedTaskWithTraits(from_here, TaskTraits(), task, delay);
PostDelayedTaskWithTraits(from_here, TaskTraits(), std::move(task), delay);
}
void PostTaskAndReply(const tracked_objects::Location& from_here,
......@@ -51,18 +51,18 @@ void PostTaskAndReply(const tracked_objects::Location& from_here,
void PostTaskWithTraits(const tracked_objects::Location& from_here,
const TaskTraits& traits,
const Closure& task) {
PostDelayedTaskWithTraits(from_here, traits, task, TimeDelta());
Closure task) {
PostDelayedTaskWithTraits(from_here, traits, std::move(task), TimeDelta());
}
void PostDelayedTaskWithTraits(const tracked_objects::Location& from_here,
const TaskTraits& traits,
const Closure& task,
Closure task,
TimeDelta delay) {
DCHECK(TaskScheduler::GetInstance())
<< "Ref. Prerequisite section of post_task.h";
TaskScheduler::GetInstance()->PostDelayedTaskWithTraits(from_here, traits,
task, delay);
TaskScheduler::GetInstance()->PostDelayedTaskWithTraits(
from_here, traits, std::move(task), delay);
}
void PostTaskWithTraitsAndReply(const tracked_objects::Location& from_here,
......
......@@ -70,7 +70,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,
const Closure& task);
Closure task);
// Posts |task| to the TaskScheduler. |task| will not run before |delay|
// expires. Calling this is equivalent to calling PostDelayedTaskWithTraits with
......@@ -79,7 +79,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,
const Closure& task,
Closure task,
TimeDelta delay);
// Posts |task| to the TaskScheduler and posts |reply| on the caller's execution
......@@ -107,7 +107,7 @@ void PostTaskAndReplyWithResult(const tracked_objects::Location& from_here,
// Posts |task| with specific |traits| to the TaskScheduler.
BASE_EXPORT void PostTaskWithTraits(const tracked_objects::Location& from_here,
const TaskTraits& traits,
const Closure& task);
Closure task);
// Posts |task| with specific |traits| to the TaskScheduler. |task| will not run
// before |delay| expires.
......@@ -117,7 +117,7 @@ BASE_EXPORT void PostTaskWithTraits(const tracked_objects::Location& from_here,
BASE_EXPORT void PostDelayedTaskWithTraits(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
const Closure& task,
Closure task,
TimeDelta delay);
// Posts |task| with specific |traits| to the TaskScheduler and posts |reply| on
......
......@@ -253,9 +253,9 @@ class SchedulerSingleThreadTaskRunnerManager::SchedulerSingleThreadTaskRunner
// SingleThreadTaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
const Closure& closure,
Closure closure,
TimeDelta delay) override {
auto task = MakeUnique<Task>(from_here, closure, traits_, delay);
auto task = MakeUnique<Task>(from_here, std::move(closure), traits_, delay);
task->single_thread_task_runner_ref = this;
if (!outer_->task_tracker_->WillPostTask(task.get()))
......@@ -272,10 +272,10 @@ class SchedulerSingleThreadTaskRunnerManager::SchedulerSingleThreadTaskRunner
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
const Closure& closure,
Closure closure,
TimeDelta delay) override {
// Tasks are never nested within the task scheduler.
return PostDelayedTask(from_here, closure, delay);
return PostDelayedTask(from_here, std::move(closure), delay);
}
bool RunsTasksOnCurrentThread() const override {
......
......@@ -58,11 +58,11 @@ class SchedulerParallelTaskRunner : public TaskRunner {
// TaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
const Closure& closure,
Closure closure,
TimeDelta delay) override {
// Post the task as part of a one-off single-task Sequence.
return worker_pool_->PostTaskWithSequence(
MakeUnique<Task>(from_here, closure, traits_, delay),
MakeUnique<Task>(from_here, std::move(closure), traits_, delay),
make_scoped_refptr(new Sequence));
}
......@@ -93,9 +93,10 @@ class SchedulerSequencedTaskRunner : public SequencedTaskRunner {
// SequencedTaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
const Closure& closure,
Closure closure,
TimeDelta delay) override {
std::unique_ptr<Task> task(new Task(from_here, closure, traits_, delay));
std::unique_ptr<Task> task(
new Task(from_here, std::move(closure), traits_, delay));
task->sequenced_task_runner_ref = this;
// Post the task as part of |sequence_|.
......@@ -103,10 +104,10 @@ class SchedulerSequencedTaskRunner : public SequencedTaskRunner {
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
const Closure& closure,
Closure closure,
base::TimeDelta delay) override {
// Tasks are never nested within the task scheduler.
return PostDelayedTask(from_here, closure, delay);
return PostDelayedTask(from_here, std::move(closure), delay);
}
bool RunsTasksOnCurrentThread() const override {
......
......@@ -4,20 +4,22 @@
#include "base/task_scheduler/task.h"
#include <utility>
#include "base/critical_closure.h"
namespace base {
namespace internal {
Task::Task(const tracked_objects::Location& posted_from,
const Closure& task,
Closure task,
const TaskTraits& traits,
TimeDelta delay)
: PendingTask(
posted_from,
traits.shutdown_behavior() == TaskShutdownBehavior::BLOCK_SHUTDOWN
? MakeCriticalClosure(task)
: task,
? MakeCriticalClosure(std::move(task))
: std::move(task),
delay.is_zero() ? TimeTicks() : TimeTicks::Now() + delay,
false), // Not nestable.
// Prevent a delayed BLOCK_SHUTDOWN task from blocking shutdown before
......
......@@ -6,7 +6,7 @@
#define BASE_TASK_SCHEDULER_TASK_H_
#include "base/base_export.h"
#include "base/callback_forward.h"
#include "base/callback.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
......@@ -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,
const Closure& task,
Closure task,
const TaskTraits& traits,
TimeDelta delay);
~Task();
......
......@@ -10,7 +10,7 @@
#include <vector>
#include "base/base_export.h"
#include "base/callback_forward.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
......@@ -69,7 +69,7 @@ class BASE_EXPORT TaskScheduler {
virtual void PostDelayedTaskWithTraits(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
const Closure& task,
Closure task,
TimeDelta delay) = 0;
// Returns a TaskRunner whose PostTask invocations result in scheduling tasks
......
......@@ -122,11 +122,11 @@ TaskSchedulerImpl::~TaskSchedulerImpl() {
void TaskSchedulerImpl::PostDelayedTaskWithTraits(
const tracked_objects::Location& from_here,
const TaskTraits& traits,
const Closure& task,
Closure task,
TimeDelta delay) {
// Post |task| as part of a one-off single-task Sequence.
GetWorkerPoolForTraits(traits)->PostTaskWithSequence(
MakeUnique<Task>(from_here, task, traits, delay),
MakeUnique<Task>(from_here, std::move(task), traits, delay),
make_scoped_refptr(new Sequence));
}
......
......@@ -61,7 +61,7 @@ class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler {
// TaskScheduler:
void PostDelayedTaskWithTraits(const tracked_objects::Location& from_here,
const TaskTraits& traits,
const Closure& task,
Closure task,
TimeDelta delay) override;
scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
const TaskTraits& traits) override;
......
......@@ -10,16 +10,15 @@ NullTaskRunner::NullTaskRunner() {}
NullTaskRunner::~NullTaskRunner() {}
bool NullTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) {
bool NullTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here,
Closure task,
base::TimeDelta delay) {
return false;
}
bool NullTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
Closure task,
base::TimeDelta delay) {
return false;
}
......
......@@ -5,6 +5,7 @@
#ifndef BASE_TEST_NULL_TASK_RUNNER_H_
#define BASE_TEST_NULL_TASK_RUNNER_H_
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
......@@ -19,10 +20,10 @@ class NullTaskRunner : public base::SingleThreadTaskRunner {
NullTaskRunner();
bool PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
base::Closure task,
base::TimeDelta delay) override;
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
base::Closure task,
base::TimeDelta delay) override;
// Always returns true to avoid triggering DCHECKs.
bool RunsTasksOnCurrentThread() const override;
......
......@@ -9,6 +9,7 @@
#include <vector>
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
......@@ -42,7 +43,7 @@ class TestTaskScheduler : public TaskScheduler {