fake_crash.cc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (c) 2022 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 "components/variations/fake_crash.h"
  5. #include "base/bind.h"
  6. #include "base/debug/dump_without_crashing.h"
  7. #include "base/feature_list.h"
  8. #include "base/logging.h"
  9. #include "base/task/thread_pool.h"
  10. #include "base/time/time.h"
  11. namespace {
  12. // This feature causes a crash report to be created after startup (without
  13. // actually crashing). This is used for verifying safety measures that help
  14. // catch features that cause real crashes.
  15. const base::Feature kVariationsFakeCrashAfterStartup{
  16. "VariationsFakeCrashAfterStartup", base::FEATURE_DISABLED_BY_DEFAULT};
  17. } // namespace
  18. namespace variations {
  19. void MaybeScheduleFakeCrash() {
  20. if (base::FeatureList::IsEnabled(kVariationsFakeCrashAfterStartup)) {
  21. base::ThreadPool::PostDelayedTask(
  22. FROM_HERE, base::BindOnce([]() {
  23. LOG(ERROR) << "Creating dump for VariationsFakeCrashAfterStartup";
  24. base::debug::DumpWithoutCrashing();
  25. }),
  26. base::Seconds(15));
  27. }
  28. }
  29. } // namespace variations