| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 parent_->Context()->ConnectionClosed(iter->second); | 320 parent_->Context()->ConnectionClosed(iter->second); |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( | 324 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
| 325 const IPC::Message& message, bool* msg_is_ok) { | 325 const IPC::Message& message, bool* msg_is_ok) { |
| 326 bool handled = true; | 326 bool handled = true; |
| 327 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, | 327 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, |
| 328 message, *msg_is_ok) | 328 message, *msg_is_ok) |
| 329 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) | 329 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) |
| 330 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseName, OnName) | |
| 331 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersion, OnVersion) | |
| 332 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseObjectStoreNames, | |
| 333 OnObjectStoreNames) | |
| 334 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 330 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
| 335 OnCreateObjectStore) | 331 OnCreateObjectStore) |
| 336 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 332 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
| 337 OnDeleteObjectStore) | 333 OnDeleteObjectStore) |
| 338 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetVersion, OnSetVersion) | 334 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetVersion, OnSetVersion) |
| 339 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseTransaction, OnTransaction) | 335 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseTransaction, OnTransaction) |
| 340 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 336 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
| 341 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpen, OnOpen) | 337 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpen, OnOpen) |
| 342 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 338 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| 343 IPC_MESSAGE_UNHANDLED(handled = false) | 339 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 idb_index_metadata.name = web_index_metadata.name; | 372 idb_index_metadata.name = web_index_metadata.name; |
| 377 idb_index_metadata.keyPath = IndexedDBKeyPath(web_index_metadata.keyPath); | 373 idb_index_metadata.keyPath = IndexedDBKeyPath(web_index_metadata.keyPath); |
| 378 idb_index_metadata.unique = web_index_metadata.unique; | 374 idb_index_metadata.unique = web_index_metadata.unique; |
| 379 idb_index_metadata.multiEntry = web_index_metadata.multiEntry; | 375 idb_index_metadata.multiEntry = web_index_metadata.multiEntry; |
| 380 idb_store_metadata.indexes.push_back(idb_index_metadata); | 376 idb_store_metadata.indexes.push_back(idb_index_metadata); |
| 381 } | 377 } |
| 382 metadata->object_stores.push_back(idb_store_metadata); | 378 metadata->object_stores.push_back(idb_store_metadata); |
| 383 } | 379 } |
| 384 } | 380 } |
| 385 | 381 |
| 386 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnName( | |
| 387 int32 object_id, string16* name) { | |
| 388 parent_->SyncGetter<string16>(&map_, object_id, name, &WebIDBDatabase::name); | |
| 389 } | |
| 390 | |
| 391 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnVersion( | |
| 392 int32 object_id, string16* version) { | |
| 393 parent_->SyncGetter<string16>( | |
| 394 &map_, object_id, version, &WebIDBDatabase::version); | |
| 395 } | |
| 396 | |
| 397 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObjectStoreNames( | |
| 398 int32 idb_database_id, std::vector<string16>* object_stores) { | |
| 399 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | |
| 400 &map_, idb_database_id); | |
| 401 if (!idb_database) | |
| 402 return; | |
| 403 | |
| 404 WebDOMStringList web_object_stores = idb_database->objectStoreNames(); | |
| 405 object_stores->reserve(web_object_stores.length()); | |
| 406 for (unsigned i = 0; i < web_object_stores.length(); ++i) | |
| 407 object_stores->push_back(web_object_stores.item(i)); | |
| 408 } | |
| 409 | |
| 410 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( | 382 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( |
| 411 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params, | 383 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params, |
| 412 int32* object_store_id, WebKit::WebExceptionCode* ec) { | 384 int32* object_store_id, WebKit::WebExceptionCode* ec) { |
| 413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 414 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 386 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 415 &map_, params.idb_database_id); | 387 &map_, params.idb_database_id); |
| 416 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 388 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 417 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 389 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
| 418 if (!idb_database || !idb_transaction) | 390 if (!idb_database || !idb_transaction) |
| 419 return; | 391 return; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } | 503 } |
| 532 | 504 |
| 533 IndexedDBDispatcherHost::IndexDispatcherHost::~IndexDispatcherHost() { | 505 IndexedDBDispatcherHost::IndexDispatcherHost::~IndexDispatcherHost() { |
| 534 } | 506 } |
| 535 | 507 |
| 536 bool IndexedDBDispatcherHost::IndexDispatcherHost::OnMessageReceived( | 508 bool IndexedDBDispatcherHost::IndexDispatcherHost::OnMessageReceived( |
| 537 const IPC::Message& message, bool* msg_is_ok) { | 509 const IPC::Message& message, bool* msg_is_ok) { |
| 538 bool handled = true; | 510 bool handled = true; |
| 539 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::IndexDispatcherHost, | 511 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::IndexDispatcherHost, |
| 540 message, *msg_is_ok) | 512 message, *msg_is_ok) |
| 541 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexName, OnName) | |
| 542 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexKeyPath, OnKeyPath) | |
| 543 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexUnique, OnUnique) | |
| 544 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexMultiEntry, OnMultiEntry) | |
| 545 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenObjectCursor, | 513 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenObjectCursor, |
| 546 OnOpenObjectCursor) | 514 OnOpenObjectCursor) |
| 547 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) | 515 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) |
| 548 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexCount, OnCount) | 516 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexCount, OnCount) |
| 549 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) | 517 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) |
| 550 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) | 518 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) |
| 551 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) | 519 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) |
| 552 IPC_MESSAGE_UNHANDLED(handled = false) | 520 IPC_MESSAGE_UNHANDLED(handled = false) |
| 553 IPC_END_MESSAGE_MAP() | 521 IPC_END_MESSAGE_MAP() |
| 554 return handled; | 522 return handled; |
| 555 } | 523 } |
| 556 | 524 |
| 557 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( | 525 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( |
| 558 IPC::Message* message) { | 526 IPC::Message* message) { |
| 559 parent_->Send(message); | 527 parent_->Send(message); |
| 560 } | 528 } |
| 561 | 529 |
| 562 void IndexedDBDispatcherHost::IndexDispatcherHost::OnName( | |
| 563 int32 object_id, string16* name) { | |
| 564 parent_->SyncGetter<string16>(&map_, object_id, name, &WebIDBIndex::name); | |
| 565 } | |
| 566 | |
| 567 void IndexedDBDispatcherHost::IndexDispatcherHost::OnKeyPath( | |
| 568 int32 object_id, IndexedDBKeyPath* key_path) { | |
| 569 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess(&map_, object_id); | |
| 570 if (!idb_index) | |
| 571 return; | |
| 572 | |
| 573 *key_path = IndexedDBKeyPath(idb_index->keyPath()); | |
| 574 } | |
| 575 | |
| 576 void IndexedDBDispatcherHost::IndexDispatcherHost::OnUnique( | |
| 577 int32 object_id, bool* unique) { | |
| 578 parent_->SyncGetter<bool>(&map_, object_id, unique, &WebIDBIndex::unique); | |
| 579 } | |
| 580 | |
| 581 void IndexedDBDispatcherHost::IndexDispatcherHost::OnMultiEntry( | |
| 582 int32 object_id, bool* multi_entry) { | |
| 583 parent_->SyncGetter<bool>( | |
| 584 &map_, object_id, multi_entry, &WebIDBIndex::multiEntry); | |
| 585 } | |
| 586 | |
| 587 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenObjectCursor( | 530 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenObjectCursor( |
| 588 const IndexedDBHostMsg_IndexOpenCursor_Params& params, | 531 const IndexedDBHostMsg_IndexOpenCursor_Params& params, |
| 589 WebKit::WebExceptionCode* ec) { | 532 WebKit::WebExceptionCode* ec) { |
| 590 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 591 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 534 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 592 &map_, params.idb_index_id); | 535 &map_, params.idb_index_id); |
| 593 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 536 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 594 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 537 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
| 595 if (!idb_transaction || !idb_index) | 538 if (!idb_transaction || !idb_index) |
| 596 return; | 539 return; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 | 647 |
| 705 IndexedDBDispatcherHost:: | 648 IndexedDBDispatcherHost:: |
| 706 ObjectStoreDispatcherHost::~ObjectStoreDispatcherHost() { | 649 ObjectStoreDispatcherHost::~ObjectStoreDispatcherHost() { |
| 707 } | 650 } |
| 708 | 651 |
| 709 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( | 652 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( |
| 710 const IPC::Message& message, bool* msg_is_ok) { | 653 const IPC::Message& message, bool* msg_is_ok) { |
| 711 bool handled = true; | 654 bool handled = true; |
| 712 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, | 655 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, |
| 713 message, *msg_is_ok) | 656 message, *msg_is_ok) |
| 714 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreName, OnName) | |
| 715 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) | |
| 716 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) | |
| 717 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreAutoIncrement, | |
| 718 OnAutoIncrement) | |
| 719 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) | 657 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) |
| 720 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) | 658 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) |
| 721 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) | 659 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) |
| 722 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) | 660 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) |
| 723 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) | 661 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) |
| 724 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) | 662 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) |
| 725 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) | 663 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) |
| 726 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) | 664 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) |
| 727 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) | 665 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) |
| 728 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) | 666 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) |
| 729 IPC_MESSAGE_UNHANDLED(handled = false) | 667 IPC_MESSAGE_UNHANDLED(handled = false) |
| 730 IPC_END_MESSAGE_MAP() | 668 IPC_END_MESSAGE_MAP() |
| 731 return handled; | 669 return handled; |
| 732 } | 670 } |
| 733 | 671 |
| 734 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::Send( | 672 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::Send( |
| 735 IPC::Message* message) { | 673 IPC::Message* message) { |
| 736 parent_->Send(message); | 674 parent_->Send(message); |
| 737 } | 675 } |
| 738 | 676 |
| 739 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnName( | |
| 740 int32 object_id, string16* name) { | |
| 741 parent_->SyncGetter<string16>( | |
| 742 &map_, object_id, name, &WebIDBObjectStore::name); | |
| 743 } | |
| 744 | |
| 745 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnKeyPath( | |
| 746 int32 object_id, IndexedDBKeyPath* key_path) { | |
| 747 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 748 &map_,object_id); | |
| 749 if (!idb_object_store) | |
| 750 return; | |
| 751 | |
| 752 *key_path = IndexedDBKeyPath(idb_object_store->keyPath()); | |
| 753 } | |
| 754 | |
| 755 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndexNames( | |
| 756 int32 idb_object_store_id, std::vector<string16>* index_names) { | |
| 757 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 758 &map_, idb_object_store_id); | |
| 759 if (!idb_object_store) | |
| 760 return; | |
| 761 | |
| 762 WebDOMStringList web_index_names = idb_object_store->indexNames(); | |
| 763 index_names->reserve(web_index_names.length()); | |
| 764 for (unsigned i = 0; i < web_index_names.length(); ++i) | |
| 765 index_names->push_back(web_index_names.item(i)); | |
| 766 } | |
| 767 | |
| 768 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnAutoIncrement( | |
| 769 int32 idb_object_store_id, bool* auto_increment) { | |
| 770 parent_->SyncGetter<bool>(&map_, idb_object_store_id, auto_increment, | |
| 771 &WebIDBObjectStore::autoIncrement); | |
| 772 } | |
| 773 | |
| 774 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( | 677 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( |
| 775 int idb_object_store_id, | 678 int idb_object_store_id, |
| 776 int32 thread_id, | 679 int32 thread_id, |
| 777 int32 response_id, | 680 int32 response_id, |
| 778 const IndexedDBKeyRange& key_range, | 681 const IndexedDBKeyRange& key_range, |
| 779 int32 transaction_id, | 682 int32 transaction_id, |
| 780 WebKit::WebExceptionCode* ec) { | 683 WebKit::WebExceptionCode* ec) { |
| 781 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 684 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 782 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 685 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 783 &map_, idb_object_store_id); | 686 &map_, idb_object_store_id); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 } | 1136 } |
| 1234 idb_transaction->didCompleteTaskEvents(); | 1137 idb_transaction->didCompleteTaskEvents(); |
| 1235 } | 1138 } |
| 1236 | 1139 |
| 1237 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1140 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1238 int32 object_id) { | 1141 int32 object_id) { |
| 1239 transaction_size_map_.erase(object_id); | 1142 transaction_size_map_.erase(object_id); |
| 1240 transaction_url_map_.erase(object_id); | 1143 transaction_url_map_.erase(object_id); |
| 1241 parent_->DestroyObject(&map_, object_id); | 1144 parent_->DestroyObject(&map_, object_id); |
| 1242 } | 1145 } |
| OLD | NEW |