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

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

Issue 2521773003: Revert of [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 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 IndexedDBCallbacksImpl::InternalState* callback_state); 120 IndexedDBCallbacksImpl::InternalState* callback_state);
121 void RegisterMojoOwnedDatabaseCallbacks( 121 void RegisterMojoOwnedDatabaseCallbacks(
122 blink::WebIDBDatabaseCallbacks* callback_state); 122 blink::WebIDBDatabaseCallbacks* callback_state);
123 void UnregisterMojoOwnedDatabaseCallbacks( 123 void UnregisterMojoOwnedDatabaseCallbacks(
124 blink::WebIDBDatabaseCallbacks* callback_state); 124 blink::WebIDBDatabaseCallbacks* callback_state);
125 125
126 private: 126 private:
127 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset); 127 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset);
128 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId); 128 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId);
129 129
130 // Looking up move-only entries in an std::unordered_set and removing them
131 // with out freeing them seems to be impossible so use a map instead so that
132 // the key type can remain a raw pointer.
133 using CallbackStateSet = std::unordered_map<
134 IndexedDBCallbacksImpl::InternalState*,
135 std::unique_ptr<IndexedDBCallbacksImpl::InternalState>>;
136 using DatabaseCallbackStateSet =
137 std::unordered_map<blink::WebIDBDatabaseCallbacks*,
138 std::unique_ptr<blink::WebIDBDatabaseCallbacks>>;
139
140 static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); } 130 static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); }
141 131
142 template <typename T> 132 template <typename T>
143 void init_params(T* params, blink::WebIDBCallbacks* callbacks_ptr) { 133 void init_params(T* params, blink::WebIDBCallbacks* callbacks_ptr) {
144 std::unique_ptr<blink::WebIDBCallbacks> callbacks(callbacks_ptr); 134 std::unique_ptr<blink::WebIDBCallbacks> callbacks(callbacks_ptr);
145 params->ipc_thread_id = CurrentWorkerId(); 135 params->ipc_thread_id = CurrentWorkerId();
146 params->ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); 136 params->ipc_callbacks_id = pending_callbacks_.Add(callbacks.release());
147 } 137 }
148 138
149 // IDBCallback message handlers. 139 // IDBCallback message handlers.
(...skipping 17 matching lines...) Expand all
167 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be 157 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be
168 // destroyed and used on the same thread it was created on. 158 // destroyed and used on the same thread it was created on.
169 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; 159 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_;
170 IDMap<blink::WebIDBObserver, IDMapOwnPointer> observers_; 160 IDMap<blink::WebIDBObserver, IDMapOwnPointer> observers_;
171 161
172 // Holds pointers to the worker-thread owned state of IndexedDBCallbacksImpl 162 // Holds pointers to the worker-thread owned state of IndexedDBCallbacksImpl
173 // and IndexedDBDatabaseCallbacksImpl objects to makes sure that it is 163 // and IndexedDBDatabaseCallbacksImpl objects to makes sure that it is
174 // destroyed on thread exit if the Mojo pipe is not yet closed. Otherwise the 164 // destroyed on thread exit if the Mojo pipe is not yet closed. Otherwise the
175 // object will leak because the thread's task runner is no longer executing 165 // object will leak because the thread's task runner is no longer executing
176 // tasks. 166 // tasks.
177 CallbackStateSet mojo_owned_callback_state_; 167 std::unordered_set<IndexedDBCallbacksImpl::InternalState*>
178 DatabaseCallbackStateSet mojo_owned_database_callback_state_; 168 mojo_owned_callback_state_;
169 std::unordered_set<blink::WebIDBDatabaseCallbacks*>
170 mojo_owned_database_callback_state_;
179 171
180 // Maps the ipc_callback_id from an open cursor request to the request's 172 // Maps the ipc_callback_id from an open cursor request to the request's
181 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl 173 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl
182 // when it is created. 174 // when it is created.
183 std::map<int32_t, int64_t> cursor_transaction_ids_; 175 std::map<int32_t, int64_t> cursor_transaction_ids_;
184 176
185 // Map from cursor id to WebIDBCursorImpl. 177 // Map from cursor id to WebIDBCursorImpl.
186 std::map<int32_t, WebIDBCursorImpl*> cursors_; 178 std::map<int32_t, WebIDBCursorImpl*> cursors_;
187 179
188 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); 180 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher);
189 }; 181 };
190 182
191 } // namespace content 183 } // namespace content
192 184
193 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 185 #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