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