Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/webdata/common/web_database_service.h" | 5 #include "components/webdata/common/web_database_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 void WebDatabaseService::RegisterDBErrorCallback( | 130 void WebDatabaseService::RegisterDBErrorCallback( |
| 131 const DBLoadErrorCallback& callback) { | 131 const DBLoadErrorCallback& callback) { |
| 132 error_callbacks_.push_back(callback); | 132 error_callbacks_.push_back(callback); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void WebDatabaseService::OnDatabaseLoadDone(sql::InitStatus status, | 135 void WebDatabaseService::OnDatabaseLoadDone(sql::InitStatus status, |
| 136 const std::string& diagnostics) { | 136 const std::string& diagnostics) { |
| 137 if (status == sql::INIT_OK) { | 137 if (status == sql::INIT_OK) { |
| 138 db_loaded_ = true; | 138 db_loaded_ = true; |
| 139 | 139 |
| 140 for (const auto& loaded_callback : loaded_callbacks_) { | 140 while (!loaded_callbacks_.empty()) { |
| 141 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.
| |
| 142 loaded_callbacks_.pop_back(); | |
| 141 if (!loaded_callback.is_null()) | 143 if (!loaded_callback.is_null()) |
| 142 loaded_callback.Run(); | 144 loaded_callback.Run(); |
| 143 } | 145 } |
| 144 | |
| 145 loaded_callbacks_.clear(); | |
| 146 } else { | 146 } else { |
| 147 // Notify that the database load failed. | 147 // Notify that the database load failed. |
| 148 for (const auto& error_callback : error_callbacks_) { | 148 while (!error_callbacks_.empty()) { |
| 149 // The profile error callback is a message box that runs in a nested run | |
| 150 // loop. While it's being displayed, other OnDatabaseLoadDone() will run | |
| 151 // (posted from WebDatabaseBackend::Delegate::DBLoaded()). We need to make | |
| 152 // sure that after the callback running the message box returns, it checks | |
| 153 // |error_callbacks_| before it accesses it. | |
| 154 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.
| |
| 155 error_callbacks_.pop_back(); | |
| 149 if (!error_callback.is_null()) | 156 if (!error_callback.is_null()) |
| 150 error_callback.Run(status, diagnostics); | 157 error_callback.Run(status, diagnostics); |
| 151 } | 158 } |
| 152 | |
| 153 error_callbacks_.clear(); | |
| 154 } | 159 } |
| 155 } | 160 } |
| OLD | NEW |