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

Unified Diff: base/task_scheduler/task.cc

Issue 2383193002: TaskScheduler: Adjust shutdown behavior of delayed tasks. (Closed)
Patch Set: no copy Created 4 years, 2 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
Index: base/task_scheduler/task.cc
diff --git a/base/task_scheduler/task.cc b/base/task_scheduler/task.cc
index 8a589a202186dc2b3404c234e104a856ca57d8dd..5ba594b734d12565d434c4f8b44dcde41878e935 100644
--- a/base/task_scheduler/task.cc
+++ b/base/task_scheduler/task.cc
@@ -15,7 +15,14 @@ Task::Task(const tracked_objects::Location& posted_from,
task,
delay.is_zero() ? TimeTicks() : TimeTicks::Now() + delay,
false), // Not nestable.
- traits(traits) {}
+ traits(traits) {
+ // Prevent a delayed BLOCK_SHUTDOWN task from blocking shutdown before being
+ // scheduled by changing its shutdown behavior to SKIP_ON_SHUTDOWN.
+ if (!delay.is_zero() &&
+ traits.shutdown_behavior() == TaskShutdownBehavior::BLOCK_SHUTDOWN) {
+ this->traits.WithShutdownBehavior(TaskShutdownBehavior::SKIP_ON_SHUTDOWN);
gab 2016/10/03 16:59:53 rm "this->" ? To avoid naming conflict and make s
fdoray 2016/10/03 17:10:15 Done.
+ }
+}
Task::~Task() = default;

Powered by Google App Engine
This is Rietveld 408576698