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_SEQUENCE_CHECKER_H_ | 5 #ifndef BASE_SEQUENCE_CHECKER_H_ |
6 #define BASE_SEQUENCE_CHECKER_H_ | 6 #define BASE_SEQUENCE_CHECKER_H_ |
7 | 7 |
8 // See comments for the similar block in thread_checker.h. | |
9 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) | |
10 #define ENABLE_SEQUENCE_CHECKER 1 | |
11 #else | |
12 #define ENABLE_SEQUENCE_CHECKER 0 | |
13 #endif | |
14 | |
15 #include "base/sequence_checker_impl.h" | 8 #include "base/sequence_checker_impl.h" |
16 | 9 |
17 namespace base { | 10 namespace base { |
18 | 11 |
19 // Do nothing implementation, for use in release mode. | 12 // Do nothing implementation, for use in release mode. |
20 // | 13 // |
21 // Note: You should almost always use the SequenceChecker class to get | 14 // Note: You should almost always use the SequenceChecker class to get |
22 // the right version for your build configuration. | 15 // the right version for your build configuration. |
23 class SequenceCheckerDoNothing { | 16 class SequenceCheckerDoNothing { |
24 public: | 17 public: |
(...skipping 14 matching lines...) Expand all Loading... |
39 // void Foo() { | 32 // void Foo() { |
40 // DCHECK(sequence_checker_.CalledOnValidSequence()); | 33 // DCHECK(sequence_checker_.CalledOnValidSequence()); |
41 // ... (do stuff) ... | 34 // ... (do stuff) ... |
42 // } | 35 // } |
43 // | 36 // |
44 // private: | 37 // private: |
45 // SequenceChecker sequence_checker_; | 38 // SequenceChecker sequence_checker_; |
46 // } | 39 // } |
47 // | 40 // |
48 // In Release mode, CalledOnValidSequence() will always return true. | 41 // In Release mode, CalledOnValidSequence() will always return true. |
49 #if ENABLE_SEQUENCE_CHECKER | 42 #if DCHECK_IS_ON() |
50 class SequenceChecker : public SequenceCheckerImpl { | 43 class SequenceChecker : public SequenceCheckerImpl { |
51 }; | 44 }; |
52 #else | 45 #else |
53 class SequenceChecker : public SequenceCheckerDoNothing { | 46 class SequenceChecker : public SequenceCheckerDoNothing { |
54 }; | 47 }; |
55 #endif // ENABLE_SEQUENCE_CHECKER | 48 #endif // DCHECK_IS_ON() |
56 | |
57 #undef ENABLE_SEQUENCE_CHECKER | |
58 | 49 |
59 } // namespace base | 50 } // namespace base |
60 | 51 |
61 #endif // BASE_SEQUENCE_CHECKER_H_ | 52 #endif // BASE_SEQUENCE_CHECKER_H_ |
OLD | NEW |