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

Unified Diff: base/threading/thread_checker_impl.h

Issue 2213263002: Make ThreadChecker::CalledOnValidThread() return true when called from the same task. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR gab #6 (fix comment) Created 4 years, 4 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/threading/thread_checker_impl.h
diff --git a/base/threading/thread_checker_impl.h b/base/threading/thread_checker_impl.h
index 3e46316bc4e713fad2c0b84502339bc4b3a64904..13193d129932de0939f2c61bf76c3aa1ed8e8ea3 100644
--- a/base/threading/thread_checker_impl.h
+++ b/base/threading/thread_checker_impl.h
@@ -42,6 +42,14 @@ class BASE_EXPORT ThreadCheckerImpl {
// Thread on which CalledOnValidThread() may return true.
mutable PlatformThreadRef thread_id_;
+ // TaskToken for which CalledOnValidThread() always returns true. This allows
+ // CalledOnValidThread() to return true when called multiple times from the
+ // same task, even if it's not running in a single-threaded context itself
+ // (allowing usage of ThreadChecker/NonThreadSafe objects on the stack in the
+ // scope of one-off tasks). Note: CalledOnValidThread() may return true even
+ // if the current TaskToken is not equal to this.
+ mutable TaskToken task_token_;
+
// SequenceToken for which CalledOnValidThread() may return true. Used to
// ensure that CalledOnValidThread() doesn't return true for TaskScheduler
// tasks that happen to run on the same thread but weren't posted to the same

Powered by Google App Engine
This is Rietveld 408576698