| OLD | NEW |
| 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 Loading... |
| 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_[callbacks] = base::WrapUnique(callbacks); | 199 mojo_owned_callback_state_.insert(callbacks); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void IndexedDBDispatcher::UnregisterMojoOwnedCallbacks( | 202 void IndexedDBDispatcher::UnregisterMojoOwnedCallbacks( |
| 203 IndexedDBCallbacksImpl::InternalState* callbacks) { | 203 IndexedDBCallbacksImpl::InternalState* callbacks) { |
| 204 auto it = mojo_owned_callback_state_.find(callbacks); | 204 DCHECK(base::ContainsValue(mojo_owned_callback_state_, callbacks)); |
| 205 DCHECK(it != mojo_owned_callback_state_.end()); | 205 mojo_owned_callback_state_.erase(callbacks); |
| 206 it->second.release(); | |
| 207 mojo_owned_callback_state_.erase(it); | |
| 208 } | 206 } |
| 209 | 207 |
| 210 void IndexedDBDispatcher::RegisterMojoOwnedDatabaseCallbacks( | 208 void IndexedDBDispatcher::RegisterMojoOwnedDatabaseCallbacks( |
| 211 blink::WebIDBDatabaseCallbacks* callbacks) { | 209 blink::WebIDBDatabaseCallbacks* callbacks) { |
| 212 mojo_owned_database_callback_state_[callbacks] = base::WrapUnique(callbacks); | 210 mojo_owned_database_callback_state_.insert(callbacks); |
| 213 } | 211 } |
| 214 | 212 |
| 215 void IndexedDBDispatcher::UnregisterMojoOwnedDatabaseCallbacks( | 213 void IndexedDBDispatcher::UnregisterMojoOwnedDatabaseCallbacks( |
| 216 blink::WebIDBDatabaseCallbacks* callbacks) { | 214 blink::WebIDBDatabaseCallbacks* callbacks) { |
| 217 auto it = mojo_owned_database_callback_state_.find(callbacks); | 215 DCHECK(base::ContainsValue(mojo_owned_database_callback_state_, callbacks)); |
| 218 DCHECK(it != mojo_owned_database_callback_state_.end()); | 216 mojo_owned_database_callback_state_.erase(callbacks); |
| 219 it->second.release(); | |
| 220 mojo_owned_database_callback_state_.erase(it); | |
| 221 } | 217 } |
| 222 | 218 |
| 223 // Populate some WebIDBValue members (data & blob info) from the supplied | 219 // Populate some WebIDBValue members (data & blob info) from the supplied |
| 224 // value message (IndexedDBMsg_Value or one that includes it). | 220 // value message (IndexedDBMsg_Value or one that includes it). |
| 225 template <class IndexedDBMsgValueType> | 221 template <class IndexedDBMsgValueType> |
| 226 static void PrepareWebValue(const IndexedDBMsgValueType& value, | 222 static void PrepareWebValue(const IndexedDBMsgValueType& value, |
| 227 WebIDBValue* web_value) { | 223 WebIDBValue* web_value) { |
| 228 if (value.bits.empty()) | 224 if (value.bits.empty()) |
| 229 return; | 225 return; |
| 230 | 226 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; | 358 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; |
| 363 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 359 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 364 if (i->first == ipc_exception_cursor_id || | 360 if (i->first == ipc_exception_cursor_id || |
| 365 i->second->transaction_id() != transaction_id) | 361 i->second->transaction_id() != transaction_id) |
| 366 continue; | 362 continue; |
| 367 i->second->ResetPrefetchCache(); | 363 i->second->ResetPrefetchCache(); |
| 368 } | 364 } |
| 369 } | 365 } |
| 370 | 366 |
| 371 } // namespace content | 367 } // namespace content |
| OLD | NEW |