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

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

Issue 2524823002: Reland: [IndexedDB] Delete callbacks state on worker thread exit. (Closed)
Patch Set: Rebased. 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 4189fdfed76e851e98dd279bc78241449d02b03e..26084c777bf20d039131865920dcfecead845f34 100644
--- a/content/child/indexed_db/indexed_db_dispatcher.cc
+++ b/content/child/indexed_db/indexed_db_dispatcher.cc
@@ -36,6 +36,10 @@ IndexedDBDispatcher::IndexedDBDispatcher() {
}
IndexedDBDispatcher::~IndexedDBDispatcher() {
+ in_destructor_ = true;
+ mojo_owned_callback_state_.clear();
+ mojo_owned_database_callback_state_.clear();
+
g_idb_dispatcher_tls.Pointer()->Set(kHasBeenDeleted);
}
@@ -98,24 +102,34 @@ void IndexedDBDispatcher::RemoveObservers(
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);
}
void IndexedDBDispatcher::OnDatabaseChanges(
« 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