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

Unified Diff: base/task_scheduler/task.cc

Issue 2770873003: Add CriticalClosure to BLOCK_SHUTDOWN Tasks (Closed)
Patch Set: Created 3 years, 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/task.cc
diff --git a/base/task_scheduler/task.cc b/base/task_scheduler/task.cc
index 3780c16dcb71ceff67da3611d4c9c260e641aa76..bf3bbbd5c19d041acc197ac7c114cadcc8f43996 100644
--- a/base/task_scheduler/task.cc
+++ b/base/task_scheduler/task.cc
@@ -4,6 +4,8 @@
#include "base/task_scheduler/task.h"
+#include "base/critical_closure.h"
+
namespace base {
namespace internal {
@@ -11,15 +13,17 @@ Task::Task(const tracked_objects::Location& posted_from,
const Closure& task,
const TaskTraits& traits,
TimeDelta delay)
- : PendingTask(posted_from,
- task,
- delay.is_zero() ? TimeTicks() : TimeTicks::Now() + delay,
- false), // Not nestable.
+ : PendingTask(
+ posted_from,
+ traits.shutdown_behavior() == TaskShutdownBehavior::BLOCK_SHUTDOWN
+ ? MakeCriticalClosure(task)
+ : task,
+ delay.is_zero() ? TimeTicks() : TimeTicks::Now() + delay,
+ false), // Not nestable.
// Prevent a delayed BLOCK_SHUTDOWN task from blocking shutdown before
// being scheduled by changing its shutdown behavior to SKIP_ON_SHUTDOWN.
- traits(!delay.is_zero() &&
- traits.shutdown_behavior() ==
- TaskShutdownBehavior::BLOCK_SHUTDOWN
+ traits(!delay.is_zero() && traits.shutdown_behavior() ==
+ TaskShutdownBehavior::BLOCK_SHUTDOWN
? TaskTraits(traits).WithShutdownBehavior(
TaskShutdownBehavior::SKIP_ON_SHUTDOWN)
: traits),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698