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

Side by Side Diff: base/threading/thread_checker.h

Issue 9020008: Enable ThreadChecker in non-debug builds if DCHECK_ALWAYS_ON is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef NDEBUG 9 // Apart from debug builds, we also enable the thread checker in
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
12 // debug bots.
13 //
14 // Note that this does not perfectly match situations where DCHECK is
15 // enabled. For example a non-official release build may have
16 // DCHECK_ALWAYS_ON undefined (and therefore ThreadChecker would be
17 // disabled) but have DCHECKs enabled at runtime.
18 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
19 #define ENABLE_THREAD_CHECKER 1
20 #else
21 #define ENABLE_THREAD_CHECKER 0
22 #endif
23
24 #if ENABLE_THREAD_CHECKER
10 #include "base/threading/thread_checker_impl.h" 25 #include "base/threading/thread_checker_impl.h"
11 #endif 26 #endif
12 27
13 namespace base { 28 namespace base {
14 29
15 // Do nothing implementation, for use in release mode. 30 // Do nothing implementation, for use in release mode.
16 // 31 //
17 // 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
18 // right version for your build configuration. 33 // right version for your build configuration.
19 class ThreadCheckerDoNothing { 34 class ThreadCheckerDoNothing {
(...skipping 19 matching lines...) Expand all
39 // Example: 54 // Example:
40 // class MyClass : public ThreadChecker { 55 // class MyClass : public ThreadChecker {
41 // public: 56 // public:
42 // void Foo() { 57 // void Foo() {
43 // DCHECK(CalledOnValidThread()); 58 // DCHECK(CalledOnValidThread());
44 // ... (do stuff) ... 59 // ... (do stuff) ...
45 // } 60 // }
46 // } 61 // }
47 // 62 //
48 // In Release mode, CalledOnValidThread will always return true. 63 // In Release mode, CalledOnValidThread will always return true.
49 #ifndef NDEBUG 64 #if ENABLE_THREAD_CHECKER
50 class ThreadChecker : public ThreadCheckerImpl { 65 class ThreadChecker : public ThreadCheckerImpl {
51 }; 66 };
52 #else 67 #else
53 class ThreadChecker : public ThreadCheckerDoNothing { 68 class ThreadChecker : public ThreadCheckerDoNothing {
54 }; 69 };
55 #endif // NDEBUG 70 #endif // ENABLE_THREAD_CHECKER
71
72 #undef ENABLE_THREAD_CHECKER
56 73
57 } // namespace base 74 } // namespace base
58 75
59 #endif // BASE_THREADING_THREAD_CHECKER_H_ 76 #endif // BASE_THREADING_THREAD_CHECKER_H_
OLDNEW
« no previous file with comments | « no previous file | base/threading/thread_checker_unittest.cc » ('j') | base/threading/thread_checker_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698