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

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

Issue 2125213002: [IndexedDB] Propogating changes to observers : Renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lifetime
Patch Set: IDBDatabase weakptr introduced on IDBObserver Created 4 years, 5 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/IDBObserver.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp
index db4a1ea7763e34fa39c8f7a7bf1e0167f75c5878..dbcbaad670c4d9b6f2779b8ca414632de5a3e20f 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp
@@ -10,6 +10,7 @@
#include "core/dom/ExceptionCode.h"
#include "modules/indexeddb/IDBDatabase.h"
#include "modules/indexeddb/IDBObserverCallback.h"
+#include "modules/indexeddb/IDBObserverChanges.h"
#include "modules/indexeddb/IDBObserverInit.h"
#include "modules/indexeddb/IDBTransaction.h"
#include "modules/indexeddb/WebIDBObserverImpl.h"
@@ -49,7 +50,7 @@ void IDBObserver::observe(IDBDatabase* database, IDBTransaction* transaction, Ex
std::unique_ptr<WebIDBObserverImpl> observer = WebIDBObserverImpl::create(this);
WebIDBObserverImpl* observerPtr = observer.get();
int32_t observerId = database->backend()->addObserver(std::move(observer), transaction->id());
- m_observerIds.insert(observerId);
+ m_observerIds[observerId] = database;
observerPtr->setId(observerId);
}
@@ -62,8 +63,8 @@ void IDBObserver::unobserve(IDBDatabase* database, ExceptionState& exceptionStat
auto it = m_observerIds.begin();
std::vector<int32_t> observerIdsToRemove;
while (it != m_observerIds.end()) {
- if (database->backend()->containsObserverId(*it)) {
- observerIdsToRemove.push_back(*it);
+ if (it->second == database) {
+ observerIdsToRemove.push_back(it->first);
it = m_observerIds.erase(it);
} else {
it++;
@@ -78,6 +79,11 @@ void IDBObserver::removeObserver(int32_t id)
m_observerIds.erase(id);
}
+void IDBObserver::onChange(int32_t id, const std::vector<WebIDBObservation>& observations, const std::vector<int32_t>& observationIndex)
+{
+ m_callback->handleEvent(*IDBObserverChanges::create(m_observerIds[id], observations, observationIndex), *this);
+}
+
DEFINE_TRACE(IDBObserver)
{
visitor->trace(m_callback);

Powered by Google App Engine
This is Rietveld 408576698