| 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 |
| 11 // debug bots. | 11 // debug bots. |
| 12 // | 12 // |
| 13 // Note that this does not perfectly match situations where DCHECK is | 13 // Note that this does not perfectly match situations where DCHECK is |
| 14 // enabled. For example a non-official release build may have | 14 // enabled. For example a non-official release build may have |
| 15 // DCHECK_ALWAYS_ON undefined (and therefore ThreadChecker would be | 15 // DCHECK_ALWAYS_ON undefined (and therefore ThreadChecker would be |
| 16 // disabled) but have DCHECKs enabled at runtime. | 16 // disabled) but have DCHECKs enabled at runtime. |
| 17 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) | 17 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
| 18 #define ENABLE_THREAD_CHECKER 1 | 18 #define ENABLE_THREAD_CHECKER 1 |
| 19 #else | 19 #else |
| 20 #define ENABLE_THREAD_CHECKER 0 | 20 #define ENABLE_THREAD_CHECKER 0 |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 #if ENABLE_THREAD_CHECKER | |
| 24 #include "base/threading/thread_checker_impl.h" | 23 #include "base/threading/thread_checker_impl.h" |
| 25 #endif | |
| 26 | 24 |
| 27 namespace base { | 25 namespace base { |
| 28 | 26 |
| 29 // Do nothing implementation, for use in release mode. | 27 // Do nothing implementation, for use in release mode. |
| 30 // | 28 // |
| 31 // 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 |
| 32 // right version for your build configuration. | 30 // right version for your build configuration. |
| 33 class ThreadCheckerDoNothing { | 31 class ThreadCheckerDoNothing { |
| 34 public: | 32 public: |
| 35 bool CalledOnValidThread() const { | 33 bool CalledOnValidThread() const { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #else | 74 #else |
| 77 class ThreadChecker : public ThreadCheckerDoNothing { | 75 class ThreadChecker : public ThreadCheckerDoNothing { |
| 78 }; | 76 }; |
| 79 #endif // ENABLE_THREAD_CHECKER | 77 #endif // ENABLE_THREAD_CHECKER |
| 80 | 78 |
| 81 #undef ENABLE_THREAD_CHECKER | 79 #undef ENABLE_THREAD_CHECKER |
| 82 | 80 |
| 83 } // namespace base | 81 } // namespace base |
| 84 | 82 |
| 85 #endif // BASE_THREADING_THREAD_CHECKER_H_ | 83 #endif // BASE_THREADING_THREAD_CHECKER_H_ |
| OLD | NEW |