OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 ObjectStoreDispatcherHost::~ObjectStoreDispatcherHost() { | 636 ObjectStoreDispatcherHost::~ObjectStoreDispatcherHost() { |
637 } | 637 } |
638 | 638 |
639 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( | 639 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( |
640 const IPC::Message& message, bool* msg_is_ok) { | 640 const IPC::Message& message, bool* msg_is_ok) { |
641 bool handled = true; | 641 bool handled = true; |
642 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, | 642 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, |
643 message, *msg_is_ok) | 643 message, *msg_is_ok) |
644 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) | 644 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) |
645 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) | 645 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) |
| 646 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreSetIndexKeys, |
| 647 OnSetIndexKeys) |
| 648 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreSetIndexesReady, |
| 649 OnSetIndexesReady) |
646 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) | 650 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) |
647 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) | 651 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) |
648 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) | 652 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) |
649 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) | 653 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) |
650 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) | 654 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) |
651 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) | 655 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) |
652 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) | 656 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) |
653 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) | 657 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) |
654 IPC_MESSAGE_UNHANDLED(handled = false) | 658 IPC_MESSAGE_UNHANDLED(handled = false) |
655 IPC_END_MESSAGE_MAP() | 659 IPC_END_MESSAGE_MAP() |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 *idb_transaction, params.index_names, | 707 *idb_transaction, params.index_names, |
704 params.index_keys, *ec); | 708 params.index_keys, *ec); |
705 if (*ec) | 709 if (*ec) |
706 return; | 710 return; |
707 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); | 711 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); |
708 WebIDBTransactionIDToSizeMap* map = | 712 WebIDBTransactionIDToSizeMap* map = |
709 &parent_->transaction_dispatcher_host_->transaction_size_map_; | 713 &parent_->transaction_dispatcher_host_->transaction_size_map_; |
710 (*map)[params.transaction_id] += size; | 714 (*map)[params.transaction_id] += size; |
711 } | 715 } |
712 | 716 |
| 717 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexKeys( |
| 718 int32 idb_object_store_id, |
| 719 const content::IndexedDBKey& primary_key, |
| 720 const std::vector<string16>& index_names, |
| 721 const std::vector<std::vector<content::IndexedDBKey> >& index_keys, |
| 722 int32 transaction_id) { |
| 723 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 724 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 725 &map_, idb_object_store_id); |
| 726 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 727 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
| 728 if (!idb_transaction || !idb_object_store) |
| 729 return; |
| 730 idb_object_store->setIndexKeys(primary_key, index_names, |
| 731 index_keys, *idb_transaction); |
| 732 } |
| 733 |
| 734 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexesReady( |
| 735 int32 idb_object_store_id, |
| 736 const std::vector<string16>& index_names, |
| 737 int32 transaction_id) { |
| 738 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 739 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 740 &map_, idb_object_store_id); |
| 741 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 742 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
| 743 if (!idb_transaction || !idb_object_store) |
| 744 return; |
| 745 |
| 746 idb_object_store->setIndexesReady(index_names, *idb_transaction); |
| 747 } |
| 748 |
713 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( | 749 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( |
714 int idb_object_store_id, | 750 int idb_object_store_id, |
715 int32 thread_id, | 751 int32 thread_id, |
716 int32 response_id, | 752 int32 response_id, |
717 const IndexedDBKeyRange& key_range, | 753 const IndexedDBKeyRange& key_range, |
718 int32 transaction_id, | 754 int32 transaction_id, |
719 WebKit::WebExceptionCode* ec) { | 755 WebKit::WebExceptionCode* ec) { |
720 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 756 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
721 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 757 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
722 &map_, idb_object_store_id); | 758 &map_, idb_object_store_id); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 857 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
822 if (!idb_transaction || !idb_object_store) | 858 if (!idb_transaction || !idb_object_store) |
823 return; | 859 return; |
824 | 860 |
825 *ec = 0; | 861 *ec = 0; |
826 scoped_ptr<WebIDBCallbacks> callbacks( | 862 scoped_ptr<WebIDBCallbacks> callbacks( |
827 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.thread_id, | 863 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.thread_id, |
828 params.response_id, -1)); | 864 params.response_id, -1)); |
829 idb_object_store->openCursor( | 865 idb_object_store->openCursor( |
830 params.key_range, params.direction, callbacks.release(), | 866 params.key_range, params.direction, callbacks.release(), |
| 867 params.task_type, |
831 *idb_transaction, *ec); | 868 *idb_transaction, *ec); |
832 } | 869 } |
833 | 870 |
834 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCount( | 871 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCount( |
835 const IndexedDBHostMsg_ObjectStoreCount_Params& params, | 872 const IndexedDBHostMsg_ObjectStoreCount_Params& params, |
836 WebKit::WebExceptionCode* ec) { | 873 WebKit::WebExceptionCode* ec) { |
837 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 874 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
838 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 875 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
839 &parent_->object_store_dispatcher_host_->map_, | 876 &parent_->object_store_dispatcher_host_->map_, |
840 params.idb_object_store_id); | 877 params.idb_object_store_id); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 } | 1135 } |
1099 | 1136 |
1100 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1137 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
1101 int32 object_id) { | 1138 int32 object_id) { |
1102 // TODO(dgrogan): This doesn't seem to be happening with some version change | 1139 // TODO(dgrogan): This doesn't seem to be happening with some version change |
1103 // transactions. Possibly introduced with integer version support. | 1140 // transactions. Possibly introduced with integer version support. |
1104 transaction_size_map_.erase(object_id); | 1141 transaction_size_map_.erase(object_id); |
1105 transaction_url_map_.erase(object_id); | 1142 transaction_url_map_.erase(object_id); |
1106 parent_->DestroyObject(&map_, object_id); | 1143 parent_->DestroyObject(&map_, object_id); |
1107 } | 1144 } |
OLD | NEW |