| 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/indexed_db/indexed_db_dispatcher_host.h" | 5 #include "content/browser/indexed_db/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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 524 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 525 | 525 |
| 526 IndexedDBConnection* connection = | 526 IndexedDBConnection* connection = |
| 527 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 527 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 528 if (!connection || !connection->IsConnected()) | 528 if (!connection || !connection->IsConnected()) |
| 529 return; | 529 return; |
| 530 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 530 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| 531 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); | 531 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| 532 | 532 |
| 533 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 533 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 534 if (params.index_ids.size() != params.index_keys.size()) { | |
| 535 connection->database()->Abort( | |
| 536 host_transaction_id, | |
| 537 IndexedDBDatabaseError( | |
| 538 blink::WebIDBDatabaseExceptionUnknownError, | |
| 539 "Malformed IPC message: index_ids.size() != index_keys.size()")); | |
| 540 parent_->BadMessageReceived(); | |
| 541 return; | |
| 542 } | |
| 543 | |
| 544 // TODO(alecflett): Avoid a copy here. | 534 // TODO(alecflett): Avoid a copy here. |
| 545 std::string value_copy(params.value); | 535 std::string value_copy(params.value); |
| 546 connection->database()->Put( | 536 connection->database()->Put( |
| 547 host_transaction_id, | 537 host_transaction_id, |
| 548 params.object_store_id, | 538 params.object_store_id, |
| 549 &value_copy, | 539 &value_copy, |
| 550 make_scoped_ptr(new IndexedDBKey(params.key)), | 540 make_scoped_ptr(new IndexedDBKey(params.key)), |
| 551 static_cast<IndexedDBDatabase::PutMode>(params.put_mode), | 541 static_cast<IndexedDBDatabase::PutMode>(params.put_mode), |
| 552 callbacks, | 542 callbacks, |
| 553 params.index_ids, | |
| 554 params.index_keys); | 543 params.index_keys); |
| 555 TransactionIDToSizeMap* map = | 544 TransactionIDToSizeMap* map = |
| 556 &parent_->database_dispatcher_host_->transaction_size_map_; | 545 &parent_->database_dispatcher_host_->transaction_size_map_; |
| 557 // Size can't be big enough to overflow because it represents the | 546 // Size can't be big enough to overflow because it represents the |
| 558 // actual bytes passed through IPC. | 547 // actual bytes passed through IPC. |
| 559 (*map)[host_transaction_id] += params.value.size(); | 548 (*map)[host_transaction_id] += params.value.size(); |
| 560 } | 549 } |
| 561 | 550 |
| 562 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( | 551 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( |
| 563 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { | 552 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { |
| 564 DCHECK( | 553 DCHECK( |
| 565 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 554 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 566 IndexedDBConnection* connection = | 555 IndexedDBConnection* connection = |
| 567 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 556 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 568 if (!connection || !connection->IsConnected()) | 557 if (!connection || !connection->IsConnected()) |
| 569 return; | 558 return; |
| 570 | 559 |
| 571 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 560 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 572 if (params.index_ids.size() != params.index_keys.size()) { | |
| 573 connection->database()->Abort( | |
| 574 host_transaction_id, | |
| 575 IndexedDBDatabaseError( | |
| 576 blink::WebIDBDatabaseExceptionUnknownError, | |
| 577 "Malformed IPC message: index_ids.size() != index_keys.size()")); | |
| 578 parent_->BadMessageReceived(); | |
| 579 return; | |
| 580 } | |
| 581 | |
| 582 connection->database()->SetIndexKeys( | 561 connection->database()->SetIndexKeys( |
| 583 host_transaction_id, | 562 host_transaction_id, |
| 584 params.object_store_id, | 563 params.object_store_id, |
| 585 make_scoped_ptr(new IndexedDBKey(params.primary_key)), | 564 make_scoped_ptr(new IndexedDBKey(params.primary_key)), |
| 586 params.index_ids, | |
| 587 params.index_keys); | 565 params.index_keys); |
| 588 } | 566 } |
| 589 | 567 |
| 590 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( | 568 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( |
| 591 int32 ipc_database_id, | 569 int32 ipc_database_id, |
| 592 int64 transaction_id, | 570 int64 transaction_id, |
| 593 int64 object_store_id, | 571 int64 object_store_id, |
| 594 const std::vector<int64>& index_ids) { | 572 const std::vector<int64>& index_ids) { |
| 595 DCHECK( | 573 DCHECK( |
| 596 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 574 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 } | 842 } |
| 865 | 843 |
| 866 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 844 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 867 int32 ipc_object_id) { | 845 int32 ipc_object_id) { |
| 868 DCHECK( | 846 DCHECK( |
| 869 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 847 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 870 parent_->DestroyObject(&map_, ipc_object_id); | 848 parent_->DestroyObject(&map_, ipc_object_id); |
| 871 } | 849 } |
| 872 | 850 |
| 873 } // namespace content | 851 } // namespace content |
| OLD | NEW |