error_delegate_util.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef SQL_ERROR_DELEGATE_UTIL_H_
  5. #define SQL_ERROR_DELEGATE_UTIL_H_
  6. #include <string>
  7. #include "base/component_export.h"
  8. namespace base {
  9. class FilePath;
  10. } // namespace base
  11. namespace sql {
  12. // Returns true if `sqlite_error_code` is caused by database corruption.
  13. //
  14. // This method returns true for SQLite error codes that can only be explained by
  15. // some form of corruption in the database's on-disk state. Retrying the failed
  16. // operation will result in the same error, until the on-disk state changes.
  17. // Callers should react to a true return value by deleting the database and
  18. // starting over, or by attempting to recover the data.
  19. //
  20. // Corruption is most often associated with storage media decay (aged disks),
  21. // but it can also be caused by bugs in the storage stack we're using (Chrome,
  22. // SQLite, the filesystem, the OS disk driver or disk firmware), or by some
  23. // other software that modifies the user's Chrome profile.
  24. COMPONENT_EXPORT(SQL) bool IsErrorCatastrophic(int sqlite_error_code);
  25. // Gets diagnostic info of the given |corrupted_file_path| that can be appended
  26. // to a corrupt database diagnostics info. The file info are not localized as
  27. // it's meant to be added to feedback reports and used by developers.
  28. // Also the full file path is not appended as it might contain some PII. Instead
  29. // only the last two components of the path are appended to distinguish between
  30. // default and user profiles.
  31. COMPONENT_EXPORT(SQL)
  32. std::string GetCorruptFileDiagnosticsInfo(
  33. const base::FilePath& corrupted_file_path);
  34. } // namespace sql
  35. #endif // SQL_ERROR_DELEGATE_UTIL_H_