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

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: 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
« no previous file with comments | « components/webdata/common/web_database_service.h ('k') | sql/connection.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e0dc1b9e22f39f3f7c5df4ff90deeb835714f283 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()) {
+ auto loaded_callback = loaded_callbacks_.back();
Daniel Erat 2016/08/09 21:05:41 same comment as below
afakhry 2016/08/09 21:36:17 Done.
+ 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.
+ auto error_callback = error_callbacks_.back();
Daniel Erat 2016/08/09 21:05:41 the c++ rules around auto and references seem arca
afakhry 2016/08/09 21:36:17 Yes, absolutely. Thanks! Done.
+ error_callbacks_.pop_back();
if (!error_callback.is_null())
error_callback.Run(status, diagnostics);
}
-
- error_callbacks_.clear();
}
}
« no previous file with comments | « components/webdata/common/web_database_service.h ('k') | sql/connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698