Chromium Code Reviews| Index: content/browser/indexed_db/indexed_db_connection.cc |
| diff --git a/content/browser/indexed_db/indexed_db_connection.cc b/content/browser/indexed_db/indexed_db_connection.cc |
| index f7133a69230da18b88b9deb75e84775823d9467e..a32af1a3618e43b04c79c595b6fd21a4c0e090ad 100644 |
| --- a/content/browser/indexed_db/indexed_db_connection.cc |
| +++ b/content/browser/indexed_db/indexed_db_connection.cc |
| @@ -21,6 +21,7 @@ void IndexedDBConnection::Close() { |
| if (this_obj) { |
| database_ = nullptr; |
| callbacks_ = nullptr; |
| + active_observers_.clear(); |
| } |
| } |
| @@ -35,6 +36,7 @@ void IndexedDBConnection::ForceClose() { |
| if (this_obj) { |
| database_ = nullptr; |
| callbacks_ = nullptr; |
| + active_observers_.clear(); |
| } |
| callbacks->OnForcedClose(); |
| } |
| @@ -49,4 +51,35 @@ bool IndexedDBConnection::IsConnected() { |
| return database_.get() != NULL; |
| } |
| +void IndexedDBConnection::ActivatePendingObservers( |
| + std::vector<std::unique_ptr<IndexedDBObserver>>* pending_observers) { |
| + for (uint32_t i = 0; i < pending_observers->size(); i++) { |
| + active_observers_.emplace_back(std::move(pending_observers->at(i))); |
|
dmurph
2016/06/23 21:53:04
I believe we just want push_back here. emplace_bac
palakj1
2016/06/24 00:03:00
Changed.
|
| + } |
| +} |
| + |
| +void IndexedDBConnection::RemoveObservers( |
| + const std::vector<int32_t>& remove_observer_ids) { |
| + // TODO(palakj): Change from vector to set or create tmp vector instead of |
| + // erase. |
| + std::vector<int32_t> pending_observer_ids; |
| + for (uint32_t i = 0; i < remove_observer_ids.size(); i++) { |
| + bool removed = false; |
| + for (uint32_t j = 0; j < active_observers_.size(); j++) { |
| + if (active_observers_[j]->id() == remove_observer_ids[i]) { |
| + active_observers_.erase(active_observers_.begin() + j); |
|
dmurph
2016/06/23 21:53:04
In order for us to be able to erase while iteratin
palakj1
2016/06/24 00:03:00
After each erase, we break. So the state of iterat
|
| + removed = true; |
| + break; |
| + } |
| + } |
| + // If observer not in active_observers_ , must be in pending_observer list |
| + // of one of the transactions. |
| + if (!removed) |
| + pending_observer_ids.push_back(remove_observer_ids[i]); |
| + } |
| + |
| + if (!pending_observer_ids.empty()) |
| + database_->RemovePendingObservers(this, pending_observer_ids); |
| +} |
| + |
| } // namespace content |