| 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 "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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexName, OnName) | 499 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexName, OnName) |
| 500 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexStoreName, OnStoreName) | 500 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexStoreName, OnStoreName) |
| 501 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexKeyPath, OnKeyPath) | 501 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexKeyPath, OnKeyPath) |
| 502 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexUnique, OnUnique) | 502 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexUnique, OnUnique) |
| 503 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexMultiEntry, OnMultiEntry) | 503 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexMultiEntry, OnMultiEntry) |
| 504 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenObjectCursor, | 504 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenObjectCursor, |
| 505 OnOpenObjectCursor) | 505 OnOpenObjectCursor) |
| 506 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) | 506 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) |
| 507 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexCount, OnCount) | 507 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexCount, OnCount) |
| 508 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) | 508 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) |
| 509 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObjectByRange, |
| 510 OnGetObjectByRange) |
| 509 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) | 511 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) |
| 512 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKeyByRange, OnGetKeyByRange) |
| 510 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) | 513 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) |
| 511 IPC_MESSAGE_UNHANDLED(handled = false) | 514 IPC_MESSAGE_UNHANDLED(handled = false) |
| 512 IPC_END_MESSAGE_MAP() | 515 IPC_END_MESSAGE_MAP() |
| 513 return handled; | 516 return handled; |
| 514 } | 517 } |
| 515 | 518 |
| 516 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( | 519 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( |
| 517 IPC::Message* message) { | 520 IPC::Message* message) { |
| 518 parent_->Send(message); | 521 parent_->Send(message); |
| 519 } | 522 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 if (!idb_transaction || !idb_index) | 628 if (!idb_transaction || !idb_index) |
| 626 return; | 629 return; |
| 627 | 630 |
| 628 *ec = 0; | 631 *ec = 0; |
| 629 scoped_ptr<WebIDBCallbacks> callbacks( | 632 scoped_ptr<WebIDBCallbacks> callbacks( |
| 630 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, | 633 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 631 response_id)); | 634 response_id)); |
| 632 idb_index->getObject(key, callbacks.release(), *idb_transaction, *ec); | 635 idb_index->getObject(key, callbacks.release(), *idb_transaction, *ec); |
| 633 } | 636 } |
| 634 | 637 |
| 638 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObjectByRange( |
| 639 int idb_index_id, |
| 640 int32 thread_id, |
| 641 int32 response_id, |
| 642 const IndexedDBKeyRange& key_range, |
| 643 int32 transaction_id, |
| 644 WebKit::WebExceptionCode* ec) { |
| 645 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 646 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 647 &map_, idb_index_id); |
| 648 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 649 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
| 650 if (!idb_transaction || !idb_index) |
| 651 return; |
| 652 |
| 653 *ec = 0; |
| 654 scoped_ptr<WebIDBCallbacks> callbacks( |
| 655 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 656 response_id)); |
| 657 idb_index->getObject(key_range, callbacks.release(), *idb_transaction, *ec); |
| 658 } |
| 659 |
| 635 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( | 660 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( |
| 636 int idb_index_id, | 661 int idb_index_id, |
| 637 int32 thread_id, | 662 int32 thread_id, |
| 638 int32 response_id, | 663 int32 response_id, |
| 639 const IndexedDBKey& key, | 664 const IndexedDBKey& key, |
| 640 int32 transaction_id, | 665 int32 transaction_id, |
| 641 WebKit::WebExceptionCode* ec) { | 666 WebKit::WebExceptionCode* ec) { |
| 642 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 643 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 668 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 644 &map_, idb_index_id); | 669 &map_, idb_index_id); |
| 645 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 670 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 646 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 671 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
| 647 if (!idb_transaction || !idb_index) | 672 if (!idb_transaction || !idb_index) |
| 648 return; | 673 return; |
| 649 | 674 |
| 650 *ec = 0; | 675 *ec = 0; |
| 651 scoped_ptr<WebIDBCallbacks> callbacks( | 676 scoped_ptr<WebIDBCallbacks> callbacks( |
| 652 new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id)); | 677 new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id)); |
| 653 idb_index->getKey(key, callbacks.release(), *idb_transaction, *ec); | 678 idb_index->getKey(key, callbacks.release(), *idb_transaction, *ec); |
| 654 } | 679 } |
| 655 | 680 |
| 681 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKeyByRange( |
| 682 int idb_index_id, |
| 683 int32 thread_id, |
| 684 int32 response_id, |
| 685 const IndexedDBKeyRange& key_range, |
| 686 int32 transaction_id, |
| 687 WebKit::WebExceptionCode* ec) { |
| 688 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 689 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 690 &map_, idb_index_id); |
| 691 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 692 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
| 693 if (!idb_transaction || !idb_index) |
| 694 return; |
| 695 |
| 696 *ec = 0; |
| 697 scoped_ptr<WebIDBCallbacks> callbacks( |
| 698 new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id)); |
| 699 idb_index->getKey(key_range, callbacks.release(), *idb_transaction, *ec); |
| 700 } |
| 701 |
| 656 void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( | 702 void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( |
| 657 int32 object_id) { | 703 int32 object_id) { |
| 658 parent_->DestroyObject(&map_, object_id); | 704 parent_->DestroyObject(&map_, object_id); |
| 659 } | 705 } |
| 660 | 706 |
| 661 ////////////////////////////////////////////////////////////////////// | 707 ////////////////////////////////////////////////////////////////////// |
| 662 // IndexedDBDispatcherHost::ObjectStoreDispatcherHost | 708 // IndexedDBDispatcherHost::ObjectStoreDispatcherHost |
| 663 // | 709 // |
| 664 | 710 |
| 665 IndexedDBDispatcherHost::ObjectStoreDispatcherHost::ObjectStoreDispatcherHost( | 711 IndexedDBDispatcherHost::ObjectStoreDispatcherHost::ObjectStoreDispatcherHost( |
| 666 IndexedDBDispatcherHost* parent) | 712 IndexedDBDispatcherHost* parent) |
| 667 : parent_(parent) { | 713 : parent_(parent) { |
| 668 map_.set_check_on_null_data(true); | 714 map_.set_check_on_null_data(true); |
| 669 } | 715 } |
| 670 | 716 |
| 671 IndexedDBDispatcherHost:: | 717 IndexedDBDispatcherHost:: |
| 672 ObjectStoreDispatcherHost::~ObjectStoreDispatcherHost() { | 718 ObjectStoreDispatcherHost::~ObjectStoreDispatcherHost() { |
| 673 } | 719 } |
| 674 | 720 |
| 675 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( | 721 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( |
| 676 const IPC::Message& message, bool* msg_is_ok) { | 722 const IPC::Message& message, bool* msg_is_ok) { |
| 677 bool handled = true; | 723 bool handled = true; |
| 678 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, | 724 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, |
| 679 message, *msg_is_ok) | 725 message, *msg_is_ok) |
| 680 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreName, OnName) | 726 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreName, OnName) |
| 681 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) | 727 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) |
| 682 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) | 728 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) |
| 683 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) | 729 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) |
| 730 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGetByRange, OnGetByRange) |
| 684 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) | 731 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) |
| 685 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) | 732 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) |
| 686 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteRange, OnDeleteRange) | 733 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteRange, OnDeleteRange) |
| 687 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) | 734 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) |
| 688 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) | 735 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) |
| 689 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) | 736 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) |
| 690 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) | 737 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) |
| 691 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) | 738 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) |
| 692 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) | 739 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) |
| 693 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) | 740 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 if (!idb_transaction || !idb_object_store) | 788 if (!idb_transaction || !idb_object_store) |
| 742 return; | 789 return; |
| 743 | 790 |
| 744 *ec = 0; | 791 *ec = 0; |
| 745 scoped_ptr<WebIDBCallbacks> callbacks( | 792 scoped_ptr<WebIDBCallbacks> callbacks( |
| 746 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, | 793 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 747 response_id)); | 794 response_id)); |
| 748 idb_object_store->get(key, callbacks.release(), *idb_transaction, *ec); | 795 idb_object_store->get(key, callbacks.release(), *idb_transaction, *ec); |
| 749 } | 796 } |
| 750 | 797 |
| 798 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGetByRange( |
| 799 int idb_object_store_id, |
| 800 int32 thread_id, |
| 801 int32 response_id, |
| 802 const IndexedDBKeyRange& key_range, |
| 803 int32 transaction_id, |
| 804 WebKit::WebExceptionCode* ec) { |
| 805 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 806 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 807 &map_, idb_object_store_id); |
| 808 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 809 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
| 810 if (!idb_transaction || !idb_object_store) |
| 811 return; |
| 812 |
| 813 *ec = 0; |
| 814 scoped_ptr<WebIDBCallbacks> callbacks( |
| 815 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 816 response_id)); |
| 817 idb_object_store->get(key_range, callbacks.release(), *idb_transaction, *ec); |
| 818 } |
| 819 |
| 751 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( | 820 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( |
| 752 const IndexedDBHostMsg_ObjectStorePut_Params& params, | 821 const IndexedDBHostMsg_ObjectStorePut_Params& params, |
| 753 WebKit::WebExceptionCode* ec) { | 822 WebKit::WebExceptionCode* ec) { |
| 754 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 823 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 755 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 824 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 756 &map_, params.idb_object_store_id); | 825 &map_, params.idb_object_store_id); |
| 757 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 826 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 758 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 827 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
| 759 if (!idb_transaction || !idb_object_store) | 828 if (!idb_transaction || !idb_object_store) |
| 760 return; | 829 return; |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 } | 1262 } |
| 1194 idb_transaction->didCompleteTaskEvents(); | 1263 idb_transaction->didCompleteTaskEvents(); |
| 1195 } | 1264 } |
| 1196 | 1265 |
| 1197 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1266 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1198 int32 object_id) { | 1267 int32 object_id) { |
| 1199 transaction_size_map_.erase(object_id); | 1268 transaction_size_map_.erase(object_id); |
| 1200 transaction_url_map_.erase(object_id); | 1269 transaction_url_map_.erase(object_id); |
| 1201 parent_->DestroyObject(&map_, object_id); | 1270 parent_->DestroyObject(&map_, object_id); |
| 1202 } | 1271 } |
| OLD | NEW |