Chromium Code Reviews| 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" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( | 350 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
| 351 const IPC::Message& message, bool* msg_is_ok) { | 351 const IPC::Message& message, bool* msg_is_ok) { |
| 352 bool handled = true; | 352 bool handled = true; |
| 353 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, | 353 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, |
| 354 message, *msg_is_ok) | 354 message, *msg_is_ok) |
| 355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) | 355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) |
| 356 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStoreOld, | |
| 357 OnCreateObjectStoreOld) | |
| 356 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 358 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
| 357 OnCreateObjectStore) | 359 OnCreateObjectStore) |
| 358 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 360 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
| 359 OnDeleteObjectStore) | 361 OnDeleteObjectStore) |
| 362 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStoreOld, | |
| 363 OnDeleteObjectStoreOld) | |
| 360 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, | 364 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, |
| 361 OnCreateTransaction) | 365 OnCreateTransaction) |
| 362 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 366 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
| 363 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 367 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| 364 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) | 368 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) |
| 365 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) | 369 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) |
| 366 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, | 370 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, |
| 367 OnSetIndexKeys) | 371 OnSetIndexKeys) |
| 368 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, | 372 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, |
| 369 OnSetIndexesReady) | 373 OnSetIndexesReady) |
| 370 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) | 374 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) |
| 371 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) | 375 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) |
| 372 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) | 376 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) |
| 373 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) | 377 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) |
| 378 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex, | |
| 379 OnCreateIndex) | |
| 380 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteIndex, | |
| 381 OnDeleteIndex) | |
| 374 IPC_MESSAGE_UNHANDLED(handled = false) | 382 IPC_MESSAGE_UNHANDLED(handled = false) |
| 375 IPC_END_MESSAGE_MAP() | 383 IPC_END_MESSAGE_MAP() |
| 376 return handled; | 384 return handled; |
| 377 } | 385 } |
| 378 | 386 |
| 379 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( | 387 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( |
| 380 IPC::Message* message) { | 388 IPC::Message* message) { |
| 381 parent_->Send(message); | 389 parent_->Send(message); |
| 382 } | 390 } |
| 383 | 391 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 413 idb_index_metadata.name = web_index_metadata.name; | 421 idb_index_metadata.name = web_index_metadata.name; |
| 414 idb_index_metadata.keyPath = IndexedDBKeyPath(web_index_metadata.keyPath); | 422 idb_index_metadata.keyPath = IndexedDBKeyPath(web_index_metadata.keyPath); |
| 415 idb_index_metadata.unique = web_index_metadata.unique; | 423 idb_index_metadata.unique = web_index_metadata.unique; |
| 416 idb_index_metadata.multiEntry = web_index_metadata.multiEntry; | 424 idb_index_metadata.multiEntry = web_index_metadata.multiEntry; |
| 417 idb_store_metadata.indexes.push_back(idb_index_metadata); | 425 idb_store_metadata.indexes.push_back(idb_index_metadata); |
| 418 } | 426 } |
| 419 metadata->object_stores.push_back(idb_store_metadata); | 427 metadata->object_stores.push_back(idb_store_metadata); |
| 420 } | 428 } |
| 421 } | 429 } |
| 422 | 430 |
| 423 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( | 431 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStoreOld( |
| 424 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params, | 432 const IndexedDBHostMsg_DatabaseCreateObjectStoreOld_Params& params, |
| 425 int32* object_store_id, WebKit::WebExceptionCode* ec) { | 433 int32* object_store_id, WebKit::WebExceptionCode* ec) { |
| 426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 427 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 435 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 428 &map_, params.ipc_database_id); | 436 &map_, params.ipc_database_id); |
| 429 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 437 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 430 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | 438 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); |
| 431 if (!idb_database || !idb_transaction) | 439 if (!idb_database || !idb_transaction) |
| 432 return; | 440 return; |
| 433 | 441 |
| 434 *ec = 0; | 442 *ec = 0; |
| 435 WebIDBObjectStore* object_store = idb_database->createObjectStore( | 443 WebIDBObjectStore* object_store = idb_database->createObjectStore( |
| 436 params.id, params.name, params.key_path, params.auto_increment, | 444 params.id, params.name, params.key_path, params.auto_increment, |
| 437 *idb_transaction, *ec); | 445 *idb_transaction, *ec); |
| 438 *object_store_id = *ec ? 0 : parent_->Add(object_store); | 446 *object_store_id = *ec ? 0 : parent_->Add(object_store); |
| 439 if (parent_->Context()->IsOverQuota( | 447 if (parent_->Context()->IsOverQuota( |
| 440 database_url_map_[params.ipc_database_id])) { | 448 database_url_map_[params.ipc_database_id])) { |
| 441 idb_transaction->abort(); | 449 idb_transaction->abort(); |
| 442 } | 450 } |
| 443 } | 451 } |
| 444 | 452 |
| 445 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( | 453 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( |
| 454 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) { | |
| 455 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 456 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 457 &map_, params.ipc_database_id); | |
| 458 if (!database) | |
| 459 return; | |
| 460 | |
| 461 database->createObjectStore( | |
| 462 params.transaction_id, | |
|
jsbell
2013/01/08 18:44:36
Doesn't this need to be parent_->HostTransactionId
| |
| 463 params.object_store_id, | |
| 464 params.name, params.key_path, params.auto_increment); | |
| 465 if (parent_->Context()->IsOverQuota( | |
| 466 database_url_map_[params.ipc_database_id])) { | |
| 467 database->abort(params.transaction_id); | |
| 468 } | |
| 469 } | |
| 470 | |
| 471 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStoreOld( | |
| 446 int32 ipc_database_id, | 472 int32 ipc_database_id, |
| 447 int64 index_id, | 473 int64 object_store_id, |
| 448 int32 ipc_transaction_id, | 474 int32 ipc_transaction_id, |
| 449 WebKit::WebExceptionCode* ec) { | 475 WebKit::WebExceptionCode* ec) { |
| 450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 451 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 477 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 452 &map_, ipc_database_id); | 478 &map_, ipc_database_id); |
| 453 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 479 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 454 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | 480 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); |
| 455 if (!idb_database || !idb_transaction) | 481 if (!idb_database || !idb_transaction) |
| 456 return; | 482 return; |
| 457 | 483 |
| 458 *ec = 0; | 484 *ec = 0; |
| 459 idb_database->deleteObjectStore(index_id, *idb_transaction, *ec); | 485 idb_database->deleteObjectStore(object_store_id, *idb_transaction, *ec); |
| 486 } | |
| 487 | |
| 488 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( | |
| 489 int32 ipc_database_id, | |
| 490 int64 transaction_id, | |
| 491 int64 object_store_id) { | |
| 492 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 493 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 494 &map_, ipc_database_id); | |
| 495 if (!database) | |
| 496 return; | |
| 497 | |
| 498 database->deleteObjectStore(transaction_id, object_store_id); | |
|
jsbell
2013/01/08 18:44:36
Ditto
| |
| 460 } | 499 } |
| 461 | 500 |
| 462 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( | 501 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( |
| 463 int32 ipc_thread_id, | 502 int32 ipc_thread_id, |
| 464 int32 ipc_database_id, | 503 int32 ipc_database_id, |
| 465 int64 transaction_id, | 504 int64 transaction_id, |
| 466 const std::vector<int64>& object_store_ids, | 505 const std::vector<int64>& object_store_ids, |
| 467 int32 mode, | 506 int32 mode, |
| 468 int32* ipc_transaction_id) { | 507 int32* ipc_transaction_id) { |
| 469 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 508 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 | 682 |
| 644 scoped_ptr<WebIDBCallbacks> callbacks( | 683 scoped_ptr<WebIDBCallbacks> callbacks( |
| 645 new IndexedDBCallbacks<WebSerializedScriptValue>( | 684 new IndexedDBCallbacks<WebSerializedScriptValue>( |
| 646 parent_, ipc_thread_id, | 685 parent_, ipc_thread_id, |
| 647 ipc_response_id)); | 686 ipc_response_id)); |
| 648 | 687 |
| 649 database->clear(parent_->HostTransactionId(transaction_id), | 688 database->clear(parent_->HostTransactionId(transaction_id), |
| 650 object_store_id, callbacks.release()); | 689 object_store_id, callbacks.release()); |
| 651 } | 690 } |
| 652 | 691 |
| 692 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex( | |
| 693 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) { | |
| 694 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 695 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 696 &map_, params.ipc_database_id); | |
| 697 if (!database) | |
| 698 return; | |
| 699 | |
| 700 database->createIndex( | |
| 701 params.transaction_id, | |
|
jsbell
2013/01/08 18:44:36
Ditto.
| |
| 702 params.object_store_id, | |
| 703 params.index_id, | |
| 704 params.name, | |
| 705 params.key_path, | |
| 706 params.unique, | |
| 707 params.multi_entry); | |
| 708 if (parent_->Context()->IsOverQuota( | |
| 709 database_url_map_[params.ipc_database_id])) { | |
| 710 database->abort(params.transaction_id); | |
| 711 } | |
| 712 } | |
| 713 | |
| 714 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( | |
| 715 int32 ipc_database_id, | |
| 716 int64 transaction_id, | |
| 717 int64 object_store_id, | |
| 718 int64 index_id) { | |
| 719 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 720 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 721 &map_, ipc_database_id); | |
| 722 if (!database) | |
| 723 return; | |
| 724 | |
| 725 database->deleteIndex(transaction_id, object_store_id, index_id); | |
|
jsbell
2013/01/08 18:44:36
Ditto.
| |
| 726 } | |
| 727 | |
| 728 | |
| 653 ////////////////////////////////////////////////////////////////////// | 729 ////////////////////////////////////////////////////////////////////// |
| 654 // IndexedDBDispatcherHost::IndexDispatcherHost | 730 // IndexedDBDispatcherHost::IndexDispatcherHost |
| 655 // | 731 // |
| 656 | 732 |
| 657 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( | 733 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( |
| 658 IndexedDBDispatcherHost* parent) | 734 IndexedDBDispatcherHost* parent) |
| 659 : parent_(parent) { | 735 : parent_(parent) { |
| 660 map_.set_check_on_null_data(true); | 736 map_.set_check_on_null_data(true); |
| 661 } | 737 } |
| 662 | 738 |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1362 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1287 int32 ipc_object_id) { | 1363 int32 ipc_object_id) { |
| 1288 // TODO(dgrogan): This doesn't seem to be happening with some version change | 1364 // TODO(dgrogan): This doesn't seem to be happening with some version change |
| 1289 // transactions. Possibly introduced with integer version support. | 1365 // transactions. Possibly introduced with integer version support. |
| 1290 transaction_ipc_size_map_.erase(ipc_object_id); | 1366 transaction_ipc_size_map_.erase(ipc_object_id); |
| 1291 transaction_url_map_.erase(ipc_object_id); | 1367 transaction_url_map_.erase(ipc_object_id); |
| 1292 parent_->DestroyObject(&map_, ipc_object_id); | 1368 parent_->DestroyObject(&map_, ipc_object_id); |
| 1293 } | 1369 } |
| 1294 | 1370 |
| 1295 } // namespace content | 1371 } // namespace content |
| OLD | NEW |