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

Unified Diff: components/webdata/common/web_database_service.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_service.cc
diff --git a/components/webdata/common/web_database_service.cc b/components/webdata/common/web_database_service.cc
index a5ed8633b2f705ba2a83c7c2f73b87591a3a2b4f..203bb7a3b4a8b425fb45821dfbcaed167e09d997 100644
--- a/components/webdata/common/web_database_service.cc
+++ b/components/webdata/common/web_database_service.cc
@@ -137,19 +137,24 @@ void WebDatabaseService::OnDatabaseLoadDone(sql::InitStatus status,
if (status == sql::INIT_OK) {
db_loaded_ = true;
- for (const auto& loaded_callback : loaded_callbacks_) {
+ while (!loaded_callbacks_.empty()) {
+ DBLoadedCallback loaded_callback = loaded_callbacks_.back();
+ loaded_callbacks_.pop_back();
if (!loaded_callback.is_null())
loaded_callback.Run();
}
-
- loaded_callbacks_.clear();
} else {
// Notify that the database load failed.
- for (const auto& error_callback : error_callbacks_) {
+ while (!error_callbacks_.empty()) {
+ // The profile error callback is a message box that runs in a nested run
+ // loop. While it's being displayed, other OnDatabaseLoadDone() will run
+ // (posted from WebDatabaseBackend::Delegate::DBLoaded()). We need to make
+ // sure that after the callback running the message box returns, it checks
+ // |error_callbacks_| before it accesses it.
Scott Hess - ex-Googler 2016/08/10 17:16:19 If I understand this correctly, another option mig
afakhry 2016/08/11 17:32:54 This works too, but it exposes a problem that was
+ DBLoadErrorCallback error_callback = error_callbacks_.back();
+ error_callbacks_.pop_back();
if (!error_callback.is_null())
error_callback.Run(status, diagnostics);
}
-
- error_callbacks_.clear();
}
}

Powered by Google App Engine
This is Rietveld 408576698