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 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 | 9 |
10 // See comments for the similar block in thread_checker.h. | 10 // See comments for the similar block in thread_checker.h. |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // SequenceChecker is a helper class used to help verify that some | 38 // SequenceChecker is a helper class used to help verify that some |
39 // methods of a class are called in sequence -- that is, called from | 39 // methods of a class are called in sequence -- that is, called from |
40 // the same SequencedTaskRunner. It is a generalization of | 40 // the same SequencedTaskRunner. It is a generalization of |
41 // ThreadChecker; see comments in sequence_checker_impl.h for details. | 41 // ThreadChecker; see comments in sequence_checker_impl.h for details. |
42 // | 42 // |
43 // Example: | 43 // Example: |
44 // class MyClass { | 44 // class MyClass { |
45 // public: | 45 // public: |
46 // void Foo() { | 46 // void Foo() { |
47 // DCHECK(sequence_checker_.CalledOnValidSequence()); | 47 // DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
48 // ... (do stuff) ... | 48 // ... (do stuff) ... |
49 // } | 49 // } |
50 // | 50 // |
51 // private: | 51 // private: |
52 // SequenceChecker sequence_checker_; | 52 // SequenceChecker sequence_checker_; |
53 // } | 53 // } |
54 // | 54 // |
55 // In Release mode, CalledOnValidSequence will always return true. | 55 // In Release mode, CalledOnValidSequence will always return true. |
56 #if ENABLE_SEQUENCE_CHECKER | 56 #if ENABLE_SEQUENCE_CHECKER |
57 class SequenceChecker : public SequenceCheckerImpl { | 57 class SequenceChecker : public SequenceCheckerImpl { |
58 }; | 58 }; |
59 #else | 59 #else |
60 class SequenceChecker : public SequenceCheckerDoNothing { | 60 class SequenceChecker : public SequenceCheckerDoNothing { |
61 }; | 61 }; |
62 #endif // ENABLE_SEQUENCE_CHECKER | 62 #endif // ENABLE_SEQUENCE_CHECKER |
63 | 63 |
64 #undef ENABLE_SEQUENCE_CHECKER | 64 #undef ENABLE_SEQUENCE_CHECKER |
65 | 65 |
66 } // namespace base | 66 } // namespace base |
67 | 67 |
68 #endif // BASE_SEQUENCE_CHECKER_H_ | 68 #endif // BASE_SEQUENCE_CHECKER_H_ |
OLD | NEW |