1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/task_runner.h"
9 #include "base/compiler_specific.h"
10 #include "base/logging.h"
11 #include "base/threading/post_task_and_reply_impl.h"
17 // TODO(akalin): There's only one other implementation of
18 // PostTaskAndReplyImpl in WorkerPool. Investigate whether it'll be
19 // possible to merge the two.
20 class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl {
22 explicit PostTaskAndReplyTaskRunner(TaskRunner* destination);
25 bool PostTask(const Location& from_here, OnceClosure task) override;
28 TaskRunner* destination_;
31 PostTaskAndReplyTaskRunner::PostTaskAndReplyTaskRunner(
32 TaskRunner* destination) : destination_(destination) {
36 bool PostTaskAndReplyTaskRunner::PostTask(const Location& from_here,
38 return destination_->PostTask(from_here, std::move(task));
43 bool TaskRunner::PostTask(const Location& from_here, OnceClosure task) {
44 return PostDelayedTask(from_here, std::move(task), base::TimeDelta());
47 bool TaskRunner::PostTaskAndReply(const Location& from_here,
50 return PostTaskAndReplyTaskRunner(this).PostTaskAndReply(
51 from_here, std::move(task), std::move(reply));
54 TaskRunner::TaskRunner() = default;
56 TaskRunner::~TaskRunner() = default;
58 void TaskRunner::OnDestruct() const {
62 void TaskRunnerTraits::Destruct(const TaskRunner* task_runner) {
63 task_runner->OnDestruct();