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 0c3cb35c010e67a465f12fd891998bff8441df93..0974a74cbba6971feff94261bbab4ee77b704178 100644 |
| --- a/content/browser/indexed_db/indexed_db_connection.cc |
| +++ b/content/browser/indexed_db/indexed_db_connection.cc |
| @@ -5,6 +5,9 @@ |
| #include "content/browser/indexed_db/indexed_db_connection.h" |
| #include "base/logging.h" |
| +#include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
| +#include "content/browser/indexed_db/indexed_db_observer.h" |
| +#include "content/browser/indexed_db/indexed_db_transaction.h" |
| namespace content { |
| @@ -15,9 +18,11 @@ static int32_t next_id; |
| } // namespace |
| IndexedDBConnection::IndexedDBConnection( |
| + int child_process_id, |
| scoped_refptr<IndexedDBDatabase> database, |
| scoped_refptr<IndexedDBDatabaseCallbacks> callbacks) |
| : id_(next_id++), |
| + child_process_id_(child_process_id), |
| database_(database), |
| callbacks_(callbacks), |
| weak_factory_(this) {} |
| @@ -85,8 +90,54 @@ void IndexedDBConnection::RemoveObservers( |
| else |
| pending_observer_ids.push_back(id_to_remove); |
| } |
| - if (!pending_observer_ids.empty()) |
| - database_->RemovePendingObservers(this, pending_observer_ids); |
| + if (pending_observer_ids.empty()) |
| + return; |
| + |
| + for (const auto& it : transactions_) { |
| + it.second->RemovePendingObservers(pending_observer_ids); |
| + } |
| +} |
| + |
| +IndexedDBTransaction* IndexedDBConnection::CreateTransaction( |
| + int64_t id, |
| + const std::set<int64_t>& scope, |
| + blink::WebIDBTransactionMode mode, |
| + IndexedDBBackingStore::Transaction* backing_store_transaction) { |
| + DCHECK_EQ(GetTransaction(id), nullptr); |
| + std::unique_ptr<IndexedDBTransaction> transaction = |
| + base::MakeUnique<IndexedDBTransaction>(id, this, scope, mode, |
| + backing_store_transaction); |
| + IndexedDBTransaction* transaction_ptr = transaction.get(); |
| + transactions_[id] = std::move(transaction); |
| + return transaction_ptr; |
| +} |
| + |
| +IndexedDBTransaction* IndexedDBConnection::GetTransaction(int64_t id) { |
| + auto it = transactions_.find(id); |
| + if (it == transactions_.end()) |
| + return nullptr; |
| + return it->second.get(); |
| +} |
| + |
| +IndexedDBTransaction* IndexedDBConnection::StoreTransactionForTesting( |
| + std::unique_ptr<IndexedDBTransaction> transaction) { |
| + DCHECK(transactions_.find(transaction->id()) == transactions_.end()); |
|
jsbell
2016/11/04 17:48:19
base::ContainsKey
dmurph
2016/11/04 22:52:24
Done.
|
| + IndexedDBTransaction* transaction_ptr = transaction.get(); |
| + transactions_[transaction->id()] = std::move(transaction); |
| + return transaction_ptr; |
| +} |
| + |
| +void IndexedDBConnection::EraseTransaction(int64_t id) { |
| + transactions_.erase(id); |
| +} |
| + |
| +void IndexedDBConnection::AbortAllTransactions( |
| + const IndexedDBDatabaseError& error) { |
| + std::unordered_map<int64_t, std::unique_ptr<IndexedDBTransaction>> temp_map; |
|
cmumford
2016/11/04 23:33:12
Couldn't you also do this?
const auto temp_map
dmurph
2016/11/07 20:05:22
I could, but that leaves transactions_ in a techni
|
| + std::swap(temp_map, transactions_); |
| + for (const auto& pair : temp_map) { |
| + pair.second->Abort(error); |
| + } |
| } |
| } // namespace content |