OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef BASE_THREADING_THREAD_CHECKER_H_ |
6 #define BASE_THREADING_THREAD_CHECKER_H_ | 6 #define BASE_THREADING_THREAD_CHECKER_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/threading/thread_checker_impl.h" | 9 #include "base/threading/thread_checker_impl.h" |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // } | 50 // } |
51 // | 51 // |
52 // private: | 52 // private: |
53 // ThreadChecker thread_checker_; | 53 // ThreadChecker thread_checker_; |
54 // } | 54 // } |
55 // | 55 // |
56 // Note that, when enabled, CalledOnValidThread() returns false when called from | 56 // Note that, when enabled, CalledOnValidThread() returns false when called from |
57 // tasks posted to SingleThreadTaskRunners bound to different sequences, even if | 57 // tasks posted to SingleThreadTaskRunners bound to different sequences, even if |
58 // the tasks happen to run on the same thread (e.g. two independent TaskRunners | 58 // the tasks happen to run on the same thread (e.g. two independent TaskRunners |
59 // with ExecutionMode::SINGLE_THREADED on the TaskScheduler that happen to share | 59 // with ExecutionMode::SINGLE_THREADED on the TaskScheduler that happen to share |
60 // a thread). Also, CalledOnValidThread() returns false when called from a non- | 60 // a thread). |
61 // single-threaded task which is associated with a SequenceToken (e.g. a task | |
62 // posted with ExecutionMode::SEQUENCED to the TaskScheduler). | |
63 // | 61 // |
64 // In Release mode, CalledOnValidThread will always return true. | 62 // In Release mode, CalledOnValidThread will always return true. |
65 #if DCHECK_IS_ON() | 63 #if DCHECK_IS_ON() |
66 class ThreadChecker : public ThreadCheckerImpl { | 64 class ThreadChecker : public ThreadCheckerImpl { |
67 }; | 65 }; |
68 #else | 66 #else |
69 class ThreadChecker : public ThreadCheckerDoNothing { | 67 class ThreadChecker : public ThreadCheckerDoNothing { |
70 }; | 68 }; |
71 #endif // DCHECK_IS_ON() | 69 #endif // DCHECK_IS_ON() |
72 | 70 |
73 } // namespace base | 71 } // namespace base |
74 | 72 |
75 #endif // BASE_THREADING_THREAD_CHECKER_H_ | 73 #endif // BASE_THREADING_THREAD_CHECKER_H_ |
OLD | NEW |