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 // Apart from debug builds, we also enable the thread checker in | 8 // Apart from debug builds, we also enable the thread checker in |
9 // builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots | 9 // builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots |
10 // with this define will get the same level of thread checking as | 10 // with this define will get the same level of thread checking as |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/threading/thread_checker_impl.h" | 23 #include "base/threading/thread_checker_impl.h" |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 | 26 |
27 // Do nothing implementation, for use in release mode. | 27 // Do nothing implementation, for use in release mode. |
28 // | 28 // |
29 // Note: You should almost always use the ThreadChecker class to get the | 29 // Note: You should almost always use the ThreadChecker class to get the |
30 // right version for your build configuration. | 30 // right version for your build configuration. |
31 class ThreadCheckerDoNothing { | 31 class ThreadCheckerDoNothing { |
32 public: | 32 public: |
33 bool CalledOnValidThread() const { | 33 bool CalledOnValidThread() const WARN_UNUSED_RESULT { |
34 return true; | 34 return true; |
35 } | 35 } |
36 | 36 |
37 void DetachFromThread() {} | 37 void DetachFromThread() {} |
38 }; | 38 }; |
39 | 39 |
40 // ThreadChecker is a helper class used to help verify that some methods of a | 40 // ThreadChecker is a helper class used to help verify that some methods of a |
41 // class are called from the same thread. It provides identical functionality to | 41 // class are called from the same thread. It provides identical functionality to |
42 // base::NonThreadSafe, but it is meant to be held as a member variable, rather | 42 // base::NonThreadSafe, but it is meant to be held as a member variable, rather |
43 // than inherited from base::NonThreadSafe. | 43 // than inherited from base::NonThreadSafe. |
(...skipping 30 matching lines...) Expand all Loading... |
74 #else | 74 #else |
75 class ThreadChecker : public ThreadCheckerDoNothing { | 75 class ThreadChecker : public ThreadCheckerDoNothing { |
76 }; | 76 }; |
77 #endif // ENABLE_THREAD_CHECKER | 77 #endif // ENABLE_THREAD_CHECKER |
78 | 78 |
79 #undef ENABLE_THREAD_CHECKER | 79 #undef ENABLE_THREAD_CHECKER |
80 | 80 |
81 } // namespace base | 81 } // namespace base |
82 | 82 |
83 #endif // BASE_THREADING_THREAD_CHECKER_H_ | 83 #endif // BASE_THREADING_THREAD_CHECKER_H_ |
OLD | NEW |