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_); |