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

Unified Diff: base/task_scheduler/task_tracker.cc

Issue 2857103005: Exempt the Service Thread from BLOCK_SHUTDOWN DCHECKs (Closed)
Patch Set: CR Feedback Created 3 years, 7 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 | « base/task_scheduler/task_tracker.h ('k') | base/task_scheduler/task_tracker_posix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..277d2e16851ada19e196aadb6a0c9399bbb572bf 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::IsPostingBlockShutdownTaskAfterShutdownAllowed() {
+ 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,17 @@ 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.
+#if DCHECK_IS_ON()
+ DCHECK(IsPostingBlockShutdownTaskAfterShutdownAllowed());
+#endif
+ state_->DecrementNumTasksBlockingShutdown();
+ return false;
+ }
++num_block_shutdown_tasks_posted_during_shutdown_;
« no previous file with comments | « base/task_scheduler/task_tracker.h ('k') | base/task_scheduler/task_tracker_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698