Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 message, *msg_is_ok) | 354 message, *msg_is_ok) |
| 355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) | 355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) |
| 356 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 356 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
| 357 OnCreateObjectStore) | 357 OnCreateObjectStore) |
| 358 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 358 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
| 359 OnDeleteObjectStore) | 359 OnDeleteObjectStore) |
| 360 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, | 360 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, |
| 361 OnCreateTransaction) | 361 OnCreateTransaction) |
| 362 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 362 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
| 363 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 363 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| 364 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) | |
| 365 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) | |
| 366 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, | |
| 367 OnSetIndexKeys) | |
| 368 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, | |
| 369 OnSetIndexesReady) | |
| 370 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) | |
| 371 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) | |
| 372 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDelete) | |
| 373 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) | |
| 364 IPC_MESSAGE_UNHANDLED(handled = false) | 374 IPC_MESSAGE_UNHANDLED(handled = false) |
| 365 IPC_END_MESSAGE_MAP() | 375 IPC_END_MESSAGE_MAP() |
| 366 return handled; | 376 return handled; |
| 367 } | 377 } |
| 368 | 378 |
| 369 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( | 379 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( |
| 370 IPC::Message* message) { | 380 IPC::Message* message) { |
| 371 parent_->Send(message); | 381 parent_->Send(message); |
| 372 } | 382 } |
| 373 | 383 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 | 494 |
| 485 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( | 495 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( |
| 486 int32 ipc_object_id) { | 496 int32 ipc_object_id) { |
| 487 WebIDBDatabase* database = map_.Lookup(ipc_object_id); | 497 WebIDBDatabase* database = map_.Lookup(ipc_object_id); |
| 488 parent_->Context()->ConnectionClosed(database_url_map_[ipc_object_id], | 498 parent_->Context()->ConnectionClosed(database_url_map_[ipc_object_id], |
| 489 database); | 499 database); |
| 490 database_url_map_.erase(ipc_object_id); | 500 database_url_map_.erase(ipc_object_id); |
| 491 parent_->DestroyObject(&map_, ipc_object_id); | 501 parent_->DestroyObject(&map_, ipc_object_id); |
| 492 } | 502 } |
| 493 | 503 |
| 504 // XXX alecf | |
|
jsbell
2012/12/14 23:04:34
Don't forget to remove this.
| |
| 505 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( | |
| 506 const IndexedDBHostMsg_DatabaseGet_Params& params) { | |
| 507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 508 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 509 &map_, params.ipc_database_id); | |
| 510 if (!database) | |
| 511 return; | |
| 512 | |
| 513 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 514 new IndexedDBCallbacks<WebSerializedScriptValue>( | |
| 515 parent_, params.ipc_thread_id, | |
| 516 params.ipc_response_id)); | |
| 517 database->get(params.transaction_id, params.object_store_id, | |
| 518 params.index_id, | |
| 519 params.key_range, params.key_only, callbacks.release()); | |
| 520 } | |
| 521 | |
| 522 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( | |
| 523 const IndexedDBHostMsg_DatabasePut_Params& params) { | |
| 524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 525 | |
| 526 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 527 &map_, params.ipc_database_id); | |
| 528 if (!database) | |
| 529 return; | |
| 530 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 531 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, | |
| 532 params.ipc_response_id)); | |
| 533 | |
| 534 database->put(params.transaction_id, params.object_store_id, | |
| 535 params.value, params.key, | |
| 536 params.put_mode, callbacks.release(), | |
| 537 params.index_ids, | |
| 538 params.index_keys); | |
| 539 WebIDBTransactionIDToSizeMap* map = | |
| 540 &parent_->database_dispatcher_host_->transaction_size_map_; | |
| 541 // Size can't be big enough to overflow because it represents the | |
| 542 // actual bytes passed through IPC. | |
| 543 (*map)[params.transaction_id] += params.value.size(); | |
| 544 } | |
| 545 | |
| 546 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( | |
| 547 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { | |
| 548 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 549 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 550 &map_, params.ipc_database_id); | |
| 551 if (!database) | |
| 552 return; | |
| 553 | |
| 554 database->setIndexKeys(params.transaction_id, params.object_store_id, | |
| 555 params.primary_key, params.index_ids, | |
| 556 params.index_keys); | |
| 557 } | |
| 558 | |
| 559 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( | |
| 560 int32 ipc_database_id, | |
| 561 int64 transaction_id, | |
| 562 int64 object_store_id, | |
| 563 const std::vector<int64>& index_ids) { | |
| 564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 565 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 566 &map_, ipc_database_id); | |
| 567 if (!database) | |
| 568 return; | |
| 569 | |
| 570 database->setIndexesReady(transaction_id, object_store_id, | |
| 571 WebVector<long long>(index_ids)); | |
| 572 } | |
| 573 | |
| 574 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( | |
| 575 const IndexedDBHostMsg_DatabaseOpenCursor_Params& params) { | |
| 576 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 577 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 578 &map_, params.ipc_database_id); | |
| 579 if (!database) | |
| 580 return; | |
| 581 | |
| 582 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 583 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.ipc_thread_id, | |
| 584 params.ipc_response_id, -1)); | |
| 585 database->openCursor( | |
| 586 params.transaction_id, params.object_store_id, params.index_id, | |
| 587 params.key_range, params.direction, params.key_only, params.task_type, | |
| 588 callbacks.release()); | |
| 589 } | |
| 590 | |
| 591 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( | |
| 592 const IndexedDBHostMsg_DatabaseCount_Params& params) { | |
| 593 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 594 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 595 &map_, params.ipc_database_id); | |
| 596 if (!database) | |
| 597 return; | |
| 598 | |
| 599 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 600 new IndexedDBCallbacks<WebSerializedScriptValue>( | |
| 601 parent_, params.ipc_thread_id, | |
| 602 params.ipc_response_id)); | |
| 603 database->count( | |
| 604 params.transaction_id, params.object_store_id, params.index_id, | |
| 605 params.key_range, callbacks.release()); | |
| 606 } | |
| 607 | |
| 608 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDelete( | |
| 609 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) { | |
| 610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 611 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 612 &map_, params.ipc_database_id); | |
| 613 if (!database) | |
| 614 return; | |
| 615 | |
| 616 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 617 new IndexedDBCallbacks<WebSerializedScriptValue>( | |
| 618 parent_, params.ipc_thread_id, | |
| 619 params.ipc_response_id)); | |
| 620 database->deleteRange(params.transaction_id, params.object_store_id, | |
| 621 params.key_range, callbacks.release()); | |
| 622 } | |
| 623 | |
| 624 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( | |
| 625 int32 ipc_thread_id, | |
| 626 int32 ipc_response_id, | |
| 627 int32 ipc_database_id, | |
| 628 int64 transaction_id, | |
| 629 int64 object_store_id) { | |
| 630 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 631 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 632 &map_, ipc_database_id); | |
| 633 if (!database) | |
| 634 return; | |
| 635 | |
| 636 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 637 new IndexedDBCallbacks<WebSerializedScriptValue>( | |
| 638 parent_, ipc_thread_id, | |
| 639 ipc_response_id)); | |
| 640 | |
| 641 database->clear(transaction_id, object_store_id, callbacks.release()); | |
| 642 } | |
| 643 | |
| 644 // xxx end alecf | |
|
jsbell
2012/12/14 23:04:34
Don't forget to remove.
| |
| 494 | 645 |
| 495 ////////////////////////////////////////////////////////////////////// | 646 ////////////////////////////////////////////////////////////////////// |
| 496 // IndexedDBDispatcherHost::IndexDispatcherHost | 647 // IndexedDBDispatcherHost::IndexDispatcherHost |
| 497 // | 648 // |
| 498 | 649 |
| 499 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( | 650 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( |
| 500 IndexedDBDispatcherHost* parent) | 651 IndexedDBDispatcherHost* parent) |
| 501 : parent_(parent) { | 652 : parent_(parent) { |
| 502 map_.set_check_on_null_data(true); | 653 map_.set_check_on_null_data(true); |
| 503 } | 654 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 712 return; | 863 return; |
| 713 | 864 |
| 714 scoped_ptr<WebIDBCallbacks> callbacks( | 865 scoped_ptr<WebIDBCallbacks> callbacks( |
| 715 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, | 866 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, |
| 716 params.ipc_response_id)); | 867 params.ipc_response_id)); |
| 717 idb_object_store->put(params.serialized_value, params.key, | 868 idb_object_store->put(params.serialized_value, params.key, |
| 718 params.put_mode, callbacks.release(), | 869 params.put_mode, callbacks.release(), |
| 719 *idb_transaction, params.index_ids, | 870 *idb_transaction, params.index_ids, |
| 720 params.index_keys); | 871 params.index_keys); |
| 721 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); | 872 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); |
| 722 WebIDBTransactionIDToSizeMap* map = | 873 WebIDBTransactionIPCIDToSizeMap* map = |
| 723 &parent_->transaction_dispatcher_host_->transaction_size_map_; | 874 &parent_->transaction_dispatcher_host_->transaction_ipc_size_map_; |
| 724 (*map)[params.ipc_transaction_id] += size; | 875 (*map)[params.ipc_transaction_id] += size; |
| 725 } | 876 } |
| 726 | 877 |
| 727 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexKeys( | 878 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexKeys( |
| 728 int32 ipc_object_store_id, | 879 int32 ipc_object_store_id, |
| 729 const IndexedDBKey& primary_key, | 880 const IndexedDBKey& primary_key, |
| 730 const std::vector<int64>& index_names, | 881 const std::vector<int64>& index_names, |
| 731 const std::vector<std::vector<IndexedDBKey> >& index_keys, | 882 const std::vector<std::vector<IndexedDBKey> >& index_keys, |
| 732 int32 ipc_transaction_id) { | 883 int32 ipc_transaction_id) { |
| 733 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 884 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1076 int32 ipc_transaction_id) { | 1227 int32 ipc_transaction_id) { |
| 1077 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 1228 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 1078 &map_, ipc_transaction_id); | 1229 &map_, ipc_transaction_id); |
| 1079 if (!idb_transaction) | 1230 if (!idb_transaction) |
| 1080 return; | 1231 return; |
| 1081 | 1232 |
| 1082 // TODO(dgrogan): Tell the page the transaction aborted because of quota. | 1233 // TODO(dgrogan): Tell the page the transaction aborted because of quota. |
| 1083 // http://crbug.com/113118 | 1234 // http://crbug.com/113118 |
| 1084 if (parent_->Context()->WouldBeOverQuota( | 1235 if (parent_->Context()->WouldBeOverQuota( |
| 1085 transaction_url_map_[ipc_transaction_id], | 1236 transaction_url_map_[ipc_transaction_id], |
| 1086 transaction_size_map_[ipc_transaction_id])) { | 1237 transaction_ipc_size_map_[ipc_transaction_id])) { |
| 1087 idb_transaction->abort(); | 1238 idb_transaction->abort(); |
| 1088 return; | 1239 return; |
| 1089 } | 1240 } |
| 1090 | 1241 |
| 1091 idb_transaction->commit(); | 1242 idb_transaction->commit(); |
| 1092 } | 1243 } |
| 1093 | 1244 |
| 1094 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort( | 1245 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort( |
| 1095 int32 ipc_transaction_id) { | 1246 int32 ipc_transaction_id) { |
| 1096 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 1247 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1122 &map_, ipc_transaction_id); | 1273 &map_, ipc_transaction_id); |
| 1123 if (!idb_transaction) | 1274 if (!idb_transaction) |
| 1124 return; | 1275 return; |
| 1125 idb_transaction->didCompleteTaskEvents(); | 1276 idb_transaction->didCompleteTaskEvents(); |
| 1126 } | 1277 } |
| 1127 | 1278 |
| 1128 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1279 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1129 int32 ipc_object_id) { | 1280 int32 ipc_object_id) { |
| 1130 // TODO(dgrogan): This doesn't seem to be happening with some version change | 1281 // TODO(dgrogan): This doesn't seem to be happening with some version change |
| 1131 // transactions. Possibly introduced with integer version support. | 1282 // transactions. Possibly introduced with integer version support. |
| 1132 transaction_size_map_.erase(ipc_object_id); | 1283 transaction_ipc_size_map_.erase(ipc_object_id); |
| 1133 transaction_url_map_.erase(ipc_object_id); | 1284 transaction_url_map_.erase(ipc_object_id); |
| 1134 parent_->DestroyObject(&map_, ipc_object_id); | 1285 parent_->DestroyObject(&map_, ipc_object_id); |
| 1135 } | 1286 } |
| 1136 | 1287 |
| 1137 } // namespace content | 1288 } // namespace content |
| OLD | NEW |