1 // Copyright 2021 The Chromium Authors 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() ScopedValidateSequenceChecker(const SequenceChecker & checker)18ScopedValidateSequenceChecker::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 30