Chromium Code Reviews| 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(); |
| } |
| } |