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

Side by Side 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: similarity 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_THREADING_THREAD_CHECKER_IMPL_H_ 5 #ifndef BASE_THREADING_THREAD_CHECKER_IMPL_H_
6 #define BASE_THREADING_THREAD_CHECKER_IMPL_H_ 6 #define BASE_THREADING_THREAD_CHECKER_IMPL_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/sequence_token.h" 10 #include "base/sequence_and_task_token.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 // Real implementation of ThreadChecker, for use in debug mode, or for temporary 16 // Real implementation of ThreadChecker, for use in debug mode, or for temporary
17 // use in release mode (e.g. to CHECK on a threading issue seen only in the 17 // use in release mode (e.g. to CHECK on a threading issue seen only in the
18 // wild). 18 // wild).
19 // 19 //
20 // Note: You should almost always use the ThreadChecker class to get the right 20 // Note: You should almost always use the ThreadChecker class to get the right
(...skipping 14 matching lines...) Expand all
35 void EnsureAssigned() const; 35 void EnsureAssigned() const;
36 36
37 // Members are mutable so that CalledOnValidThread() can set them. 37 // Members are mutable so that CalledOnValidThread() can set them.
38 38
39 // Synchronizes access to all members. 39 // Synchronizes access to all members.
40 mutable base::Lock lock_; 40 mutable base::Lock lock_;
41 41
42 // Thread on which CalledOnValidThread() may return true. 42 // Thread on which CalledOnValidThread() may return true.
43 mutable PlatformThreadRef thread_id_; 43 mutable PlatformThreadRef thread_id_;
44 44
45 // TaskToken for which CalledOnValidThread() always returns true. This allows
46 // CalledOnValidThread() to return true when called multiple times from the
47 // same task. CalledOnValidThread() may return true even if the current
gab 2016/08/08 16:34:22 Prefix the last sentence with "Note: "
gab 2016/08/08 16:34:22 s/same task/same task, even if it's not running in
fdoray 2016/08/08 17:45:18 Done.
fdoray 2016/08/08 17:45:18 Done.
48 // TaskToken is not equal to this.
49 mutable TaskToken task_token_;
50
45 // SequenceToken for which CalledOnValidThread() may return true. Used to 51 // SequenceToken for which CalledOnValidThread() may return true. Used to
46 // ensure that CalledOnValidThread() doesn't return true for TaskScheduler 52 // ensure that CalledOnValidThread() doesn't return true for TaskScheduler
47 // tasks that happen to run on the same thread but weren't posted to the same 53 // tasks that happen to run on the same thread but weren't posted to the same
48 // SingleThreadTaskRunner. 54 // SingleThreadTaskRunner.
49 mutable SequenceToken sequence_token_; 55 mutable SequenceToken sequence_token_;
50 }; 56 };
51 57
52 } // namespace base 58 } // namespace base
53 59
54 #endif // BASE_THREADING_THREAD_CHECKER_IMPL_H_ 60 #endif // BASE_THREADING_THREAD_CHECKER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698