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

Unified Diff: content/browser/indexed_db/indexed_db_database.cc

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unobserve functionality Created 4 years, 6 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: content/browser/indexed_db/indexed_db_database.cc
diff --git a/content/browser/indexed_db/indexed_db_database.cc b/content/browser/indexed_db/indexed_db_database.cc
index f2212d3083d49677da5b802dcb2993bd3fc60cb9..60fbd2afc0513974e10bf08d60501d77e1f74966 100644
--- a/content/browser/indexed_db/indexed_db_database.cc
+++ b/content/browser/indexed_db/indexed_db_database.cc
@@ -546,8 +546,19 @@ void IndexedDBDatabase::Observe(int64_t transaction_id, int64_t observer_id) {
IndexedDBTransaction* transaction = GetTransaction(transaction_id);
if (!transaction)
return;
- transaction->AddPendingObserver(
- base::WrapUnique(new IndexedDBObserver(observer_id)));
+ transaction->AddPendingObserver(observer_id,
+ new IndexedDBObserver(observer_id));
+}
+
+void IndexedDBDatabase::Unobserve(std::vector<int64_t> observersToRemove) {
+ // TODO (palakj): Remove observer from pending_observer queue of transactions
+ typedef std::map<int64_t, IndexedDBObserver*>::iterator Iterator;
+ for (uint32_t i = 0; i < observersToRemove.size(); i++) {
+ Iterator obs = active_observers_.find(observersToRemove[i]);
+ if (obs != active_observers_.end()) {
+ active_observers_.erase(obs);
dmurph 2016/06/16 07:30:33 I believe you can just do active_observers_.erase(
palakj1 2016/06/16 17:51:41 Done
palakj1 2016/06/16 17:51:41 Done
+ }
+ }
}
void IndexedDBDatabase::GetAll(int64_t transaction_id,

Powered by Google App Engine
This is Rietveld 408576698