| 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) | |
| 511 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) | 509 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) |
| 512 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKeyByRange, OnGetKeyByRange) | |
| 513 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) | 510 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) |
| 514 IPC_MESSAGE_UNHANDLED(handled = false) | 511 IPC_MESSAGE_UNHANDLED(handled = false) |
| 515 IPC_END_MESSAGE_MAP() | 512 IPC_END_MESSAGE_MAP() |
| 516 return handled; | 513 return handled; |
| 517 } | 514 } |
| 518 | 515 |
| 519 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( | 516 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( |
| 520 IPC::Message* message) { | 517 IPC::Message* message) { |
| 521 parent_->Send(message); | 518 parent_->Send(message); |
| 522 } | 519 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 idb_index->count( | 607 idb_index->count( |
| 611 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 608 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 612 params.upper_open), | 609 params.upper_open), |
| 613 callbacks.release(), *idb_transaction, *ec); | 610 callbacks.release(), *idb_transaction, *ec); |
| 614 } | 611 } |
| 615 | 612 |
| 616 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( | 613 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( |
| 617 int idb_index_id, | 614 int idb_index_id, |
| 618 int32 thread_id, | 615 int32 thread_id, |
| 619 int32 response_id, | 616 int32 response_id, |
| 620 const IndexedDBKey& key, | |
| 621 int32 transaction_id, | |
| 622 WebKit::WebExceptionCode* ec) { | |
| 623 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 624 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | |
| 625 &map_, idb_index_id); | |
| 626 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 627 &parent_->transaction_dispatcher_host_->map_, transaction_id); | |
| 628 if (!idb_transaction || !idb_index) | |
| 629 return; | |
| 630 | |
| 631 *ec = 0; | |
| 632 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 633 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, | |
| 634 response_id)); | |
| 635 idb_index->getObject(key, callbacks.release(), *idb_transaction, *ec); | |
| 636 } | |
| 637 | |
| 638 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObjectByRange( | |
| 639 int idb_index_id, | |
| 640 int32 thread_id, | |
| 641 int32 response_id, | |
| 642 const IndexedDBKeyRange& key_range, | 617 const IndexedDBKeyRange& key_range, |
| 643 int32 transaction_id, | 618 int32 transaction_id, |
| 644 WebKit::WebExceptionCode* ec) { | 619 WebKit::WebExceptionCode* ec) { |
| 645 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 620 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 646 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 621 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 647 &map_, idb_index_id); | 622 &map_, idb_index_id); |
| 648 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 623 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 649 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 624 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
| 650 if (!idb_transaction || !idb_index) | 625 if (!idb_transaction || !idb_index) |
| 651 return; | 626 return; |
| 652 | 627 |
| 653 *ec = 0; | 628 *ec = 0; |
| 654 scoped_ptr<WebIDBCallbacks> callbacks( | 629 scoped_ptr<WebIDBCallbacks> callbacks( |
| 655 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, | 630 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 656 response_id)); | 631 response_id)); |
| 657 idb_index->getObject(key_range, callbacks.release(), *idb_transaction, *ec); | 632 idb_index->getObject(key_range, callbacks.release(), *idb_transaction, *ec); |
| 658 } | 633 } |
| 659 | 634 |
| 660 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( | 635 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( |
| 661 int idb_index_id, | 636 int idb_index_id, |
| 662 int32 thread_id, | 637 int32 thread_id, |
| 663 int32 response_id, | 638 int32 response_id, |
| 664 const IndexedDBKey& key, | |
| 665 int32 transaction_id, | |
| 666 WebKit::WebExceptionCode* ec) { | |
| 667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 668 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | |
| 669 &map_, idb_index_id); | |
| 670 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 671 &parent_->transaction_dispatcher_host_->map_, transaction_id); | |
| 672 if (!idb_transaction || !idb_index) | |
| 673 return; | |
| 674 | |
| 675 *ec = 0; | |
| 676 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 677 new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id)); | |
| 678 idb_index->getKey(key, callbacks.release(), *idb_transaction, *ec); | |
| 679 } | |
| 680 | |
| 681 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKeyByRange( | |
| 682 int idb_index_id, | |
| 683 int32 thread_id, | |
| 684 int32 response_id, | |
| 685 const IndexedDBKeyRange& key_range, | 639 const IndexedDBKeyRange& key_range, |
| 686 int32 transaction_id, | 640 int32 transaction_id, |
| 687 WebKit::WebExceptionCode* ec) { | 641 WebKit::WebExceptionCode* ec) { |
| 688 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 642 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 689 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 643 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 690 &map_, idb_index_id); | 644 &map_, idb_index_id); |
| 691 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 645 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 692 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 646 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
| 693 if (!idb_transaction || !idb_index) | 647 if (!idb_transaction || !idb_index) |
| 694 return; | 648 return; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 720 | 674 |
| 721 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( | 675 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( |
| 722 const IPC::Message& message, bool* msg_is_ok) { | 676 const IPC::Message& message, bool* msg_is_ok) { |
| 723 bool handled = true; | 677 bool handled = true; |
| 724 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, | 678 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, |
| 725 message, *msg_is_ok) | 679 message, *msg_is_ok) |
| 726 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreName, OnName) | 680 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreName, OnName) |
| 727 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) | 681 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) |
| 728 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) | 682 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) |
| 729 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) | 683 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) |
| 730 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGetByRange, OnGetByRange) | |
| 731 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) | 684 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) |
| 732 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) | 685 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) |
| 733 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteRange, OnDeleteRange) | 686 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteRange, OnDeleteRange) |
| 734 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) | 687 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) |
| 735 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) | 688 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) |
| 736 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) | 689 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) |
| 737 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) | 690 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) |
| 738 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) | 691 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) |
| 739 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) | 692 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) |
| 740 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) | 693 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 770 WebDOMStringList web_index_names = idb_object_store->indexNames(); | 723 WebDOMStringList web_index_names = idb_object_store->indexNames(); |
| 771 index_names->reserve(web_index_names.length()); | 724 index_names->reserve(web_index_names.length()); |
| 772 for (unsigned i = 0; i < web_index_names.length(); ++i) | 725 for (unsigned i = 0; i < web_index_names.length(); ++i) |
| 773 index_names->push_back(web_index_names.item(i)); | 726 index_names->push_back(web_index_names.item(i)); |
| 774 } | 727 } |
| 775 | 728 |
| 776 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( | 729 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( |
| 777 int idb_object_store_id, | 730 int idb_object_store_id, |
| 778 int32 thread_id, | 731 int32 thread_id, |
| 779 int32 response_id, | 732 int32 response_id, |
| 780 const IndexedDBKey& key, | |
| 781 int32 transaction_id, | |
| 782 WebKit::WebExceptionCode* ec) { | |
| 783 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 784 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 785 &map_, idb_object_store_id); | |
| 786 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 787 &parent_->transaction_dispatcher_host_->map_, transaction_id); | |
| 788 if (!idb_transaction || !idb_object_store) | |
| 789 return; | |
| 790 | |
| 791 *ec = 0; | |
| 792 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 793 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, | |
| 794 response_id)); | |
| 795 idb_object_store->get(key, callbacks.release(), *idb_transaction, *ec); | |
| 796 } | |
| 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, | 733 const IndexedDBKeyRange& key_range, |
| 803 int32 transaction_id, | 734 int32 transaction_id, |
| 804 WebKit::WebExceptionCode* ec) { | 735 WebKit::WebExceptionCode* ec) { |
| 805 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 806 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 737 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 807 &map_, idb_object_store_id); | 738 &map_, idb_object_store_id); |
| 808 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 739 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 809 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 740 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
| 810 if (!idb_transaction || !idb_object_store) | 741 if (!idb_transaction || !idb_object_store) |
| 811 return; | 742 return; |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 } | 1193 } |
| 1263 idb_transaction->didCompleteTaskEvents(); | 1194 idb_transaction->didCompleteTaskEvents(); |
| 1264 } | 1195 } |
| 1265 | 1196 |
| 1266 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1197 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1267 int32 object_id) { | 1198 int32 object_id) { |
| 1268 transaction_size_map_.erase(object_id); | 1199 transaction_size_map_.erase(object_id); |
| 1269 transaction_url_map_.erase(object_id); | 1200 transaction_url_map_.erase(object_id); |
| 1270 parent_->DestroyObject(&map_, object_id); | 1201 parent_->DestroyObject(&map_, object_id); |
| 1271 } | 1202 } |
| OLD | NEW |