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

Side by Side Diff: content/child/indexed_db/indexed_db_dispatcher.h

Issue 2524823002: Reland: [IndexedDB] Delete callbacks state on worker thread exit. (Closed)
Patch Set: Rebased. Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/child/indexed_db/indexed_db_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 5 #ifndef CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_
6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 IndexedDBCallbacksImpl::InternalState* callback_state); 78 IndexedDBCallbacksImpl::InternalState* callback_state);
79 void RegisterMojoOwnedDatabaseCallbacks( 79 void RegisterMojoOwnedDatabaseCallbacks(
80 blink::WebIDBDatabaseCallbacks* callback_state); 80 blink::WebIDBDatabaseCallbacks* callback_state);
81 void UnregisterMojoOwnedDatabaseCallbacks( 81 void UnregisterMojoOwnedDatabaseCallbacks(
82 blink::WebIDBDatabaseCallbacks* callback_state); 82 blink::WebIDBDatabaseCallbacks* callback_state);
83 83
84 private: 84 private:
85 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset); 85 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset);
86 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId); 86 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId);
87 87
88 // Looking up move-only entries in an std::unordered_set and removing them
89 // with out freeing them seems to be impossible so use a map instead so that
90 // the key type can remain a raw pointer.
91 using CallbackStateSet = std::unordered_map<
92 IndexedDBCallbacksImpl::InternalState*,
93 std::unique_ptr<IndexedDBCallbacksImpl::InternalState>>;
94 using DatabaseCallbackStateSet =
95 std::unordered_map<blink::WebIDBDatabaseCallbacks*,
96 std::unique_ptr<blink::WebIDBDatabaseCallbacks>>;
97
88 static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); } 98 static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); }
89 99
90 // IDBCallback message handlers. 100 // IDBCallback message handlers.
91 void OnDatabaseChanges(int32_t ipc_thread_id, 101 void OnDatabaseChanges(int32_t ipc_thread_id,
92 const IndexedDBMsg_ObserverChanges&); 102 const IndexedDBMsg_ObserverChanges&);
93 103
94 IDMap<blink::WebIDBObserver, IDMapOwnPointer> observers_; 104 IDMap<blink::WebIDBObserver, IDMapOwnPointer> observers_;
95 std::unordered_set<WebIDBCursorImpl*> cursors_; 105 std::unordered_set<WebIDBCursorImpl*> cursors_;
96 106
97 // Holds pointers to the worker-thread owned state of IndexedDBCallbacksImpl 107 // Holds pointers to the worker-thread owned state of IndexedDBCallbacksImpl
98 // and IndexedDBDatabaseCallbacksImpl objects to makes sure that it is 108 // and IndexedDBDatabaseCallbacksImpl objects to makes sure that it is
99 // destroyed on thread exit if the Mojo pipe is not yet closed. Otherwise the 109 // destroyed on thread exit if the Mojo pipe is not yet closed. Otherwise the
100 // object will leak because the thread's task runner is no longer executing 110 // object will leak because the thread's task runner is no longer executing
101 // tasks. 111 // tasks.
102 std::unordered_set<IndexedDBCallbacksImpl::InternalState*> 112 CallbackStateSet mojo_owned_callback_state_;
103 mojo_owned_callback_state_; 113 DatabaseCallbackStateSet mojo_owned_database_callback_state_;
104 std::unordered_set<blink::WebIDBDatabaseCallbacks*> 114 bool in_destructor_ = false;
105 mojo_owned_database_callback_state_;
106 115
107 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); 116 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher);
108 }; 117 };
109 118
110 } // namespace content 119 } // namespace content
111 120
112 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 121 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_
OLDNEW
« 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