Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: third_party/WebKit/Source/modules/indexeddb/IDBDatabase.cpp

Issue 2601983002: [IndexedDB] Adding transaction and value support to observers (Closed)
Patch Set: added comments and bug link Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/indexeddb/IDBDatabase.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBDatabase.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBDatabase.cpp
index 2322a090ee6baff10b2218897c8fc50903d6d616..e674a3e27d61e05125b5935f809e65d6a7bd0f23 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBDatabase.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBDatabase.cpp
@@ -46,6 +46,7 @@
#include "public/platform/modules/indexeddb/WebIDBKeyPath.h"
#include "public/platform/modules/indexeddb/WebIDBTypes.h"
#include "wtf/Atomics.h"
+
#include <limits>
#include <memory>
@@ -53,6 +54,8 @@ using blink::WebIDBDatabase;
namespace blink {
+const char IDBDatabase::cannotObserveVersionChangeTransaction[] =
+ "An observer cannot target a version change transaction.";
const char IDBDatabase::indexDeletedErrorMessage[] =
"The index or its object store has been deleted.";
const char IDBDatabase::indexNameTakenErrorMessage[] =
@@ -177,14 +180,31 @@ void IDBDatabase::onComplete(int64_t transactionId) {
void IDBDatabase::onChanges(
const std::unordered_map<int32_t, std::vector<int32_t>>&
observation_index_map,
- const WebVector<WebIDBObservation>& observations) {
+ const WebVector<WebIDBObservation>& observations,
+ const IDBDatabaseCallbacks::TransactionMap& transactions) {
for (const auto& map_entry : observation_index_map) {
auto it = m_observers.find(map_entry.first);
if (it != m_observers.end()) {
IDBObserver* observer = it->value;
+
+ IDBTransaction* transaction = nullptr;
+ auto it = transactions.find(map_entry.first);
+ if (it != transactions.end()) {
+ const std::pair<int64_t, std::vector<int64_t>>& obs_txn = it->second;
+ HashSet<String> stores;
+ for (int64_t store_id : obs_txn.second) {
+ stores.add(m_metadata.objectStores.get(store_id)->name);
+ }
+
+ transaction = IDBTransaction::createObserver(
+ getExecutionContext(), obs_txn.first, stores, this);
+ }
+
observer->callback()->call(
- observer,
- IDBObserverChanges::create(this, observations, map_entry.second));
+ observer, IDBObserverChanges::create(this, transaction, observations,
+ map_entry.second));
+ if (transaction)
+ transaction->setActive(false);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698