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 "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 int32 ipc_object_id, | 453 int32 ipc_object_id, |
454 const IndexedDBDatabaseMetadata& idb_metadata) { | 454 const IndexedDBDatabaseMetadata& idb_metadata) { |
455 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 455 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
456 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 456 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
457 if (!callbacks) | 457 if (!callbacks) |
458 return; | 458 return; |
459 WebIDBMetadata metadata(ConvertMetadata(idb_metadata)); | 459 WebIDBMetadata metadata(ConvertMetadata(idb_metadata)); |
460 // If an upgrade was performed, count will be non-zero. | 460 // If an upgrade was performed, count will be non-zero. |
461 if (!databases_.count(ipc_object_id)) | 461 if (!databases_.count(ipc_object_id)) |
462 databases_[ipc_object_id] = new RendererWebIDBDatabaseImpl( | 462 databases_[ipc_object_id] = new RendererWebIDBDatabaseImpl( |
463 ipc_object_id, ipc_database_callbacks_id, thread_safe_sender_); | 463 ipc_object_id, ipc_database_callbacks_id, thread_safe_sender_.get()); |
464 DCHECK_EQ(databases_.count(ipc_object_id), 1u); | 464 DCHECK_EQ(databases_.count(ipc_object_id), 1u); |
465 callbacks->onSuccess(databases_[ipc_object_id], metadata); | 465 callbacks->onSuccess(databases_[ipc_object_id], metadata); |
466 pending_callbacks_.Remove(ipc_callbacks_id); | 466 pending_callbacks_.Remove(ipc_callbacks_id); |
467 } | 467 } |
468 | 468 |
469 void IndexedDBDispatcher::OnSuccessIndexedDBKey(int32 ipc_thread_id, | 469 void IndexedDBDispatcher::OnSuccessIndexedDBKey(int32 ipc_thread_id, |
470 int32 ipc_callbacks_id, | 470 int32 ipc_callbacks_id, |
471 const IndexedDBKey& key) { | 471 const IndexedDBKey& key) { |
472 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 472 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
473 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 473 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 const IndexedDBKey& primary_key = p.primary_key; | 550 const IndexedDBKey& primary_key = p.primary_key; |
551 WebData web_value; | 551 WebData web_value; |
552 if (p.value.size()) | 552 if (p.value.size()) |
553 web_value.assign(&p.value.front(), p.value.size()); | 553 web_value.assign(&p.value.front(), p.value.size()); |
554 | 554 |
555 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 555 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
556 if (!callbacks) | 556 if (!callbacks) |
557 return; | 557 return; |
558 | 558 |
559 RendererWebIDBCursorImpl* cursor = | 559 RendererWebIDBCursorImpl* cursor = |
560 new RendererWebIDBCursorImpl(ipc_object_id, thread_safe_sender_); | 560 new RendererWebIDBCursorImpl(ipc_object_id, thread_safe_sender_.get()); |
561 cursors_[ipc_object_id] = cursor; | 561 cursors_[ipc_object_id] = cursor; |
562 callbacks->onSuccess(cursor, key, primary_key, web_value); | 562 callbacks->onSuccess(cursor, key, primary_key, web_value); |
563 | 563 |
564 pending_callbacks_.Remove(ipc_callbacks_id); | 564 pending_callbacks_.Remove(ipc_callbacks_id); |
565 } | 565 } |
566 | 566 |
567 void IndexedDBDispatcher::OnSuccessCursorContinue( | 567 void IndexedDBDispatcher::OnSuccessCursorContinue( |
568 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) { | 568 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) { |
569 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); | 569 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
570 int32 ipc_callbacks_id = p.ipc_callbacks_id; | 570 int32 ipc_callbacks_id = p.ipc_callbacks_id; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 callbacks->onBlocked(existing_version); | 619 callbacks->onBlocked(existing_version); |
620 } | 620 } |
621 | 621 |
622 void IndexedDBDispatcher::OnUpgradeNeeded( | 622 void IndexedDBDispatcher::OnUpgradeNeeded( |
623 const IndexedDBMsg_CallbacksUpgradeNeeded_Params& p) { | 623 const IndexedDBMsg_CallbacksUpgradeNeeded_Params& p) { |
624 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); | 624 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
625 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(p.ipc_callbacks_id); | 625 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(p.ipc_callbacks_id); |
626 DCHECK(callbacks); | 626 DCHECK(callbacks); |
627 WebIDBMetadata metadata(ConvertMetadata(p.idb_metadata)); | 627 WebIDBMetadata metadata(ConvertMetadata(p.idb_metadata)); |
628 DCHECK(!databases_.count(p.ipc_database_id)); | 628 DCHECK(!databases_.count(p.ipc_database_id)); |
629 databases_[p.ipc_database_id] = new RendererWebIDBDatabaseImpl( | 629 databases_[p.ipc_database_id] = |
630 p.ipc_database_id, p.ipc_database_callbacks_id, thread_safe_sender_); | 630 new RendererWebIDBDatabaseImpl(p.ipc_database_id, |
| 631 p.ipc_database_callbacks_id, |
| 632 thread_safe_sender_.get()); |
631 callbacks->onUpgradeNeeded( | 633 callbacks->onUpgradeNeeded( |
632 p.old_version, | 634 p.old_version, |
633 databases_[p.ipc_database_id], | 635 databases_[p.ipc_database_id], |
634 metadata, | 636 metadata, |
635 static_cast<WebIDBCallbacks::DataLoss>(p.data_loss)); | 637 static_cast<WebIDBCallbacks::DataLoss>(p.data_loss)); |
636 } | 638 } |
637 | 639 |
638 void IndexedDBDispatcher::OnError(int32 ipc_thread_id, | 640 void IndexedDBDispatcher::OnError(int32 ipc_thread_id, |
639 int32 ipc_callbacks_id, | 641 int32 ipc_callbacks_id, |
640 int code, | 642 int code, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 int32 ipc_exception_cursor_id) { | 707 int32 ipc_exception_cursor_id) { |
706 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 708 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
707 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 709 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
708 if (i->first == ipc_exception_cursor_id) | 710 if (i->first == ipc_exception_cursor_id) |
709 continue; | 711 continue; |
710 i->second->ResetPrefetchCache(); | 712 i->second->ResetPrefetchCache(); |
711 } | 713 } |
712 } | 714 } |
713 | 715 |
714 } // namespace content | 716 } // namespace content |
OLD | NEW |