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 #pragma once | 7 #pragma once |
8 | 8 |
9 // Apart from debug builds, we also enable the thread checker in | 9 // Apart from debug builds, we also enable the thread checker in |
10 // builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots | 10 // builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots |
11 // with this define will get the same level of thread checking as | 11 // with this define will get the same level of thread checking as |
12 // debug bots. | 12 // debug bots. |
13 // | 13 // |
14 // Note that this does not perfectly match situations where DCHECK is | 14 // Note that this does not perfectly match situations where DCHECK is |
15 // enabled. For example a non-official release build may have | 15 // enabled. For example a non-official release build may have |
16 // DCHECK_ALWAYS_ON undefined (and therefore ThreadChecker would be | 16 // DCHECK_ALWAYS_ON undefined (and therefore ThreadChecker would be |
17 // disabled) but have DCHECKs enabled at runtime. | 17 // disabled) but have DCHECKs enabled at runtime. |
18 #define ENABLE_THREAD_CHECKER (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) | 18 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
| 19 #define ENABLE_THREAD_CHECKER 1 |
| 20 #else |
| 21 #define ENABLE_THREAD_CHECKER 0 |
| 22 #endif |
19 | 23 |
20 #if ENABLE_THREAD_CHECKER | 24 #if ENABLE_THREAD_CHECKER |
21 #include "base/threading/thread_checker_impl.h" | 25 #include "base/threading/thread_checker_impl.h" |
22 #endif | 26 #endif |
23 | 27 |
24 namespace base { | 28 namespace base { |
25 | 29 |
26 // Do nothing implementation, for use in release mode. | 30 // Do nothing implementation, for use in release mode. |
27 // | 31 // |
28 // Note: You should almost always use the ThreadChecker class to get the | 32 // Note: You should almost always use the ThreadChecker class to get the |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #else | 67 #else |
64 class ThreadChecker : public ThreadCheckerDoNothing { | 68 class ThreadChecker : public ThreadCheckerDoNothing { |
65 }; | 69 }; |
66 #endif // ENABLE_THREAD_CHECKER | 70 #endif // ENABLE_THREAD_CHECKER |
67 | 71 |
68 #undef ENABLE_THREAD_CHECKER | 72 #undef ENABLE_THREAD_CHECKER |
69 | 73 |
70 } // namespace base | 74 } // namespace base |
71 | 75 |
72 #endif // BASE_THREADING_THREAD_CHECKER_H_ | 76 #endif // BASE_THREADING_THREAD_CHECKER_H_ |
OLD | NEW |