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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 bool handled = true; | 507 bool handled = true; |
508 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::IndexDispatcherHost, | 508 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::IndexDispatcherHost, |
509 message, *msg_is_ok) | 509 message, *msg_is_ok) |
510 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexName, OnName) | 510 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexName, OnName) |
511 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexStoreName, OnStoreName) | 511 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexStoreName, OnStoreName) |
512 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexKeyPath, OnKeyPath) | 512 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexKeyPath, OnKeyPath) |
513 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexUnique, OnUnique) | 513 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexUnique, OnUnique) |
514 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenObjectCursor, | 514 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenObjectCursor, |
515 OnOpenObjectCursor) | 515 OnOpenObjectCursor) |
516 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) | 516 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) |
| 517 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexCount, OnCount) |
517 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) | 518 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) |
518 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) | 519 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) |
519 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) | 520 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) |
520 IPC_MESSAGE_UNHANDLED(handled = false) | 521 IPC_MESSAGE_UNHANDLED(handled = false) |
521 IPC_END_MESSAGE_MAP() | 522 IPC_END_MESSAGE_MAP() |
522 return handled; | 523 return handled; |
523 } | 524 } |
524 | 525 |
525 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( | 526 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( |
526 IPC::Message* message) { | 527 IPC::Message* message) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 583 |
583 *ec = 0; | 584 *ec = 0; |
584 scoped_ptr<WebIDBCallbacks> callbacks( | 585 scoped_ptr<WebIDBCallbacks> callbacks( |
585 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); | 586 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); |
586 idb_index->openKeyCursor( | 587 idb_index->openKeyCursor( |
587 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 588 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
588 params.upper_open), | 589 params.upper_open), |
589 params.direction, callbacks.release(), *idb_transaction, *ec); | 590 params.direction, callbacks.release(), *idb_transaction, *ec); |
590 } | 591 } |
591 | 592 |
| 593 void IndexedDBDispatcherHost::IndexDispatcherHost::OnCount( |
| 594 const IndexedDBHostMsg_IndexCount_Params& params, |
| 595 WebKit::WebExceptionCode* ec) { |
| 596 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 597 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 598 &map_, params.idb_index_id); |
| 599 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 600 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
| 601 if (!idb_transaction || !idb_index) |
| 602 return; |
| 603 |
| 604 *ec = 0; |
| 605 scoped_ptr<WebIDBCallbacks> callbacks( |
| 606 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, |
| 607 params.response_id)); |
| 608 idb_index->count( |
| 609 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 610 params.upper_open), |
| 611 callbacks.release(), *idb_transaction, *ec); |
| 612 } |
| 613 |
592 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( | 614 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( |
593 int idb_index_id, | 615 int idb_index_id, |
594 int32 response_id, | 616 int32 response_id, |
595 const IndexedDBKey& key, | 617 const IndexedDBKey& key, |
596 int32 transaction_id, | 618 int32 transaction_id, |
597 WebKit::WebExceptionCode* ec) { | 619 WebKit::WebExceptionCode* ec) { |
598 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 620 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
599 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 621 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
600 &map_, idb_index_id); | 622 &map_, idb_index_id); |
601 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 623 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) | 679 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) |
658 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) | 680 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) |
659 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) | 681 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) |
660 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) | 682 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) |
661 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) | 683 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) |
662 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) | 684 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) |
663 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) | 685 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) |
664 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) | 686 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) |
665 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) | 687 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) |
666 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) | 688 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) |
| 689 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) |
667 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) | 690 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) |
668 IPC_MESSAGE_UNHANDLED(handled = false) | 691 IPC_MESSAGE_UNHANDLED(handled = false) |
669 IPC_END_MESSAGE_MAP() | 692 IPC_END_MESSAGE_MAP() |
670 return handled; | 693 return handled; |
671 } | 694 } |
672 | 695 |
673 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::Send( | 696 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::Send( |
674 IPC::Message* message) { | 697 IPC::Message* message) { |
675 parent_->Send(message); | 698 parent_->Send(message); |
676 } | 699 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 | 877 |
855 *ec = 0; | 878 *ec = 0; |
856 scoped_ptr<WebIDBCallbacks> callbacks( | 879 scoped_ptr<WebIDBCallbacks> callbacks( |
857 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); | 880 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); |
858 idb_object_store->openCursor( | 881 idb_object_store->openCursor( |
859 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 882 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
860 params.upper_open), | 883 params.upper_open), |
861 params.direction, callbacks.release(), *idb_transaction, *ec); | 884 params.direction, callbacks.release(), *idb_transaction, *ec); |
862 } | 885 } |
863 | 886 |
| 887 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCount( |
| 888 const IndexedDBHostMsg_ObjectStoreCount_Params& params, |
| 889 WebKit::WebExceptionCode* ec) { |
| 890 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 891 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 892 &parent_->object_store_dispatcher_host_->map_, |
| 893 params.idb_object_store_id); |
| 894 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 895 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
| 896 if (!idb_transaction || !idb_object_store) |
| 897 return; |
| 898 |
| 899 *ec = 0; |
| 900 scoped_ptr<WebIDBCallbacks> callbacks( |
| 901 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, |
| 902 params.response_id)); |
| 903 idb_object_store->count( |
| 904 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 905 params.upper_open), |
| 906 callbacks.release(), *idb_transaction, *ec); |
| 907 } |
| 908 |
864 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( | 909 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( |
865 int32 object_id) { | 910 int32 object_id) { |
866 parent_->DestroyObject(&map_, object_id); | 911 parent_->DestroyObject(&map_, object_id); |
867 } | 912 } |
868 | 913 |
869 ////////////////////////////////////////////////////////////////////// | 914 ////////////////////////////////////////////////////////////////////// |
870 // IndexedDBDispatcherHost::CursorDispatcherHost | 915 // IndexedDBDispatcherHost::CursorDispatcherHost |
871 // | 916 // |
872 | 917 |
873 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( | 918 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 } | 1151 } |
1107 idb_transaction->didCompleteTaskEvents(); | 1152 idb_transaction->didCompleteTaskEvents(); |
1108 } | 1153 } |
1109 | 1154 |
1110 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1155 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
1111 int32 object_id) { | 1156 int32 object_id) { |
1112 transaction_size_map_.erase(object_id); | 1157 transaction_size_map_.erase(object_id); |
1113 transaction_url_map_.erase(object_id); | 1158 transaction_url_map_.erase(object_id); |
1114 parent_->DestroyObject(&map_, object_id); | 1159 parent_->DestroyObject(&map_, object_id); |
1115 } | 1160 } |
OLD | NEW |