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

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

Issue 2525443002: [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
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 #include "content/child/indexed_db/indexed_db_dispatcher.h" 5 #include "content/child/indexed_db/indexed_db_dispatcher.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 DCHECK(!base::ContainsKey(cursors_, ipc_cursor_id)); 189 DCHECK(!base::ContainsKey(cursors_, ipc_cursor_id));
190 cursors_[ipc_cursor_id] = cursor; 190 cursors_[ipc_cursor_id] = cursor;
191 } 191 }
192 192
193 void IndexedDBDispatcher::CursorDestroyed(int32_t ipc_cursor_id) { 193 void IndexedDBDispatcher::CursorDestroyed(int32_t ipc_cursor_id) {
194 cursors_.erase(ipc_cursor_id); 194 cursors_.erase(ipc_cursor_id);
195 } 195 }
196 196
197 void IndexedDBDispatcher::RegisterMojoOwnedCallbacks( 197 void IndexedDBDispatcher::RegisterMojoOwnedCallbacks(
198 IndexedDBCallbacksImpl::InternalState* callbacks) { 198 IndexedDBCallbacksImpl::InternalState* callbacks) {
199 mojo_owned_callback_state_.insert(callbacks); 199 mojo_owned_callback_state_[callbacks] = base::WrapUnique(callbacks);
200 } 200 }
201 201
202 void IndexedDBDispatcher::UnregisterMojoOwnedCallbacks( 202 void IndexedDBDispatcher::UnregisterMojoOwnedCallbacks(
203 IndexedDBCallbacksImpl::InternalState* callbacks) { 203 IndexedDBCallbacksImpl::InternalState* callbacks) {
204 DCHECK(base::ContainsValue(mojo_owned_callback_state_, callbacks)); 204 auto it = mojo_owned_callback_state_.find(callbacks);
205 mojo_owned_callback_state_.erase(callbacks); 205 DCHECK(it != mojo_owned_callback_state_.end());
206 it->second.release();
jsbell 2016/11/21 22:38:06 Is the release() necessary?
Reilly Grant (use Gerrit) 2016/11/21 23:26:10 Yes. Otherwise erase(it) will free the object and
jsbell 2016/11/21 23:36:29 Derp. My brain was reading `reset()` for some reas
207 mojo_owned_callback_state_.erase(it);
206 } 208 }
207 209
208 void IndexedDBDispatcher::RegisterMojoOwnedDatabaseCallbacks( 210 void IndexedDBDispatcher::RegisterMojoOwnedDatabaseCallbacks(
209 blink::WebIDBDatabaseCallbacks* callbacks) { 211 blink::WebIDBDatabaseCallbacks* callbacks) {
210 mojo_owned_database_callback_state_.insert(callbacks); 212 mojo_owned_database_callback_state_[callbacks] = base::WrapUnique(callbacks);
211 } 213 }
212 214
213 void IndexedDBDispatcher::UnregisterMojoOwnedDatabaseCallbacks( 215 void IndexedDBDispatcher::UnregisterMojoOwnedDatabaseCallbacks(
214 blink::WebIDBDatabaseCallbacks* callbacks) { 216 blink::WebIDBDatabaseCallbacks* callbacks) {
215 DCHECK(base::ContainsValue(mojo_owned_database_callback_state_, callbacks)); 217 auto it = mojo_owned_database_callback_state_.find(callbacks);
216 mojo_owned_database_callback_state_.erase(callbacks); 218 DCHECK(it != mojo_owned_database_callback_state_.end());
219 it->second.release();
220 mojo_owned_database_callback_state_.erase(it);
217 } 221 }
218 222
219 // Populate some WebIDBValue members (data & blob info) from the supplied 223 // Populate some WebIDBValue members (data & blob info) from the supplied
220 // value message (IndexedDBMsg_Value or one that includes it). 224 // value message (IndexedDBMsg_Value or one that includes it).
221 template <class IndexedDBMsgValueType> 225 template <class IndexedDBMsgValueType>
222 static void PrepareWebValue(const IndexedDBMsgValueType& value, 226 static void PrepareWebValue(const IndexedDBMsgValueType& value,
223 WebIDBValue* web_value) { 227 WebIDBValue* web_value) {
224 if (value.bits.empty()) 228 if (value.bits.empty())
225 return; 229 return;
226 230
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; 362 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator;
359 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { 363 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
360 if (i->first == ipc_exception_cursor_id || 364 if (i->first == ipc_exception_cursor_id ||
361 i->second->transaction_id() != transaction_id) 365 i->second->transaction_id() != transaction_id)
362 continue; 366 continue;
363 i->second->ResetPrefetchCache(); 367 i->second->ResetPrefetchCache();
364 } 368 }
365 } 369 }
366 370
367 } // namespace content 371 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698