Chromium Code Reviews| Index: content/browser/indexed_db/indexed_db_database.cc |
| diff --git a/content/browser/indexed_db/indexed_db_database.cc b/content/browser/indexed_db/indexed_db_database.cc |
| index 97f47a04d14cd726d5f86b16f2b6c7a9502a7995..a9e9f41da023e767da2f62996966de6c614a8122 100644 |
| --- a/content/browser/indexed_db/indexed_db_database.cc |
| +++ b/content/browser/indexed_db/indexed_db_database.cc |
| @@ -29,6 +29,7 @@ |
| #include "content/browser/indexed_db/indexed_db_cursor.h" |
| #include "content/browser/indexed_db/indexed_db_factory.h" |
| #include "content/browser/indexed_db/indexed_db_index_writer.h" |
| +#include "content/browser/indexed_db/indexed_db_observer.h" |
| #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
| #include "content/browser/indexed_db/indexed_db_return_value.h" |
| #include "content/browser/indexed_db/indexed_db_tracing.h" |
| @@ -541,6 +542,39 @@ void IndexedDBDatabase::Abort(int64_t transaction_id, |
| transaction->Abort(error); |
| } |
| +void IndexedDBDatabase::Observe(int64_t transaction_id, int64_t observer_id) { |
| + IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| + if (!transaction) |
| + return; |
| + transaction->AddPendingObserver( |
| + base::WrapUnique(new IndexedDBObserver(observer_id))); |
| +} |
| + |
| +void IndexedDBDatabase::RemovePendingObservers( |
| + IndexedDBConnection* connection, |
| + std::vector<int32_t> observersToRemove) { |
| + // TODO(palakj): Better Implementation needed. |
| + TransactionMap::iterator trans_iter; |
| + for (trans_iter = transactions_.begin(); |
| + trans_iter != transactions_.end() && !observersToRemove.empty(); |
| + trans_iter++) { |
| + IndexedDBTransaction* transaction = trans_iter->second; |
| + if (transaction->getConnection() == connection) { |
| + // Do I move this logic to transaction. |
|
dmurph
2016/06/22 01:09:49
Sure, it might make a little more sense.
palakj1
2016/06/23 20:56:29
Done
|
| + for (uint32_t k = 0; k < transaction->pending_observers_.size(); k++) { |
| + std::vector<int>::iterator it = |
| + std::find(observersToRemove.begin(), observersToRemove.end(), |
|
dmurph
2016/06/22 01:09:49
why not just observersToRemove.find? Also, remove
palakj1
2016/06/23 20:56:29
Does a vector have find function?
|
| + transaction->pending_observers_[k]->id()); |
| + if (it != observersToRemove.end()) { |
| + transaction->pending_observers_.erase( |
| + transaction->pending_observers_.begin() + k); |
| + observersToRemove.erase(it); |
| + } |
| + } |
| + } |
| + } |
| +} |
| + |
| void IndexedDBDatabase::GetAll(int64_t transaction_id, |
| int64_t object_store_id, |
| int64_t index_id, |
| @@ -1665,7 +1699,7 @@ void IndexedDBDatabase::CreateTransaction( |
| // The transaction will add itself to this database's coordinator, which |
| // manages the lifetime of the object. |
| TransactionCreated(IndexedDBClassFactory::Get()->CreateIndexedDBTransaction( |
| - transaction_id, connection->callbacks(), |
| + transaction_id, connection, connection->callbacks(), |
| std::set<int64_t>(object_store_ids.begin(), object_store_ids.end()), mode, |
| this, new IndexedDBBackingStore::Transaction(backing_store_.get()))); |
| } |