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

Unified Diff: content/child/indexed_db/webidbdatabase_impl.cc

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final architechture 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
« no previous file with comments | « content/child/indexed_db/webidbdatabase_impl.h ('k') | content/common/indexed_db/indexed_db_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/indexed_db/webidbdatabase_impl.cc
diff --git a/content/child/indexed_db/webidbdatabase_impl.cc b/content/child/indexed_db/webidbdatabase_impl.cc
index fedb0e7333974ecdce6127249739b0b4ea4ccdae..1895b5aff3b5ce6392a2da29a7175dd259e85a52 100644
--- a/content/child/indexed_db/webidbdatabase_impl.cc
+++ b/content/child/indexed_db/webidbdatabase_impl.cc
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
+#include "base/stl_util.h"
#include "content/child/indexed_db/indexed_db_dispatcher.h"
#include "content/child/indexed_db/indexed_db_key_builders.h"
#include "content/child/thread_safe_sender.h"
@@ -29,6 +30,7 @@ using blink::WebIDBMetadata;
using blink::WebIDBKey;
using blink::WebIDBKeyPath;
using blink::WebIDBKeyRange;
+using blink::WebIDBObserver;
using blink::WebString;
using blink::WebVector;
@@ -90,6 +92,7 @@ void WebIDBDatabaseImpl::createTransaction(
void WebIDBDatabaseImpl::close() {
IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
+ dispatcher->RemoveIDBObservers(observer_ids_);
dispatcher->RequestIDBDatabaseClose(ipc_database_id_,
ipc_database_callbacks_id_);
}
@@ -100,6 +103,33 @@ void WebIDBDatabaseImpl::versionChangeIgnored() {
dispatcher->NotifyIDBDatabaseVersionChangeIgnored(ipc_database_id_);
}
+int32_t WebIDBDatabaseImpl::addObserver(
+ std::unique_ptr<WebIDBObserver> observer,
+ long long transaction_id) {
+ IndexedDBDispatcher* dispatcher =
+ IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
+
+ int32_t observer_id = dispatcher->AddIDBObserver(
+ ipc_database_id_, transaction_id, std::move(observer));
+ observer_ids_.insert(observer_id);
+ return observer_id;
+}
+
+bool WebIDBDatabaseImpl::containsObserverId(int32_t id) const {
+ return ContainsValue(observer_ids_, id);
+}
+
+void WebIDBDatabaseImpl::removeObservers(
+ const std::vector<int32_t>& observer_ids_to_remove) {
+ for (int32_t id : observer_ids_to_remove)
+ observer_ids_.erase(id);
+
+ IndexedDBDispatcher* dispatcher =
+ IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
+ dispatcher->RemoveIDBObserversFromDatabase(ipc_database_id_,
+ observer_ids_to_remove);
+}
+
void WebIDBDatabaseImpl::get(long long transaction_id,
long long object_store_id,
long long index_id,
« no previous file with comments | « content/child/indexed_db/webidbdatabase_impl.h ('k') | content/common/indexed_db/indexed_db_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698