sequence_checker.cc 793 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2021 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. #include "base/sequence_checker.h"
  5. #if DCHECK_IS_ON()
  6. #include <memory>
  7. #include <ostream>
  8. #include "base/check.h"
  9. #include "base/debug/stack_trace.h"
  10. #endif
  11. namespace base {
  12. #if DCHECK_IS_ON()
  13. ScopedValidateSequenceChecker::ScopedValidateSequenceChecker(
  14. const SequenceChecker& checker) {
  15. std::unique_ptr<debug::StackTrace> bound_at;
  16. DCHECK(checker.CalledOnValidSequence(&bound_at))
  17. << (bound_at ? "\nWas attached to sequence at:\n" + bound_at->ToString()
  18. : "");
  19. }
  20. ScopedValidateSequenceChecker::~ScopedValidateSequenceChecker() = default;
  21. #endif // DCHECK_IS_ON()
  22. } // namespace base