Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1838)

Unified Diff: base/task_scheduler/scheduler_thread_pool_impl.cc

Issue 1911023002: TaskScheduler: Add TaskRunnerHandle support to TaskScheduler tasks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@c1_1876363004_STTR
Patch Set: review:fdoray#17 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/task_scheduler/sequence.h » ('j') | base/task_scheduler/sequence.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/scheduler_thread_pool_impl.cc
diff --git a/base/task_scheduler/scheduler_thread_pool_impl.cc b/base/task_scheduler/scheduler_thread_pool_impl.cc
index 0eba0f7f0e13df7687fc995b3d7893abda4c9703..27afa38724fbfb5339811ef4d30fce9316187af2 100644
--- a/base/task_scheduler/scheduler_thread_pool_impl.cc
+++ b/base/task_scheduler/scheduler_thread_pool_impl.cc
@@ -77,10 +77,12 @@ class SchedulerSequencedTaskRunner : public SequencedTaskRunner {
bool PostDelayedTask(const tracked_objects::Location& from_here,
const Closure& closure,
TimeDelta delay) override {
+ std::unique_ptr<Task> task(new Task(from_here, closure, traits_, delay));
+ task->sequenced_task_runner_ref = this;
+
// Post the task as part of |sequence_|.
- return thread_pool_->PostTaskWithSequence(
- WrapUnique(new Task(from_here, closure, traits_, delay)), sequence_,
- nullptr);
+ return thread_pool_->PostTaskWithSequence(std::move(task), sequence_,
+ nullptr);
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
@@ -124,10 +126,12 @@ class SchedulerSingleThreadTaskRunner : public SingleThreadTaskRunner {
bool PostDelayedTask(const tracked_objects::Location& from_here,
const Closure& closure,
TimeDelta delay) override {
+ std::unique_ptr<Task> task(new Task(from_here, closure, traits_, delay));
+ task->single_thread_task_runner_ref = this;
+
// Post the task to be executed by |worker_thread_| as part of |sequence_|.
- return thread_pool_->PostTaskWithSequence(
- WrapUnique(new Task(from_here, closure, traits_, delay)), sequence_,
- worker_thread_);
+ return thread_pool_->PostTaskWithSequence(std::move(task), sequence_,
+ worker_thread_);
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
« no previous file with comments | « no previous file | base/task_scheduler/sequence.h » ('j') | base/task_scheduler/sequence.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698