| 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/compiler_specific.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/sequence_checker_impl.h" | 10 #include "base/sequence_checker_impl.h" |
| 10 | 11 |
| 11 // SequenceChecker is a helper class used to help verify that some methods of a | 12 // SequenceChecker is a helper class used to help verify that some methods of a |
| 12 // class are called sequentially (for thread-safety). | 13 // class are called sequentially (for thread-safety). |
| 13 // | 14 // |
| 14 // Use the macros below instead of the SequenceChecker directly so that the | 15 // Use the macros below instead of the SequenceChecker directly so that the |
| 15 // unused member doesn't result in an extra byte (four when padded) per | 16 // unused member doesn't result in an extra byte (four when padded) per |
| 16 // instance in production. | 17 // instance in production. |
| 17 // | 18 // |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #endif // DCHECK_IS_ON() | 60 #endif // DCHECK_IS_ON() |
| 60 | 61 |
| 61 namespace base { | 62 namespace base { |
| 62 | 63 |
| 63 // Do nothing implementation, for use in release mode. | 64 // Do nothing implementation, for use in release mode. |
| 64 // | 65 // |
| 65 // Note: You should almost always use the SequenceChecker class (through the | 66 // Note: You should almost always use the SequenceChecker class (through the |
| 66 // above macros) to get the right version for your build configuration. | 67 // above macros) to get the right version for your build configuration. |
| 67 class SequenceCheckerDoNothing { | 68 class SequenceCheckerDoNothing { |
| 68 public: | 69 public: |
| 69 bool CalledOnValidSequence() const { return true; } | 70 bool CalledOnValidSequence() const WARN_UNUSED_RESULT { return true; } |
| 70 | 71 |
| 71 void DetachFromSequence() {} | 72 void DetachFromSequence() {} |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 #if DCHECK_IS_ON() | 75 #if DCHECK_IS_ON() |
| 75 class SequenceChecker : public SequenceCheckerImpl { | 76 class SequenceChecker : public SequenceCheckerImpl { |
| 76 }; | 77 }; |
| 77 #else | 78 #else |
| 78 class SequenceChecker : public SequenceCheckerDoNothing { | 79 class SequenceChecker : public SequenceCheckerDoNothing { |
| 79 }; | 80 }; |
| 80 #endif // DCHECK_IS_ON() | 81 #endif // DCHECK_IS_ON() |
| 81 | 82 |
| 82 } // namespace base | 83 } // namespace base |
| 83 | 84 |
| 84 #endif // BASE_SEQUENCE_CHECKER_H_ | 85 #endif // BASE_SEQUENCE_CHECKER_H_ |
| OLD | NEW |