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