| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" | 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 bool handled = true; | 515 bool handled = true; |
| 516 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::IndexDispatcherHost, | 516 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::IndexDispatcherHost, |
| 517 message, *msg_is_ok) | 517 message, *msg_is_ok) |
| 518 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexName, OnName) | 518 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexName, OnName) |
| 519 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexStoreName, OnStoreName) | 519 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexStoreName, OnStoreName) |
| 520 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexKeyPath, OnKeyPath) | 520 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexKeyPath, OnKeyPath) |
| 521 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexUnique, OnUnique) | 521 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexUnique, OnUnique) |
| 522 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenObjectCursor, | 522 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenObjectCursor, |
| 523 OnOpenObjectCursor) | 523 OnOpenObjectCursor) |
| 524 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) | 524 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) |
| 525 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexCount, OnCount) |
| 525 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) | 526 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) |
| 526 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) | 527 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) |
| 527 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) | 528 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) |
| 528 IPC_MESSAGE_UNHANDLED(handled = false) | 529 IPC_MESSAGE_UNHANDLED(handled = false) |
| 529 IPC_END_MESSAGE_MAP() | 530 IPC_END_MESSAGE_MAP() |
| 530 return handled; | 531 return handled; |
| 531 } | 532 } |
| 532 | 533 |
| 533 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( | 534 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( |
| 534 IPC::Message* message) { | 535 IPC::Message* message) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 *ec = 0; | 593 *ec = 0; |
| 593 scoped_ptr<WebIDBCallbacks> callbacks( | 594 scoped_ptr<WebIDBCallbacks> callbacks( |
| 594 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.thread_id, | 595 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.thread_id, |
| 595 params.response_id, -1)); | 596 params.response_id, -1)); |
| 596 idb_index->openKeyCursor( | 597 idb_index->openKeyCursor( |
| 597 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 598 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 598 params.upper_open), | 599 params.upper_open), |
| 599 params.direction, callbacks.release(), *idb_transaction, *ec); | 600 params.direction, callbacks.release(), *idb_transaction, *ec); |
| 600 } | 601 } |
| 601 | 602 |
| 603 void IndexedDBDispatcherHost::IndexDispatcherHost::OnCount( |
| 604 const IndexedDBHostMsg_IndexCount_Params& params, |
| 605 WebKit::WebExceptionCode* ec) { |
| 606 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 607 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 608 &map_, params.idb_index_id); |
| 609 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 610 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
| 611 if (!idb_transaction || !idb_index) |
| 612 return; |
| 613 |
| 614 *ec = 0; |
| 615 scoped_ptr<WebIDBCallbacks> callbacks( |
| 616 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, |
| 617 params.thread_id, |
| 618 params.response_id)); |
| 619 idb_index->count( |
| 620 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 621 params.upper_open), |
| 622 callbacks.release(), *idb_transaction, *ec); |
| 623 } |
| 624 |
| 602 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( | 625 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( |
| 603 int idb_index_id, | 626 int idb_index_id, |
| 604 int32 thread_id, | 627 int32 thread_id, |
| 605 int32 response_id, | 628 int32 response_id, |
| 606 const IndexedDBKey& key, | 629 const IndexedDBKey& key, |
| 607 int32 transaction_id, | 630 int32 transaction_id, |
| 608 WebKit::WebExceptionCode* ec) { | 631 WebKit::WebExceptionCode* ec) { |
| 609 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 632 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 610 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 633 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 611 &map_, idb_index_id); | 634 &map_, idb_index_id); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) | 693 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) |
| 671 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) | 694 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) |
| 672 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) | 695 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) |
| 673 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) | 696 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) |
| 674 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) | 697 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) |
| 675 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) | 698 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) |
| 676 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) | 699 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) |
| 677 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) | 700 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) |
| 678 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) | 701 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) |
| 679 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) | 702 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) |
| 703 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) |
| 680 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) | 704 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) |
| 681 IPC_MESSAGE_UNHANDLED(handled = false) | 705 IPC_MESSAGE_UNHANDLED(handled = false) |
| 682 IPC_END_MESSAGE_MAP() | 706 IPC_END_MESSAGE_MAP() |
| 683 return handled; | 707 return handled; |
| 684 } | 708 } |
| 685 | 709 |
| 686 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::Send( | 710 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::Send( |
| 687 IPC::Message* message) { | 711 IPC::Message* message) { |
| 688 parent_->Send(message); | 712 parent_->Send(message); |
| 689 } | 713 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 *ec = 0; | 899 *ec = 0; |
| 876 scoped_ptr<WebIDBCallbacks> callbacks( | 900 scoped_ptr<WebIDBCallbacks> callbacks( |
| 877 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.thread_id, | 901 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.thread_id, |
| 878 params.response_id, -1)); | 902 params.response_id, -1)); |
| 879 idb_object_store->openCursor( | 903 idb_object_store->openCursor( |
| 880 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 904 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 881 params.upper_open), | 905 params.upper_open), |
| 882 params.direction, callbacks.release(), *idb_transaction, *ec); | 906 params.direction, callbacks.release(), *idb_transaction, *ec); |
| 883 } | 907 } |
| 884 | 908 |
| 909 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCount( |
| 910 const IndexedDBHostMsg_ObjectStoreCount_Params& params, |
| 911 WebKit::WebExceptionCode* ec) { |
| 912 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 913 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 914 &parent_->object_store_dispatcher_host_->map_, |
| 915 params.idb_object_store_id); |
| 916 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 917 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
| 918 if (!idb_transaction || !idb_object_store) |
| 919 return; |
| 920 |
| 921 *ec = 0; |
| 922 scoped_ptr<WebIDBCallbacks> callbacks( |
| 923 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, |
| 924 params.thread_id, |
| 925 params.response_id)); |
| 926 idb_object_store->count( |
| 927 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 928 params.upper_open), |
| 929 callbacks.release(), *idb_transaction, *ec); |
| 930 } |
| 931 |
| 885 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( | 932 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( |
| 886 int32 object_id) { | 933 int32 object_id) { |
| 887 parent_->DestroyObject(&map_, object_id); | 934 parent_->DestroyObject(&map_, object_id); |
| 888 } | 935 } |
| 889 | 936 |
| 890 ////////////////////////////////////////////////////////////////////// | 937 ////////////////////////////////////////////////////////////////////// |
| 891 // IndexedDBDispatcherHost::CursorDispatcherHost | 938 // IndexedDBDispatcherHost::CursorDispatcherHost |
| 892 // | 939 // |
| 893 | 940 |
| 894 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( | 941 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 } | 1180 } |
| 1134 idb_transaction->didCompleteTaskEvents(); | 1181 idb_transaction->didCompleteTaskEvents(); |
| 1135 } | 1182 } |
| 1136 | 1183 |
| 1137 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1184 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1138 int32 object_id) { | 1185 int32 object_id) { |
| 1139 transaction_size_map_.erase(object_id); | 1186 transaction_size_map_.erase(object_id); |
| 1140 transaction_url_map_.erase(object_id); | 1187 transaction_url_map_.erase(object_id); |
| 1141 parent_->DestroyObject(&map_, object_id); | 1188 parent_->DestroyObject(&map_, object_id); |
| 1142 } | 1189 } |
| OLD | NEW |