Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2021 The Chromium Authors |
Lei Zhang | b9e7c4b | 2021-12-21 17:56:05 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "base/sequence_checker.h" |
| 6 | |
| 7 | #if DCHECK_IS_ON() |
| 8 | #include <memory> |
| 9 | #include <ostream> |
| 10 | |
| 11 | #include "base/check.h" |
| 12 | #include "base/debug/stack_trace.h" |
| 13 | #endif |
| 14 | |
| 15 | namespace base { |
| 16 | |
| 17 | #if DCHECK_IS_ON() |
| 18 | ScopedValidateSequenceChecker::ScopedValidateSequenceChecker( |
| 19 | const SequenceChecker& checker) { |
| 20 | std::unique_ptr<debug::StackTrace> bound_at; |
| 21 | DCHECK(checker.CalledOnValidSequence(&bound_at)) |
| 22 | << (bound_at ? "\nWas attached to sequence at:\n" + bound_at->ToString() |
| 23 | : ""); |
| 24 | } |
| 25 | |
| 26 | ScopedValidateSequenceChecker::~ScopedValidateSequenceChecker() = default; |
| 27 | #endif // DCHECK_IS_ON() |
| 28 | |
| 29 | } // namespace base |