| 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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "content/browser/indexed_db/indexed_db_callbacks.h" | 13 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
| 14 #include "content/browser/indexed_db/indexed_db_connection.h" | 14 #include "content/browser/indexed_db/indexed_db_connection.h" |
| 15 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 15 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 16 #include "content/browser/indexed_db/indexed_db_cursor.h" | 16 #include "content/browser/indexed_db/indexed_db_cursor.h" |
| 17 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | 17 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
| 18 #include "content/browser/indexed_db/indexed_db_metadata.h" | 18 #include "content/browser/indexed_db/indexed_db_metadata.h" |
| 19 #include "content/browser/indexed_db/indexed_db_pending_connection.h" | 19 #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
| 20 #include "content/browser/indexed_db/indexed_db_value.h" |
| 20 #include "content/browser/renderer_host/render_message_filter.h" | 21 #include "content/browser/renderer_host/render_message_filter.h" |
| 21 #include "content/common/indexed_db/indexed_db_messages.h" | 22 #include "content/common/indexed_db/indexed_db_messages.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
| 24 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
| 25 #include "content/public/common/result_codes.h" | 26 #include "content/public/common/result_codes.h" |
| 26 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" | 27 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" |
| 27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 28 #include "webkit/browser/database/database_util.h" | 29 #include "webkit/browser/database/database_util.h" |
| 29 #include "webkit/common/database/database_identifier.h" | 30 #include "webkit/common/database/database_identifier.h" |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 | 558 |
| 558 IndexedDBConnection* connection = | 559 IndexedDBConnection* connection = |
| 559 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 560 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 560 if (!connection || !connection->IsConnected()) | 561 if (!connection || !connection->IsConnected()) |
| 561 return; | 562 return; |
| 562 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 563 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
| 563 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); | 564 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| 564 | 565 |
| 565 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 566 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 566 // TODO(alecflett): Avoid a copy here. | 567 // TODO(alecflett): Avoid a copy here. |
| 567 std::string value_copy(params.value); | 568 IndexedDBValue value; |
| 569 value.bits = params.value; |
| 568 connection->database()->Put( | 570 connection->database()->Put( |
| 569 host_transaction_id, | 571 host_transaction_id, |
| 570 params.object_store_id, | 572 params.object_store_id, |
| 571 &value_copy, | 573 &value, |
| 572 make_scoped_ptr(new IndexedDBKey(params.key)), | 574 make_scoped_ptr(new IndexedDBKey(params.key)), |
| 573 static_cast<IndexedDBDatabase::PutMode>(params.put_mode), | 575 static_cast<IndexedDBDatabase::PutMode>(params.put_mode), |
| 574 callbacks, | 576 callbacks, |
| 575 params.index_keys); | 577 params.index_keys); |
| 576 TransactionIDToSizeMap* map = | 578 TransactionIDToSizeMap* map = |
| 577 &parent_->database_dispatcher_host_->transaction_size_map_; | 579 &parent_->database_dispatcher_host_->transaction_size_map_; |
| 578 // Size can't be big enough to overflow because it represents the | 580 // Size can't be big enough to overflow because it represents the |
| 579 // actual bytes passed through IPC. | 581 // actual bytes passed through IPC. |
| 580 (*map)[host_transaction_id] += params.value.size(); | 582 (*map)[host_transaction_id] += params.value.size(); |
| 581 } | 583 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 } | 876 } |
| 875 | 877 |
| 876 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 878 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 877 int32 ipc_object_id) { | 879 int32 ipc_object_id) { |
| 878 DCHECK( | 880 DCHECK( |
| 879 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 881 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 880 parent_->DestroyObject(&map_, ipc_object_id); | 882 parent_->DestroyObject(&map_, ipc_object_id); |
| 881 } | 883 } |
| 882 | 884 |
| 883 } // namespace content | 885 } // namespace content |
| OLD | NEW |