| 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" |
| 11 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 11 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
| 12 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" | 12 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" |
| 13 #include "content/browser/in_process_webkit/indexed_db_transaction_callbacks.h" | 13 #include "content/browser/in_process_webkit/indexed_db_transaction_callbacks.h" |
| 14 #include "content/browser/renderer_host/render_message_filter.h" | 14 #include "content/browser/renderer_host/render_message_filter.h" |
| 15 #include "content/common/indexed_db/indexed_db_messages.h" | 15 #include "content/common/indexed_db/indexed_db_messages.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 19 #include "content/public/common/result_codes.h" | 19 #include "content/public/common/result_codes.h" |
| 20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h
" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h
" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" |
| 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/WebIDBMetadata.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" |
| 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 33 #include "webkit/database/database_util.h" | 34 #include "webkit/database/database_util.h" |
| 34 #include "webkit/glue/webkit_glue.h" | 35 #include "webkit/glue/webkit_glue.h" |
| 35 | 36 |
| 36 using content::BrowserMessageFilter; | 37 using content::BrowserMessageFilter; |
| 37 using content::BrowserThread; | 38 using content::BrowserThread; |
| 38 using content::IndexedDBKey; | 39 using content::IndexedDBKey; |
| 39 using content::IndexedDBKeyPath; | 40 using content::IndexedDBKeyPath; |
| 40 using content::IndexedDBKeyRange; | 41 using content::IndexedDBKeyRange; |
| 41 using content::UserMetricsAction; | 42 using content::UserMetricsAction; |
| 42 using content::SerializedScriptValue; | 43 using content::SerializedScriptValue; |
| 43 using webkit_database::DatabaseUtil; | 44 using webkit_database::DatabaseUtil; |
| 44 using WebKit::WebDOMStringList; | 45 using WebKit::WebDOMStringList; |
| 45 using WebKit::WebExceptionCode; | 46 using WebKit::WebExceptionCode; |
| 46 using WebKit::WebIDBCallbacks; | 47 using WebKit::WebIDBCallbacks; |
| 47 using WebKit::WebIDBCursor; | 48 using WebKit::WebIDBCursor; |
| 48 using WebKit::WebIDBDatabase; | 49 using WebKit::WebIDBDatabase; |
| 49 using WebKit::WebIDBDatabaseError; | 50 using WebKit::WebIDBDatabaseError; |
| 50 using WebKit::WebIDBIndex; | 51 using WebKit::WebIDBIndex; |
| 51 using WebKit::WebIDBKey; | 52 using WebKit::WebIDBKey; |
| 52 using WebKit::WebIDBKeyPath; | 53 using WebKit::WebIDBKeyPath; |
| 53 using WebKit::WebIDBKeyRange; | 54 using WebKit::WebIDBKeyRange; |
| 55 using WebKit::WebIDBMetadata; |
| 54 using WebKit::WebIDBObjectStore; | 56 using WebKit::WebIDBObjectStore; |
| 55 using WebKit::WebIDBTransaction; | 57 using WebKit::WebIDBTransaction; |
| 56 using WebKit::WebSecurityOrigin; | 58 using WebKit::WebSecurityOrigin; |
| 57 using WebKit::WebSerializedScriptValue; | 59 using WebKit::WebSerializedScriptValue; |
| 58 using WebKit::WebVector; | 60 using WebKit::WebVector; |
| 59 | 61 |
| 60 namespace { | 62 namespace { |
| 61 | 63 |
| 62 template <class T> | 64 template <class T> |
| 63 void DeleteOnWebKitThread(T* obj) { | 65 void DeleteOnWebKitThread(T* obj) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 database->close(); | 319 database->close(); |
| 318 parent_->Context()->ConnectionClosed(iter->second); | 320 parent_->Context()->ConnectionClosed(iter->second); |
| 319 } | 321 } |
| 320 } | 322 } |
| 321 | 323 |
| 322 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( | 324 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
| 323 const IPC::Message& message, bool* msg_is_ok) { | 325 const IPC::Message& message, bool* msg_is_ok) { |
| 324 bool handled = true; | 326 bool handled = true; |
| 325 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, | 327 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, |
| 326 message, *msg_is_ok) | 328 message, *msg_is_ok) |
| 329 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) |
| 327 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseName, OnName) | 330 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseName, OnName) |
| 328 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersion, OnVersion) | 331 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersion, OnVersion) |
| 329 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseObjectStoreNames, | 332 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseObjectStoreNames, |
| 330 OnObjectStoreNames) | 333 OnObjectStoreNames) |
| 331 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 334 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
| 332 OnCreateObjectStore) | 335 OnCreateObjectStore) |
| 333 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 336 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
| 334 OnDeleteObjectStore) | 337 OnDeleteObjectStore) |
| 335 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetVersion, OnSetVersion) | 338 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetVersion, OnSetVersion) |
| 336 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseTransaction, OnTransaction) | 339 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseTransaction, OnTransaction) |
| 337 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 340 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
| 338 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpen, OnOpen) | 341 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpen, OnOpen) |
| 339 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 342 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| 340 IPC_MESSAGE_UNHANDLED(handled = false) | 343 IPC_MESSAGE_UNHANDLED(handled = false) |
| 341 IPC_END_MESSAGE_MAP() | 344 IPC_END_MESSAGE_MAP() |
| 342 return handled; | 345 return handled; |
| 343 } | 346 } |
| 344 | 347 |
| 345 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( | 348 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( |
| 346 IPC::Message* message) { | 349 IPC::Message* message) { |
| 347 parent_->Send(message); | 350 parent_->Send(message); |
| 348 } | 351 } |
| 349 | 352 |
| 353 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMetadata( |
| 354 int32 idb_database_id, IndexedDBDatabaseMetadata* metadata) { |
| 355 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 356 &map_, idb_database_id); |
| 357 if (!idb_database) |
| 358 return; |
| 359 |
| 360 WebIDBMetadata web_metadata = idb_database->metadata(); |
| 361 metadata->name = web_metadata.name; |
| 362 metadata->version = web_metadata.version; |
| 363 |
| 364 for (size_t i = 0; i < web_metadata.objectStores.size(); ++i) { |
| 365 const WebIDBMetadata::ObjectStore& web_store_metadata = |
| 366 web_metadata.objectStores[i]; |
| 367 IndexedDBObjectStoreMetadata idb_store_metadata; |
| 368 idb_store_metadata.name = web_store_metadata.name; |
| 369 idb_store_metadata.keyPath = IndexedDBKeyPath(web_store_metadata.keyPath); |
| 370 idb_store_metadata.autoIncrement = web_store_metadata.autoIncrement; |
| 371 |
| 372 for (size_t j = 0; j < web_store_metadata.indexes.size(); ++j) { |
| 373 const WebIDBMetadata::Index& web_index_metadata = |
| 374 web_store_metadata.indexes[j]; |
| 375 IndexedDBIndexMetadata idb_index_metadata; |
| 376 idb_index_metadata.name = web_index_metadata.name; |
| 377 idb_index_metadata.keyPath = IndexedDBKeyPath(web_index_metadata.keyPath); |
| 378 idb_index_metadata.unique = web_index_metadata.unique; |
| 379 idb_index_metadata.multiEntry = web_index_metadata.multiEntry; |
| 380 idb_store_metadata.indexes.push_back(idb_index_metadata); |
| 381 } |
| 382 metadata->object_stores.push_back(idb_store_metadata); |
| 383 } |
| 384 } |
| 385 |
| 350 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnName( | 386 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnName( |
| 351 int32 object_id, string16* name) { | 387 int32 object_id, string16* name) { |
| 352 parent_->SyncGetter<string16>(&map_, object_id, name, &WebIDBDatabase::name); | 388 parent_->SyncGetter<string16>(&map_, object_id, name, &WebIDBDatabase::name); |
| 353 } | 389 } |
| 354 | 390 |
| 355 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnVersion( | 391 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnVersion( |
| 356 int32 object_id, string16* version) { | 392 int32 object_id, string16* version) { |
| 357 parent_->SyncGetter<string16>( | 393 parent_->SyncGetter<string16>( |
| 358 &map_, object_id, version, &WebIDBDatabase::version); | 394 &map_, object_id, version, &WebIDBDatabase::version); |
| 359 } | 395 } |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 } | 1257 } |
| 1222 idb_transaction->didCompleteTaskEvents(); | 1258 idb_transaction->didCompleteTaskEvents(); |
| 1223 } | 1259 } |
| 1224 | 1260 |
| 1225 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1261 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1226 int32 object_id) { | 1262 int32 object_id) { |
| 1227 transaction_size_map_.erase(object_id); | 1263 transaction_size_map_.erase(object_id); |
| 1228 transaction_url_map_.erase(object_id); | 1264 transaction_url_map_.erase(object_id); |
| 1229 parent_->DestroyObject(&map_, object_id); | 1265 parent_->DestroyObject(&map_, object_id); |
| 1230 } | 1266 } |
| OLD | NEW |