| 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 17 matching lines...) Expand all Loading... |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" |
| 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 33 #include "webkit/database/database_util.h" | 33 #include "webkit/database/database_util.h" |
| 34 #include "webkit/glue/webkit_glue.h" | 34 #include "webkit/glue/webkit_glue.h" |
| 35 | 35 |
| 36 using content::BrowserMessageFilter; | 36 using content::BrowserMessageFilter; |
| 37 using content::BrowserThread; | 37 using content::BrowserThread; |
| 38 using content::IndexedDBKey; |
| 39 using content::IndexedDBKeyPath; |
| 40 using content::IndexedDBKeyRange; |
| 38 using content::UserMetricsAction; | 41 using content::UserMetricsAction; |
| 42 using content::SerializedScriptValue; |
| 39 using webkit_database::DatabaseUtil; | 43 using webkit_database::DatabaseUtil; |
| 40 using WebKit::WebDOMStringList; | 44 using WebKit::WebDOMStringList; |
| 41 using WebKit::WebExceptionCode; | 45 using WebKit::WebExceptionCode; |
| 42 using WebKit::WebIDBCallbacks; | 46 using WebKit::WebIDBCallbacks; |
| 43 using WebKit::WebIDBCursor; | 47 using WebKit::WebIDBCursor; |
| 44 using WebKit::WebIDBDatabase; | 48 using WebKit::WebIDBDatabase; |
| 45 using WebKit::WebIDBDatabaseError; | 49 using WebKit::WebIDBDatabaseError; |
| 46 using WebKit::WebIDBIndex; | 50 using WebKit::WebIDBIndex; |
| 47 using WebKit::WebIDBKey; | 51 using WebKit::WebIDBKey; |
| 48 using WebKit::WebIDBKeyPath; | 52 using WebKit::WebIDBKeyPath; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 parent_->SyncGetter<string16>(&map_, object_id, name, &WebIDBIndex::name); | 529 parent_->SyncGetter<string16>(&map_, object_id, name, &WebIDBIndex::name); |
| 526 } | 530 } |
| 527 | 531 |
| 528 void IndexedDBDispatcherHost::IndexDispatcherHost::OnStoreName( | 532 void IndexedDBDispatcherHost::IndexDispatcherHost::OnStoreName( |
| 529 int32 object_id, string16* store_name) { | 533 int32 object_id, string16* store_name) { |
| 530 parent_->SyncGetter<string16>( | 534 parent_->SyncGetter<string16>( |
| 531 &map_, object_id, store_name, &WebIDBIndex::storeName); | 535 &map_, object_id, store_name, &WebIDBIndex::storeName); |
| 532 } | 536 } |
| 533 | 537 |
| 534 void IndexedDBDispatcherHost::IndexDispatcherHost::OnKeyPath( | 538 void IndexedDBDispatcherHost::IndexDispatcherHost::OnKeyPath( |
| 535 int32 object_id, content::IndexedDBKeyPath* key_path) { | 539 int32 object_id, IndexedDBKeyPath* key_path) { |
| 536 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess(&map_, object_id); | 540 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess(&map_, object_id); |
| 537 if (!idb_index) | 541 if (!idb_index) |
| 538 return; | 542 return; |
| 539 | 543 |
| 540 *key_path = content::IndexedDBKeyPath(idb_index->keyPath()); | 544 *key_path = IndexedDBKeyPath(idb_index->keyPath()); |
| 541 } | 545 } |
| 542 | 546 |
| 543 void IndexedDBDispatcherHost::IndexDispatcherHost::OnUnique( | 547 void IndexedDBDispatcherHost::IndexDispatcherHost::OnUnique( |
| 544 int32 object_id, bool* unique) { | 548 int32 object_id, bool* unique) { |
| 545 parent_->SyncGetter<bool>(&map_, object_id, unique, &WebIDBIndex::unique); | 549 parent_->SyncGetter<bool>(&map_, object_id, unique, &WebIDBIndex::unique); |
| 546 } | 550 } |
| 547 | 551 |
| 548 void IndexedDBDispatcherHost::IndexDispatcherHost::OnMultiEntry( | 552 void IndexedDBDispatcherHost::IndexDispatcherHost::OnMultiEntry( |
| 549 int32 object_id, bool* multi_entry) { | 553 int32 object_id, bool* multi_entry) { |
| 550 parent_->SyncGetter<bool>( | 554 parent_->SyncGetter<bool>( |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 parent_->Send(message); | 706 parent_->Send(message); |
| 703 } | 707 } |
| 704 | 708 |
| 705 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnName( | 709 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnName( |
| 706 int32 object_id, string16* name) { | 710 int32 object_id, string16* name) { |
| 707 parent_->SyncGetter<string16>( | 711 parent_->SyncGetter<string16>( |
| 708 &map_, object_id, name, &WebIDBObjectStore::name); | 712 &map_, object_id, name, &WebIDBObjectStore::name); |
| 709 } | 713 } |
| 710 | 714 |
| 711 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnKeyPath( | 715 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnKeyPath( |
| 712 int32 object_id, content::IndexedDBKeyPath* key_path) { | 716 int32 object_id, IndexedDBKeyPath* key_path) { |
| 713 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 717 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 714 &map_,object_id); | 718 &map_,object_id); |
| 715 if (!idb_object_store) | 719 if (!idb_object_store) |
| 716 return; | 720 return; |
| 717 | 721 |
| 718 *key_path = content::IndexedDBKeyPath(idb_object_store->keyPath()); | 722 *key_path = IndexedDBKeyPath(idb_object_store->keyPath()); |
| 719 } | 723 } |
| 720 | 724 |
| 721 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndexNames( | 725 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndexNames( |
| 722 int32 idb_object_store_id, std::vector<string16>* index_names) { | 726 int32 idb_object_store_id, std::vector<string16>* index_names) { |
| 723 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 727 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 724 &map_, idb_object_store_id); | 728 &map_, idb_object_store_id); |
| 725 if (!idb_object_store) | 729 if (!idb_object_store) |
| 726 return; | 730 return; |
| 727 | 731 |
| 728 WebDOMStringList web_index_names = idb_object_store->indexNames(); | 732 WebDOMStringList web_index_names = idb_object_store->indexNames(); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 int32 object_id, IndexedDBKey* primary_key) { | 1011 int32 object_id, IndexedDBKey* primary_key) { |
| 1008 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id); | 1012 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id); |
| 1009 if (!idb_cursor) | 1013 if (!idb_cursor) |
| 1010 return; | 1014 return; |
| 1011 | 1015 |
| 1012 *primary_key = IndexedDBKey(idb_cursor->primaryKey()); | 1016 *primary_key = IndexedDBKey(idb_cursor->primaryKey()); |
| 1013 } | 1017 } |
| 1014 | 1018 |
| 1015 void IndexedDBDispatcherHost::CursorDispatcherHost::OnValue( | 1019 void IndexedDBDispatcherHost::CursorDispatcherHost::OnValue( |
| 1016 int32 object_id, | 1020 int32 object_id, |
| 1017 content::SerializedScriptValue* script_value) { | 1021 SerializedScriptValue* script_value) { |
| 1018 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id); | 1022 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id); |
| 1019 if (!idb_cursor) | 1023 if (!idb_cursor) |
| 1020 return; | 1024 return; |
| 1021 | 1025 |
| 1022 *script_value = content::SerializedScriptValue(idb_cursor->value()); | 1026 *script_value = SerializedScriptValue(idb_cursor->value()); |
| 1023 } | 1027 } |
| 1024 | 1028 |
| 1025 void IndexedDBDispatcherHost::CursorDispatcherHost::OnUpdate( | 1029 void IndexedDBDispatcherHost::CursorDispatcherHost::OnUpdate( |
| 1026 int32 cursor_id, | 1030 int32 cursor_id, |
| 1027 int32 thread_id, | 1031 int32 thread_id, |
| 1028 int32 response_id, | 1032 int32 response_id, |
| 1029 const content::SerializedScriptValue& value, | 1033 const SerializedScriptValue& value, |
| 1030 WebKit::WebExceptionCode* ec) { | 1034 WebKit::WebExceptionCode* ec) { |
| 1031 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 1035 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 1032 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); | 1036 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); |
| 1033 if (!idb_cursor) | 1037 if (!idb_cursor) |
| 1034 return; | 1038 return; |
| 1035 | 1039 |
| 1036 *ec = 0; | 1040 *ec = 0; |
| 1037 idb_cursor->update( | 1041 idb_cursor->update( |
| 1038 value, new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id), | 1042 value, new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id), |
| 1039 *ec); | 1043 *ec); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 } | 1220 } |
| 1217 idb_transaction->didCompleteTaskEvents(); | 1221 idb_transaction->didCompleteTaskEvents(); |
| 1218 } | 1222 } |
| 1219 | 1223 |
| 1220 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1224 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1221 int32 object_id) { | 1225 int32 object_id) { |
| 1222 transaction_size_map_.erase(object_id); | 1226 transaction_size_map_.erase(object_id); |
| 1223 transaction_url_map_.erase(object_id); | 1227 transaction_url_map_.erase(object_id); |
| 1224 parent_->DestroyObject(&map_, object_id); | 1228 parent_->DestroyObject(&map_, object_id); |
| 1225 } | 1229 } |
| OLD | NEW |