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

Unified Diff: components/webdata/common/web_database_backend.cc

Issue 2225333003: Recreate the WebData database on a catastrophic SQL error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: derat's comments Created 4 years, 4 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
Index: components/webdata/common/web_database_backend.cc
diff --git a/components/webdata/common/web_database_backend.cc b/components/webdata/common/web_database_backend.cc
index 1408bd2b9d8613ab61a2fbae136ff58bd7375a7e..cba430ab371ed6fc9bf196eeedf0db0f8938860c 100644
--- a/components/webdata/common/web_database_backend.cc
+++ b/components/webdata/common/web_database_backend.cc
@@ -59,7 +59,8 @@ sql::InitStatus WebDatabaseBackend::LoadDatabaseIfNecessary() {
if (init_status_ != sql::INIT_OK) {
LOG(ERROR) << "Cannot initialize the web database: " << init_status_;
diagnostics_ += sql::GetCorruptFileDiagnosticsInfo(db_path_);
- db_.reset();
+ if (!catastrophic_error_occurred_)
+ db_.reset();
return init_status_;
}
@@ -124,9 +125,22 @@ void WebDatabaseBackend::DatabaseErrorCallback(int error,
if (!catastrophic_error_occurred_ && sql::IsErrorCatastrophic(error)) {
catastrophic_error_occurred_ = true;
diagnostics_ = db_->GetDiagnosticInfo(error, statement);
+
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&WebDatabaseBackend::RazeAndCloseDatabase, this));
}
}
+void WebDatabaseBackend::RazeAndCloseDatabase() {
+ if (!db_)
+ return;
+
+ db_->GetSQLConnection()->RollbackAllTransactions();
+ db_->GetSQLConnection()->Raze();
+ db_.reset();
Scott Hess - ex-Googler 2016/08/10 17:16:19 These three lines are essentially identical to wha
afakhry 2016/08/11 17:32:54 Interesting. Thanks! Done.
+}
+
void WebDatabaseBackend::Commit() {
DCHECK(db_);
DCHECK_EQ(sql::INIT_OK, init_status_);

Powered by Google App Engine
This is Rietveld 408576698