Index: base/threading/sequenced_worker_pool.cc |
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc |
index 57961b5cd5538306ea00a4b354966e32b20d4e0c..9002755d21319feae01a3773f96951faf9b4e3e5 100644 |
--- a/base/threading/sequenced_worker_pool.cc |
+++ b/base/threading/sequenced_worker_pool.cc |
@@ -247,6 +247,14 @@ class SequencedWorkerPool::Worker : public SimpleThread { |
is_processing_task_ = true; |
task_sequence_token_ = token; |
task_shutdown_behavior_ = shutdown_behavior; |
+ |
+ // It is dangerous for tasks with CONTINUE_ON_SHUTDOWN to access a class |
+ // that implements a non-leaky base::Singleton because they are generally |
+ // destroyed before the process terminates via an AtExitManager |
+ // registration. This will trigger a DCHECK to warn of such cases. See the |
+ // comment about CONTINUE_ON_SHUTDOWN for more details. |
+ ThreadRestrictions::SetSingletonAllowed(task_shutdown_behavior_ != |
+ CONTINUE_ON_SHUTDOWN); |
} |
// Indicates that the task has finished running. |