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

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

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Observer moved to connection 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_connection.cc
diff --git a/content/browser/indexed_db/indexed_db_connection.cc b/content/browser/indexed_db/indexed_db_connection.cc
index f7133a69230da18b88b9deb75e84775823d9467e..400ad570668ca5fd9bdfab08cad534d51090b914 100644
--- a/content/browser/indexed_db/indexed_db_connection.cc
+++ b/content/browser/indexed_db/indexed_db_connection.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "content/browser/indexed_db/indexed_db_connection.h"
+#include "content/browser/indexed_db/indexed_db_observer.h"
namespace content {
@@ -21,6 +22,8 @@ void IndexedDBConnection::Close() {
if (this_obj) {
database_ = nullptr;
callbacks_ = nullptr;
+ // Is this needed?
dmurph 2016/06/22 01:09:48 Yes, this makes sense here.
+ active_observers_.clear();
}
}
@@ -35,6 +38,8 @@ void IndexedDBConnection::ForceClose() {
if (this_obj) {
database_ = nullptr;
callbacks_ = nullptr;
+ // TODO(palakj):Is this needed?
dmurph 2016/06/22 01:09:48 Yes, looks good.
+ active_observers_.clear();
}
callbacks->OnForcedClose();
}
@@ -49,4 +54,16 @@ bool IndexedDBConnection::IsConnected() {
return database_.get() != NULL;
}
+void IndexedDBConnection::Unobserve(std::vector<int32_t> observersToRemove) {
+ for (uint32_t i = 0; i < observersToRemove.size(); i++) {
+ for (uint32_t j = 0; j < active_observers_.size(); j++) {
+ if (active_observers_[j]->id() == observersToRemove[i])
+ active_observers_.erase(active_observers_.begin() + j);
+ observersToRemove.erase(observersToRemove.begin() + i);
dmurph 2016/06/22 01:09:49 ? Dont need this line, it breaks your algorithm.
+ }
+ }
+ if (!observersToRemove.empty())
+ database_->RemovePendingObservers(this, observersToRemove);
dmurph 2016/06/22 01:09:48 Hm, I see what you're doing here. Let's create a n
palakj1 2016/06/23 20:56:29 I get your point. And the observersToRemove should
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698