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

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 (pure merge). Created 8 years, 11 months 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
« no previous file with comments | « base/message_pump_libevent_unittest.cc ('k') | base/threading/thread_checker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #define ENABLE_THREAD_CHECKER (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
19
20 #if ENABLE_THREAD_CHECKER
10 #include "base/threading/thread_checker_impl.h" 21 #include "base/threading/thread_checker_impl.h"
11 #endif 22 #endif
12 23
13 namespace base { 24 namespace base {
14 25
15 // Do nothing implementation, for use in release mode. 26 // Do nothing implementation, for use in release mode.
16 // 27 //
17 // Note: You should almost always use the ThreadChecker class to get the 28 // Note: You should almost always use the ThreadChecker class to get the
18 // right version for your build configuration. 29 // right version for your build configuration.
19 class ThreadCheckerDoNothing { 30 class ThreadCheckerDoNothing {
(...skipping 19 matching lines...) Expand all
39 // Example: 50 // Example:
40 // class MyClass : public ThreadChecker { 51 // class MyClass : public ThreadChecker {
41 // public: 52 // public:
42 // void Foo() { 53 // void Foo() {
43 // DCHECK(CalledOnValidThread()); 54 // DCHECK(CalledOnValidThread());
44 // ... (do stuff) ... 55 // ... (do stuff) ...
45 // } 56 // }
46 // } 57 // }
47 // 58 //
48 // In Release mode, CalledOnValidThread will always return true. 59 // In Release mode, CalledOnValidThread will always return true.
49 #ifndef NDEBUG 60 #if ENABLE_THREAD_CHECKER
50 class ThreadChecker : public ThreadCheckerImpl { 61 class ThreadChecker : public ThreadCheckerImpl {
51 }; 62 };
52 #else 63 #else
53 class ThreadChecker : public ThreadCheckerDoNothing { 64 class ThreadChecker : public ThreadCheckerDoNothing {
54 }; 65 };
55 #endif // NDEBUG 66 #endif // ENABLE_THREAD_CHECKER
67
68 #undef ENABLE_THREAD_CHECKER
56 69
57 } // namespace base 70 } // namespace base
58 71
59 #endif // BASE_THREADING_THREAD_CHECKER_H_ 72 #endif // BASE_THREADING_THREAD_CHECKER_H_
OLDNEW
« no previous file with comments | « base/message_pump_libevent_unittest.cc ('k') | base/threading/thread_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698