Chromium Code Reviews| Index: base/task_scheduler/task_tracker.cc |
| diff --git a/base/task_scheduler/task_tracker.cc b/base/task_scheduler/task_tracker.cc |
| index da21d5ea8ef510c33636cc993b34e3501aa09101..06a0553280d16976fc074a7c018d1752ee3d2604 100644 |
| --- a/base/task_scheduler/task_tracker.cc |
| +++ b/base/task_scheduler/task_tracker.cc |
| @@ -10,7 +10,6 @@ |
| #include "base/callback.h" |
| #include "base/debug/task_annotator.h" |
| #include "base/json/json_writer.h" |
| -#include "base/logging.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/metrics/histogram_macros.h" |
| #include "base/sequence_token.h" |
| @@ -379,6 +378,12 @@ void TaskTracker::PerformShutdown() { |
| } |
| } |
| +#if DCHECK_IS_ON() |
| +bool TaskTracker::IsExemptFromBlockingShutdownChecks() { |
| + return false; |
| +} |
| +#endif |
| + |
| bool TaskTracker::BeforePostTask(TaskShutdownBehavior shutdown_behavior) { |
| if (shutdown_behavior == TaskShutdownBehavior::BLOCK_SHUTDOWN) { |
| // BLOCK_SHUTDOWN tasks block shutdown between the moment they are posted |
| @@ -391,7 +396,16 @@ bool TaskTracker::BeforePostTask(TaskShutdownBehavior shutdown_behavior) { |
| // A BLOCK_SHUTDOWN task posted after shutdown has completed is an |
| // ordering bug. This aims to catch those early. |
| DCHECK(shutdown_event_); |
| - DCHECK(!shutdown_event_->IsSignaled()); |
| + if (shutdown_event_->IsSignaled()) { |
| + // TODO(robliao): http://crbug.com/698140. Since the service thread |
| + // doesn't stop processing its own tasks at shutdown, we may still |
| + // attempt to post a BLOCK_SHUTDOWN task in response to a |
| + // FileDescriptorWatcher. Delayed tasks are fine because they're marked |
|
fdoray
2017/05/03 20:34:33
Delayed tasks go through TaskTracker::BeforePostTa
robliao
2017/05/03 21:11:17
Indeed. I was thinking of the general case. Remove
|
| + // as SKIP_ON_SHUTDOWN and are accounted for shutdown purposes. |
| + DCHECK(IsExemptFromBlockingShutdownChecks()); |
| + state_->DecrementNumTasksBlockingShutdown(); |
| + return false; |
| + } |
| ++num_block_shutdown_tasks_posted_during_shutdown_; |