[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef BASE_SEQUENCE_CHECKER_IMPL_H_ | ||||
6 | #define BASE_SEQUENCE_CHECKER_IMPL_H_ | ||||
7 | |||||
tzik | 0c2fcf5 | 2017-02-16 08:52:31 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 10 | #include "base/base_export.h" |
fdoray | eed5fa7 | 2016-07-26 22:28:45 | [diff] [blame] | 11 | #include "base/compiler_specific.h" |
avi | 9b6f4293 | 2015-12-26 22:15:14 | [diff] [blame] | 12 | #include "base/macros.h" |
[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 13 | #include "base/synchronization/lock.h" |
Aditya Keerthi | d2f44c7 | 2019-04-26 17:45:14 | [diff] [blame^] | 14 | #include "base/thread_annotations.h" |
[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 15 | |
16 | namespace base { | ||||
17 | |||||
fdoray | eed5fa7 | 2016-07-26 22:28:45 | [diff] [blame] | 18 | // Real implementation of SequenceChecker for use in debug mode or for temporary |
19 | // use in release mode (e.g. to CHECK on a threading issue seen only in the | ||||
20 | // wild). | ||||
21 | // | ||||
22 | // Note: You should almost always use the SequenceChecker class to get the right | ||||
23 | // version for your build configuration. | ||||
[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 24 | class BASE_EXPORT SequenceCheckerImpl { |
25 | public: | ||||
[email protected] | d52426c | 2013-07-30 19:26:40 | [diff] [blame] | 26 | SequenceCheckerImpl(); |
[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 27 | ~SequenceCheckerImpl(); |
28 | |||||
fdoray | eed5fa7 | 2016-07-26 22:28:45 | [diff] [blame] | 29 | // Returns true if called in sequence with previous calls to this method and |
30 | // the constructor. | ||||
fdoray | e2b19a1 | 2016-07-29 02:30:16 | [diff] [blame] | 31 | bool CalledOnValidSequence() const WARN_UNUSED_RESULT; |
[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 32 | |
fdoray | eed5fa7 | 2016-07-26 22:28:45 | [diff] [blame] | 33 | // Unbinds the checker from the currently associated sequence. The checker |
fdoray | e2b19a1 | 2016-07-29 02:30:16 | [diff] [blame] | 34 | // will be re-bound on the next call to CalledOnValidSequence(). |
[email protected] | d52426c | 2013-07-30 19:26:40 | [diff] [blame] | 35 | void DetachFromSequence(); |
[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 36 | |
37 | private: | ||||
tzik | 0c2fcf5 | 2017-02-16 08:52:31 | [diff] [blame] | 38 | class Core; |
[email protected] | d52426c | 2013-07-30 19:26:40 | [diff] [blame] | 39 | |
[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 40 | mutable Lock lock_; |
Aditya Keerthi | d2f44c7 | 2019-04-26 17:45:14 | [diff] [blame^] | 41 | mutable std::unique_ptr<Core> core_ GUARDED_BY(lock_); |
[email protected] | 399ed42 | 2012-12-27 19:58:00 | [diff] [blame] | 42 | |
43 | DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl); | ||||
44 | }; | ||||
45 | |||||
46 | } // namespace base | ||||
47 | |||||
48 | #endif // BASE_SEQUENCE_CHECKER_IMPL_H_ |