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

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

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 | « no previous file | content/child/indexed_db/indexed_db_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/indexed_db/indexed_db_dispatcher.h
diff --git a/content/child/indexed_db/indexed_db_dispatcher.h b/content/child/indexed_db/indexed_db_dispatcher.h
index 3d75d37bc6dc1ba54beb815020c0774b9306c01e..6b3f3db73b2da327cfd6ef2725d41f9e31f4c62d 100644
--- a/content/child/indexed_db/indexed_db_dispatcher.h
+++ b/content/child/indexed_db/indexed_db_dispatcher.h
@@ -127,6 +127,16 @@ class CONTENT_EXPORT IndexedDBDispatcher : public WorkerThread::Observer {
FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset);
FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId);
+ // Looking up move-only entries in an std::unordered_set and removing them
+ // with out freeing them seems to be impossible so use a map instead so that
+ // the key type can remain a raw pointer.
+ using CallbackStateSet = std::unordered_map<
+ IndexedDBCallbacksImpl::InternalState*,
+ std::unique_ptr<IndexedDBCallbacksImpl::InternalState>>;
+ using DatabaseCallbackStateSet =
+ std::unordered_map<blink::WebIDBDatabaseCallbacks*,
+ std::unique_ptr<blink::WebIDBDatabaseCallbacks>>;
+
static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); }
template <typename T>
@@ -164,10 +174,9 @@ class CONTENT_EXPORT IndexedDBDispatcher : public WorkerThread::Observer {
// destroyed on thread exit if the Mojo pipe is not yet closed. Otherwise the
// object will leak because the thread's task runner is no longer executing
// tasks.
- std::unordered_set<IndexedDBCallbacksImpl::InternalState*>
- mojo_owned_callback_state_;
- std::unordered_set<blink::WebIDBDatabaseCallbacks*>
- mojo_owned_database_callback_state_;
+ CallbackStateSet mojo_owned_callback_state_;
+ DatabaseCallbackStateSet mojo_owned_database_callback_state_;
+ bool in_destructor_ = false;
// Maps the ipc_callback_id from an open cursor request to the request's
// transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl
« no previous file with comments | « no previous file | content/child/indexed_db/indexed_db_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698