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

Unified Diff: content/child/indexed_db/indexed_db_dispatcher.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/child/indexed_db/indexed_db_dispatcher.cc
diff --git a/content/child/indexed_db/indexed_db_dispatcher.cc b/content/child/indexed_db/indexed_db_dispatcher.cc
index aa40cca350f2e8548188b939f202ec53a261f290..dc50cd0f6c670083c0bdfac23e31b3d083d11c76 100644
--- a/content/child/indexed_db/indexed_db_dispatcher.cc
+++ b/content/child/indexed_db/indexed_db_dispatcher.cc
@@ -30,6 +30,7 @@ using blink::WebIDBDatabaseCallbacks;
using blink::WebIDBDatabaseError;
using blink::WebIDBKey;
using blink::WebIDBMetadata;
+using blink::WebIDBObserver;
using blink::WebIDBValue;
using blink::WebString;
using blink::WebVector;
@@ -167,6 +168,42 @@ bool IndexedDBDispatcher::Send(IPC::Message* msg) {
return thread_safe_sender_->Send(msg);
}
+int32_t IndexedDBDispatcher::AddIDBObserver(int32_t ipc_database_id,
+ int64_t transaction_id,
+ WebIDBObserver* observer) {
+ // TODO(palakj): Do I wrap WebIDBObserver with unique_ptr as in
dmurph 2016/06/22 01:09:49 unique_ptr
+ // WebIDBCallbacks.
+ int32_t observer_id = observers_.Add(observer);
+ Send(new IndexedDBHostMsg_DatabaseObserve(ipc_database_id, transaction_id,
+ observer_id));
+ return observer_id;
+}
+
+std::vector<int32_t> IndexedDBDispatcher::RemoveIDBObservers(
+ int32_t ipc_database_id,
+ WebIDBObserver* observer,
+ std::vector<int32_t> database_observers_id) {
+ std::vector<int32_t> observersToRemove;
dmurph 2016/06/22 01:09:49 no camelCase
+ for (uint32_t i = 0; i < database_observers_id.size(); i++) {
+ WebIDBObserver* obs = observers_.Lookup(database_observers_id[i]);
+ if (obs == observer) {
+ observers_.Remove(database_observers_id[i]);
+ observersToRemove.push_back(database_observers_id[i]);
+ }
+ }
+
+ Send(new IndexedDBHostMsg_DatabaseUnobserve(ipc_database_id,
+ observersToRemove));
+ return observersToRemove;
+}
+
+void IndexedDBDispatcher::ClearIDBObserver(
dmurph 2016/06/22 01:09:49 I don't think this method needs to unobserve on th
+ std::vector<int32_t> observersToRemove) {
+ for (uint32_t i = 0; i < observersToRemove.size(); i++) {
+ observers_.Remove(observersToRemove[i]);
+ }
+}
+
void IndexedDBDispatcher::RequestIDBCursorAdvance(
unsigned long count,
WebIDBCallbacks* callbacks_ptr,

Powered by Google App Engine
This is Rietveld 408576698