Chromium Code Reviews| Index: content/browser/indexed_db/indexed_db_transaction.cc |
| diff --git a/content/browser/indexed_db/indexed_db_transaction.cc b/content/browser/indexed_db/indexed_db_transaction.cc |
| index 768cf1dc2f8a96929a372b0659c6a882821619f5..c08e82a4beea1907aca3647e46009ef39a30f818 100644 |
| --- a/content/browser/indexed_db/indexed_db_transaction.cc |
| +++ b/content/browser/indexed_db/indexed_db_transaction.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/bind.h" |
| #include "base/location.h" |
| #include "base/logging.h" |
| +#include "base/memory/ptr_util.h" |
| #include "base/single_thread_task_runner.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| @@ -14,6 +15,7 @@ |
| #include "content/browser/indexed_db/indexed_db_cursor.h" |
| #include "content/browser/indexed_db/indexed_db_database.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_tracing.h" |
| #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" |
| #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseException.h" |
| @@ -66,10 +68,9 @@ IndexedDBTransaction::Operation IndexedDBTransaction::TaskStack::pop() { |
| IndexedDBTransaction::IndexedDBTransaction( |
| int64_t id, |
| - scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, |
| + IndexedDBConnection* connection, |
|
dmurph
2016/06/30 00:14:06
Please change back to WeakPtr here, based on our c
palakj1
2016/06/30 01:07:04
Done.
|
| const std::set<int64_t>& object_store_ids, |
| blink::WebIDBTransactionMode mode, |
| - IndexedDBDatabase* database, |
| IndexedDBBackingStore::Transaction* backing_store_transaction) |
| : id_(id), |
| object_store_ids_(object_store_ids), |
| @@ -77,12 +78,14 @@ IndexedDBTransaction::IndexedDBTransaction( |
| used_(false), |
| state_(CREATED), |
| commit_pending_(false), |
| - callbacks_(callbacks), |
| - database_(database), |
| transaction_(backing_store_transaction), |
| backing_store_transaction_begun_(false), |
| should_process_queue_(false), |
| pending_preemptive_events_(0) { |
| + connection_ = connection->GetWeakPtr(); |
| + callbacks_ = connection_->callbacks(); |
| + database_ = connection_->database(); |
| + |
| database_->transaction_coordinator().DidCreateTransaction(this); |
| diagnostics_.tasks_scheduled = 0; |
| @@ -191,6 +194,7 @@ void IndexedDBTransaction::Abort(const IndexedDBDatabaseError& error) { |
| database_->TransactionFinished(this, false); |
| database_ = NULL; |
| + connection_ = nullptr; |
| } |
| bool IndexedDBTransaction::IsTaskQueueEmpty() const { |
| @@ -339,6 +343,9 @@ leveldb::Status IndexedDBTransaction::CommitPhaseTwo() { |
| database_->transaction_coordinator().DidFinishTransaction(this); |
| if (committed) { |
| + // TODO (palakj) : Send Observations to observers |
| + if (!pending_observers_.empty() && connection_) |
| + connection_->ActivatePendingObservers(std::move(pending_observers_)); |
| abort_task_stack_.clear(); |
| { |
| IDB_TRACE1( |
| @@ -445,4 +452,21 @@ void IndexedDBTransaction::CloseOpenCursors() { |
| open_cursors_.clear(); |
| } |
| +void IndexedDBTransaction::AddPendingObserver(int32_t observer_id) { |
| + pending_observers_.push_back( |
| + base::WrapUnique(new IndexedDBObserver(observer_id))); |
| +} |
| + |
| +void IndexedDBTransaction::RemovePendingObservers( |
| + const std::vector<int32_t>& pending_observer_ids) { |
| + for (size_t i = 0; i < pending_observer_ids.size(); i++) { |
| + for (size_t j = 0; j < pending_observers_.size(); j++) { |
| + if (pending_observers_[j]->id() == pending_observer_ids[i]) { |
| + pending_observers_.erase(pending_observers_.begin() + j); |
| + break; |
| + } |
| + } |
| + } |
| +} |
| + |
| } // namespace content |