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

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

Issue 2526913002: Reland: [IndexedDB] Delete callbacks state on worker thread exit. (Closed)
Patch Set: Created 4 years, 1 month 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/indexed_db_dispatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 aafd24419d65f749c47d08f81e01134920406d48..f4da66328242b34be6526c9f4350d87482e3904e 100644
--- a/content/child/indexed_db/indexed_db_dispatcher.cc
+++ b/content/child/indexed_db/indexed_db_dispatcher.cc
@@ -61,6 +61,10 @@ IndexedDBDispatcher::~IndexedDBDispatcher() {
DCHECK(pending_callbacks_.IsEmpty());
+ in_destructor_ = true;
+ mojo_owned_callback_state_.clear();
+ mojo_owned_database_callback_state_.clear();
+
g_idb_dispatcher_tls.Pointer()->Set(kHasBeenDeleted);
}
@@ -196,24 +200,34 @@ void IndexedDBDispatcher::CursorDestroyed(int32_t ipc_cursor_id) {
void IndexedDBDispatcher::RegisterMojoOwnedCallbacks(
IndexedDBCallbacksImpl::InternalState* callbacks) {
- mojo_owned_callback_state_.insert(callbacks);
+ mojo_owned_callback_state_[callbacks] = base::WrapUnique(callbacks);
}
void IndexedDBDispatcher::UnregisterMojoOwnedCallbacks(
IndexedDBCallbacksImpl::InternalState* callbacks) {
- DCHECK(base::ContainsValue(mojo_owned_callback_state_, callbacks));
- mojo_owned_callback_state_.erase(callbacks);
+ if (in_destructor_)
+ return;
+
+ auto it = mojo_owned_callback_state_.find(callbacks);
+ DCHECK(it != mojo_owned_callback_state_.end());
+ it->second.release();
+ mojo_owned_callback_state_.erase(it);
}
void IndexedDBDispatcher::RegisterMojoOwnedDatabaseCallbacks(
blink::WebIDBDatabaseCallbacks* callbacks) {
- mojo_owned_database_callback_state_.insert(callbacks);
+ mojo_owned_database_callback_state_[callbacks] = base::WrapUnique(callbacks);
}
void IndexedDBDispatcher::UnregisterMojoOwnedDatabaseCallbacks(
blink::WebIDBDatabaseCallbacks* callbacks) {
- DCHECK(base::ContainsValue(mojo_owned_database_callback_state_, callbacks));
- mojo_owned_database_callback_state_.erase(callbacks);
+ if (in_destructor_)
+ return;
+
+ auto it = mojo_owned_database_callback_state_.find(callbacks);
+ DCHECK(it != mojo_owned_database_callback_state_.end());
+ it->second.release();
+ mojo_owned_database_callback_state_.erase(it);
}
// Populate some WebIDBValue members (data & blob info) from the supplied
« no previous file with comments | « content/child/indexed_db/indexed_db_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698