Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: sql/recovery.h

Issue 2727553006: [sql] Convert thumbnails and top-sites databases to auto-recovery. (Closed)
Patch Set: tests and review comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/history/core/browser/top_sites_database_unittest.cc ('k') | sql/recovery.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/recovery.h
diff --git a/sql/recovery.h b/sql/recovery.h
index efc69cbc837ff3f49ddddee3ba1cc2a9eecc1c45..e5e4abf8608f89bdb8f43f55c55e19aec5bcfe0c 100644
--- a/sql/recovery.h
+++ b/sql/recovery.h
@@ -156,18 +156,28 @@ class SQL_EXPORT Recovery {
bool GetMetaVersionNumber(int* version_number);
// Attempt to recover the database by creating a new database with schema from
- // |db|, then copying over as much data as possible. After this call, the
- // |db| handle will be poisoned (though technically remaining open) so that
- // future calls will return errors until the handle is re-opened.
- //
- // If a corrupt database contains tables without unique indices, the resulting
- // table may contain duplication. If this is not acceptable, the client
- // should use the manual process as described in the example at the top of the
- // file, cleaning up data at the appropriate points.
+ // |db|, then copying over as much data as possible. If successful, the
+ // recovery handle is returned to allow the caller to make additional changes,
+ // such as validating constraints not expressed in the schema.
//
// In case of SQLITE_NOTADB, the database is deemed unrecoverable and deleted.
+ static std::unique_ptr<Recovery> BeginRecoverDatabase(
+ Connection* db,
+ const base::FilePath& db_path) WARN_UNUSED_RESULT;
+
+ // Call BeginRecoverDatabase() to recover the database, then commit the
+ // changes using Recovered(). After this call, the |db| handle will be
+ // poisoned (though technically remaining open) so that future calls will
+ // return errors until the handle is re-opened.
static void RecoverDatabase(Connection* db, const base::FilePath& db_path);
+ // Variant on RecoverDatabase() which requires that the database have a valid
+ // meta table with a version value. The meta version value is used by some
+ // clients to make assertions about the database schema. If this information
+ // cannot be determined, the database is considered unrecoverable.
+ static void RecoverDatabaseWithMetaVersion(Connection* db,
+ const base::FilePath& db_path);
+
// Returns true for SQLite errors which RecoverDatabase() can plausibly fix.
// This does not guarantee that RecoverDatabase() will successfully recover
// the database.
« no previous file with comments | « components/history/core/browser/top_sites_database_unittest.cc ('k') | sql/recovery.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698