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 parent_->HostTransactionId(params.transaction_id), |
| 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(parent_->HostTransactionId(transaction_id), |
| 499 object_store_id); |
460 } | 500 } |
461 | 501 |
462 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( | 502 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( |
463 int32 ipc_thread_id, | 503 int32 ipc_thread_id, |
464 int32 ipc_database_id, | 504 int32 ipc_database_id, |
465 int64 transaction_id, | 505 int64 transaction_id, |
466 const std::vector<int64>& object_store_ids, | 506 const std::vector<int64>& object_store_ids, |
467 int32 mode, | 507 int32 mode, |
468 int32* ipc_transaction_id) { | 508 int32* ipc_transaction_id) { |
469 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 509 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 | 683 |
644 scoped_ptr<WebIDBCallbacks> callbacks( | 684 scoped_ptr<WebIDBCallbacks> callbacks( |
645 new IndexedDBCallbacks<WebSerializedScriptValue>( | 685 new IndexedDBCallbacks<WebSerializedScriptValue>( |
646 parent_, ipc_thread_id, | 686 parent_, ipc_thread_id, |
647 ipc_response_id)); | 687 ipc_response_id)); |
648 | 688 |
649 database->clear(parent_->HostTransactionId(transaction_id), | 689 database->clear(parent_->HostTransactionId(transaction_id), |
650 object_store_id, callbacks.release()); | 690 object_store_id, callbacks.release()); |
651 } | 691 } |
652 | 692 |
| 693 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex( |
| 694 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) { |
| 695 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 696 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 697 &map_, params.ipc_database_id); |
| 698 if (!database) |
| 699 return; |
| 700 |
| 701 database->createIndex( |
| 702 parent_->HostTransactionId(params.transaction_id), |
| 703 params.object_store_id, |
| 704 params.index_id, |
| 705 params.name, |
| 706 params.key_path, |
| 707 params.unique, |
| 708 params.multi_entry); |
| 709 if (parent_->Context()->IsOverQuota( |
| 710 database_url_map_[params.ipc_database_id])) { |
| 711 database->abort(params.transaction_id); |
| 712 } |
| 713 } |
| 714 |
| 715 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( |
| 716 int32 ipc_database_id, |
| 717 int64 transaction_id, |
| 718 int64 object_store_id, |
| 719 int64 index_id) { |
| 720 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 721 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 722 &map_, ipc_database_id); |
| 723 if (!database) |
| 724 return; |
| 725 |
| 726 database->deleteIndex(parent_->HostTransactionId(transaction_id), |
| 727 object_store_id, index_id); |
| 728 } |
| 729 |
| 730 |
653 ////////////////////////////////////////////////////////////////////// | 731 ////////////////////////////////////////////////////////////////////// |
654 // IndexedDBDispatcherHost::IndexDispatcherHost | 732 // IndexedDBDispatcherHost::IndexDispatcherHost |
655 // | 733 // |
656 | 734 |
657 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( | 735 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( |
658 IndexedDBDispatcherHost* parent) | 736 IndexedDBDispatcherHost* parent) |
659 : parent_(parent) { | 737 : parent_(parent) { |
660 map_.set_check_on_null_data(true); | 738 map_.set_check_on_null_data(true); |
661 } | 739 } |
662 | 740 |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1364 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
1287 int32 ipc_object_id) { | 1365 int32 ipc_object_id) { |
1288 // TODO(dgrogan): This doesn't seem to be happening with some version change | 1366 // TODO(dgrogan): This doesn't seem to be happening with some version change |
1289 // transactions. Possibly introduced with integer version support. | 1367 // transactions. Possibly introduced with integer version support. |
1290 transaction_ipc_size_map_.erase(ipc_object_id); | 1368 transaction_ipc_size_map_.erase(ipc_object_id); |
1291 transaction_url_map_.erase(ipc_object_id); | 1369 transaction_url_map_.erase(ipc_object_id); |
1292 parent_->DestroyObject(&map_, ipc_object_id); | 1370 parent_->DestroyObject(&map_, ipc_object_id); |
1293 } | 1371 } |
1294 | 1372 |
1295 } // namespace content | 1373 } // namespace content |
OLD | NEW |