| 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" |
| 11 #include "base/process.h" | 11 #include "base/process.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" | 14 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
| 15 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 15 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
| 16 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" | 16 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" |
| 17 #include "content/browser/in_process_webkit/indexed_db_transaction_callbacks.h" | 17 #include "content/browser/in_process_webkit/indexed_db_transaction_callbacks.h" |
| 18 #include "content/browser/renderer_host/render_message_filter.h" | 18 #include "content/browser/renderer_host/render_message_filter.h" |
| 19 #include "content/common/indexed_db/indexed_db_messages.h" | 19 #include "content/common/indexed_db/indexed_db_messages.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/user_metrics.h" | 21 #include "content/public/browser/user_metrics.h" |
| 22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/common/result_codes.h" | 23 #include "content/public/common/result_codes.h" |
| 24 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac
ks.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac
ks.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h
" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseExcepti
on.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h" |
| 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h" |
| 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" |
| 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" |
| 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 36 #include "webkit/base/file_path_string_conversions.h" | 38 #include "webkit/base/file_path_string_conversions.h" |
| 37 #include "webkit/database/database_util.h" | 39 #include "webkit/database/database_util.h" |
| 38 | 40 |
| 39 using webkit_database::DatabaseUtil; | 41 using webkit_database::DatabaseUtil; |
| 40 using WebKit::WebDOMStringList; | 42 using WebKit::WebDOMStringList; |
| 41 using WebKit::WebExceptionCode; | 43 using WebKit::WebExceptionCode; |
| 42 using WebKit::WebIDBCallbacks; | 44 using WebKit::WebIDBCallbacks; |
| 43 using WebKit::WebIDBCursor; | 45 using WebKit::WebIDBCursor; |
| 44 using WebKit::WebIDBDatabase; | 46 using WebKit::WebIDBDatabase; |
| 47 using WebKit::WebIDBDatabaseError; |
| 45 using WebKit::WebIDBIndex; | 48 using WebKit::WebIDBIndex; |
| 46 using WebKit::WebIDBKey; | 49 using WebKit::WebIDBKey; |
| 47 using WebKit::WebIDBMetadata; | 50 using WebKit::WebIDBMetadata; |
| 48 using WebKit::WebIDBObjectStore; | 51 using WebKit::WebIDBObjectStore; |
| 49 using WebKit::WebIDBTransaction; | 52 using WebKit::WebIDBTransaction; |
| 50 using WebKit::WebSecurityOrigin; | 53 using WebKit::WebSecurityOrigin; |
| 51 using WebKit::WebSerializedScriptValue; | 54 using WebKit::WebSerializedScriptValue; |
| 52 using WebKit::WebVector; | 55 using WebKit::WebVector; |
| 53 | 56 |
| 54 namespace content { | 57 namespace content { |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 710 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 708 &map_, params.ipc_object_store_id); | 711 &map_, params.ipc_object_store_id); |
| 709 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 712 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 710 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | 713 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); |
| 711 if (!idb_transaction || !idb_object_store) | 714 if (!idb_transaction || !idb_object_store) |
| 712 return; | 715 return; |
| 713 | 716 |
| 714 scoped_ptr<WebIDBCallbacks> callbacks( | 717 scoped_ptr<WebIDBCallbacks> callbacks( |
| 715 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, | 718 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, |
| 716 params.ipc_response_id)); | 719 params.ipc_response_id)); |
| 720 |
| 721 if (params.index_ids.size() != params.index_keys.size()) { |
| 722 callbacks->onError(WebIDBDatabaseError( |
| 723 WebKit::WebIDBDatabaseExceptionUnknownError, |
| 724 "Malformed IPC message: index_ids.size() != index_keys.size()")); |
| 725 return; |
| 726 } |
| 727 |
| 717 idb_object_store->put(params.serialized_value, params.key, | 728 idb_object_store->put(params.serialized_value, params.key, |
| 718 params.put_mode, callbacks.release(), | 729 params.put_mode, callbacks.release(), |
| 719 *idb_transaction, params.index_ids, | 730 *idb_transaction, params.index_ids, |
| 720 params.index_keys); | 731 params.index_keys); |
| 721 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); | 732 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); |
| 722 WebIDBTransactionIDToSizeMap* map = | 733 WebIDBTransactionIDToSizeMap* map = |
| 723 &parent_->transaction_dispatcher_host_->transaction_size_map_; | 734 &parent_->transaction_dispatcher_host_->transaction_size_map_; |
| 724 (*map)[params.ipc_transaction_id] += size; | 735 (*map)[params.ipc_transaction_id] += size; |
| 725 } | 736 } |
| 726 | 737 |
| 727 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexKeys( | 738 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexKeys( |
| 728 int32 ipc_object_store_id, | 739 int32 ipc_object_store_id, |
| 729 const IndexedDBKey& primary_key, | 740 const IndexedDBKey& primary_key, |
| 730 const std::vector<int64>& index_names, | 741 const std::vector<int64>& index_names, |
| 731 const std::vector<std::vector<IndexedDBKey> >& index_keys, | 742 const std::vector<std::vector<IndexedDBKey> >& index_keys, |
| 732 int32 ipc_transaction_id) { | 743 int32 ipc_transaction_id) { |
| 733 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 744 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 734 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 745 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 735 &map_, ipc_object_store_id); | 746 &map_, ipc_object_store_id); |
| 736 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 747 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 737 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | 748 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); |
| 749 |
| 750 if (index_names.size() != index_keys.size()) { |
| 751 idb_transaction->abort(); |
| 752 return; |
| 753 } |
| 754 |
| 738 if (!idb_transaction || !idb_object_store) | 755 if (!idb_transaction || !idb_object_store) |
| 739 return; | 756 return; |
| 740 idb_object_store->setIndexKeys(primary_key, | 757 idb_object_store->setIndexKeys(primary_key, |
| 741 WebVector<long long>(index_names), | 758 WebVector<long long>(index_names), |
| 742 index_keys, *idb_transaction); | 759 index_keys, *idb_transaction); |
| 743 } | 760 } |
| 744 | 761 |
| 745 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexesReady( | 762 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexesReady( |
| 746 int32 ipc_object_store_id, | 763 int32 ipc_object_store_id, |
| 747 const std::vector<int64>& index_ids, | 764 const std::vector<int64>& index_ids, |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1145 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1129 int32 ipc_object_id) { | 1146 int32 ipc_object_id) { |
| 1130 // TODO(dgrogan): This doesn't seem to be happening with some version change | 1147 // TODO(dgrogan): This doesn't seem to be happening with some version change |
| 1131 // transactions. Possibly introduced with integer version support. | 1148 // transactions. Possibly introduced with integer version support. |
| 1132 transaction_size_map_.erase(ipc_object_id); | 1149 transaction_size_map_.erase(ipc_object_id); |
| 1133 transaction_url_map_.erase(ipc_object_id); | 1150 transaction_url_map_.erase(ipc_object_id); |
| 1134 parent_->DestroyObject(&map_, ipc_object_id); | 1151 parent_->DestroyObject(&map_, ipc_object_id); |
| 1135 } | 1152 } |
| 1136 | 1153 |
| 1137 } // namespace content | 1154 } // namespace content |
| OLD | NEW |