report_unrecoverable_error.cc 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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. #include "components/sync/base/report_unrecoverable_error.h"
  5. #include "base/debug/dump_without_crashing.h"
  6. #include "base/rand_util.h"
  7. namespace syncer {
  8. void ReportUnrecoverableError(version_info::Channel channel) {
  9. // Only upload on canary/dev builds to avoid overwhelming crash server.
  10. if (channel != version_info::Channel::CANARY &&
  11. channel != version_info::Channel::DEV) {
  12. return;
  13. }
  14. // We only want to upload |kErrorUploadRatio| ratio of errors.
  15. // Note: crash reporting is disabled, and should only be enabled when
  16. // investigating a specific datatype error. In that event, a specific bug
  17. // should be referenced here.
  18. const double kErrorUploadRatio = 0.00;
  19. if (kErrorUploadRatio <= 0.0)
  20. return; // We are not allowed to upload errors.
  21. double random_number = base::RandDouble();
  22. if (random_number > kErrorUploadRatio)
  23. return;
  24. base::debug::DumpWithoutCrashing();
  25. }
  26. } // namespace syncer