| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( | 73 ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( |
| 74 new TransactionDispatcherHost(this))), | 74 new TransactionDispatcherHost(this))), |
| 75 process_id_(process_id) { | 75 process_id_(process_id) { |
| 76 DCHECK(webkit_context_.get()); | 76 DCHECK(webkit_context_.get()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { | 79 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { |
| 80 } | 80 } |
| 81 | 81 |
| 82 void IndexedDBDispatcherHost::OnChannelClosing() { | 82 void IndexedDBDispatcherHost::OnChannelClosing() { |
| 83 BrowserMessageFilter::OnChannelClosing(); |
| 83 BrowserThread::DeleteSoon( | 84 BrowserThread::DeleteSoon( |
| 84 BrowserThread::WEBKIT, FROM_HERE, database_dispatcher_host_.release()); | 85 BrowserThread::WEBKIT, FROM_HERE, database_dispatcher_host_.release()); |
| 85 BrowserThread::DeleteSoon( | 86 BrowserThread::DeleteSoon( |
| 86 BrowserThread::WEBKIT, FROM_HERE, index_dispatcher_host_.release()); | 87 BrowserThread::WEBKIT, FROM_HERE, index_dispatcher_host_.release()); |
| 87 BrowserThread::DeleteSoon( | 88 BrowserThread::DeleteSoon( |
| 88 BrowserThread::WEBKIT, FROM_HERE, | 89 BrowserThread::WEBKIT, FROM_HERE, |
| 89 object_store_dispatcher_host_.release()); | 90 object_store_dispatcher_host_.release()); |
| 90 BrowserThread::DeleteSoon( | 91 BrowserThread::DeleteSoon( |
| 91 BrowserThread::WEBKIT, FROM_HERE, cursor_dispatcher_host_.release()); | 92 BrowserThread::WEBKIT, FROM_HERE, cursor_dispatcher_host_.release()); |
| 92 BrowserThread::DeleteSoon( | 93 BrowserThread::DeleteSoon( |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 309 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 309 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 310 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 310 &map_, params.idb_database_id, | 311 &map_, params.idb_database_id, |
| 311 IndexedDBHostMsg_DatabaseCreateObjectStore::ID); | 312 IndexedDBHostMsg_DatabaseCreateObjectStore::ID); |
| 312 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 313 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 313 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, | 314 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 314 IndexedDBHostMsg_DatabaseCreateObjectStore::ID); | 315 IndexedDBHostMsg_DatabaseCreateObjectStore::ID); |
| 315 if (!idb_database || !idb_transaction) | 316 if (!idb_database || !idb_transaction) |
| 316 return; | 317 return; |
| 317 | 318 |
| 319 *ec = 0; |
| 318 WebIDBObjectStore* object_store = idb_database->createObjectStore( | 320 WebIDBObjectStore* object_store = idb_database->createObjectStore( |
| 319 params.name, params.key_path, params.auto_increment, | 321 params.name, params.key_path, params.auto_increment, |
| 320 *idb_transaction, *ec); | 322 *idb_transaction, *ec); |
| 321 *object_store_id = *ec ? 0 : parent_->Add(object_store); | 323 *object_store_id = *ec ? 0 : parent_->Add(object_store); |
| 322 } | 324 } |
| 323 | 325 |
| 324 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( | 326 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( |
| 325 int32 idb_database_id, | 327 int32 idb_database_id, |
| 326 const string16& name, | 328 const string16& name, |
| 327 int32 transaction_id, | 329 int32 transaction_id, |
| 328 WebKit::WebExceptionCode* ec) { | 330 WebKit::WebExceptionCode* ec) { |
| 329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 330 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 332 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 331 &map_, idb_database_id, IndexedDBHostMsg_DatabaseDeleteObjectStore::ID); | 333 &map_, idb_database_id, IndexedDBHostMsg_DatabaseDeleteObjectStore::ID); |
| 332 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 334 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 333 &parent_->transaction_dispatcher_host_->map_, transaction_id, | 335 &parent_->transaction_dispatcher_host_->map_, transaction_id, |
| 334 IndexedDBHostMsg_DatabaseDeleteObjectStore::ID); | 336 IndexedDBHostMsg_DatabaseDeleteObjectStore::ID); |
| 335 if (!idb_database || !idb_transaction) | 337 if (!idb_database || !idb_transaction) |
| 336 return; | 338 return; |
| 337 | 339 |
| 340 *ec = 0; |
| 338 idb_database->deleteObjectStore(name, *idb_transaction, *ec); | 341 idb_database->deleteObjectStore(name, *idb_transaction, *ec); |
| 339 } | 342 } |
| 340 | 343 |
| 341 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetVersion( | 344 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetVersion( |
| 342 int32 idb_database_id, | 345 int32 idb_database_id, |
| 343 int32 response_id, | 346 int32 response_id, |
| 344 const string16& version, | 347 const string16& version, |
| 345 WebKit::WebExceptionCode* ec) { | 348 WebKit::WebExceptionCode* ec) { |
| 346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 347 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 350 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 348 &map_, idb_database_id, IndexedDBHostMsg_DatabaseSetVersion::ID); | 351 &map_, idb_database_id, IndexedDBHostMsg_DatabaseSetVersion::ID); |
| 349 if (!idb_database) | 352 if (!idb_database) |
| 350 return; | 353 return; |
| 351 | 354 |
| 355 *ec = 0; |
| 352 idb_database->setVersion( | 356 idb_database->setVersion( |
| 353 version, | 357 version, |
| 354 new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id), | 358 new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id), |
| 355 *ec); | 359 *ec); |
| 356 } | 360 } |
| 357 | 361 |
| 358 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( | 362 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( |
| 359 int32 idb_database_id, | 363 int32 idb_database_id, |
| 360 const std::vector<string16>& names, | 364 const std::vector<string16>& names, |
| 361 int32 mode, | 365 int32 mode, |
| 362 int32 timeout, | 366 int32 timeout, |
| 363 int32* idb_transaction_id, | 367 int32* idb_transaction_id, |
| 364 WebKit::WebExceptionCode* ec) { | 368 WebKit::WebExceptionCode* ec) { |
| 365 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 369 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 366 &map_, idb_database_id, IndexedDBHostMsg_DatabaseTransaction::ID); | 370 &map_, idb_database_id, IndexedDBHostMsg_DatabaseTransaction::ID); |
| 367 if (!database) | 371 if (!database) |
| 368 return; | 372 return; |
| 369 | 373 |
| 370 WebDOMStringList object_stores; | 374 WebDOMStringList object_stores; |
| 371 for (std::vector<string16>::const_iterator it = names.begin(); | 375 for (std::vector<string16>::const_iterator it = names.begin(); |
| 372 it != names.end(); ++it) { | 376 it != names.end(); ++it) { |
| 373 object_stores.append(*it); | 377 object_stores.append(*it); |
| 374 } | 378 } |
| 375 | 379 |
| 380 *ec = 0; |
| 376 WebIDBTransaction* transaction = database->transaction( | 381 WebIDBTransaction* transaction = database->transaction( |
| 377 object_stores, mode, timeout, *ec); | 382 object_stores, mode, timeout, *ec); |
| 378 DCHECK(!transaction != !*ec); | 383 DCHECK(!transaction != !*ec); |
| 379 *idb_transaction_id = *ec ? 0 : parent_->Add(transaction); | 384 *idb_transaction_id = *ec ? 0 : parent_->Add(transaction); |
| 380 } | 385 } |
| 381 | 386 |
| 382 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( | 387 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( |
| 383 int32 object_id) { | 388 int32 object_id) { |
| 384 parent_->DestroyObject(&map_, object_id, | 389 parent_->DestroyObject(&map_, object_id, |
| 385 IndexedDBHostMsg_DatabaseDestroyed::ID); | 390 IndexedDBHostMsg_DatabaseDestroyed::ID); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 WebKit::WebExceptionCode* ec) { | 458 WebKit::WebExceptionCode* ec) { |
| 454 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 455 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 460 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 456 &map_, params.idb_index_id, IndexedDBHostMsg_IndexOpenObjectCursor::ID); | 461 &map_, params.idb_index_id, IndexedDBHostMsg_IndexOpenObjectCursor::ID); |
| 457 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 462 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 458 &parent_->transaction_dispatcher_host_->map_, | 463 &parent_->transaction_dispatcher_host_->map_, |
| 459 params.transaction_id, IndexedDBHostMsg_IndexOpenObjectCursor::ID); | 464 params.transaction_id, IndexedDBHostMsg_IndexOpenObjectCursor::ID); |
| 460 if (!idb_transaction || !idb_index) | 465 if (!idb_transaction || !idb_index) |
| 461 return; | 466 return; |
| 462 | 467 |
| 468 *ec = 0; |
| 463 scoped_ptr<WebIDBCallbacks> callbacks( | 469 scoped_ptr<WebIDBCallbacks> callbacks( |
| 464 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); | 470 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); |
| 465 idb_index->openObjectCursor( | 471 idb_index->openObjectCursor( |
| 466 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 472 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 467 params.upper_open), | 473 params.upper_open), |
| 468 params.direction, callbacks.release(), *idb_transaction, *ec); | 474 params.direction, callbacks.release(), *idb_transaction, *ec); |
| 469 } | 475 } |
| 470 | 476 |
| 471 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( | 477 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( |
| 472 const IndexedDBHostMsg_IndexOpenCursor_Params& params, | 478 const IndexedDBHostMsg_IndexOpenCursor_Params& params, |
| 473 WebKit::WebExceptionCode* ec) { | 479 WebKit::WebExceptionCode* ec) { |
| 474 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 480 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 475 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 481 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 476 &map_, params.idb_index_id, IndexedDBHostMsg_IndexOpenKeyCursor::ID); | 482 &map_, params.idb_index_id, IndexedDBHostMsg_IndexOpenKeyCursor::ID); |
| 477 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 483 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 478 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, | 484 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 479 IndexedDBHostMsg_IndexOpenKeyCursor::ID); | 485 IndexedDBHostMsg_IndexOpenKeyCursor::ID); |
| 480 if (!idb_transaction || !idb_index) | 486 if (!idb_transaction || !idb_index) |
| 481 return; | 487 return; |
| 482 | 488 |
| 489 *ec = 0; |
| 483 scoped_ptr<WebIDBCallbacks> callbacks( | 490 scoped_ptr<WebIDBCallbacks> callbacks( |
| 484 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); | 491 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); |
| 485 idb_index->openKeyCursor( | 492 idb_index->openKeyCursor( |
| 486 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 493 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 487 params.upper_open), | 494 params.upper_open), |
| 488 params.direction, callbacks.release(), *idb_transaction, *ec); | 495 params.direction, callbacks.release(), *idb_transaction, *ec); |
| 489 } | 496 } |
| 490 | 497 |
| 491 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( | 498 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( |
| 492 int idb_index_id, | 499 int idb_index_id, |
| 493 int32 response_id, | 500 int32 response_id, |
| 494 const IndexedDBKey& key, | 501 const IndexedDBKey& key, |
| 495 int32 transaction_id, | 502 int32 transaction_id, |
| 496 WebKit::WebExceptionCode* ec) { | 503 WebKit::WebExceptionCode* ec) { |
| 497 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 504 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 498 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 505 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 499 &map_, idb_index_id, IndexedDBHostMsg_IndexGetObject::ID); | 506 &map_, idb_index_id, IndexedDBHostMsg_IndexGetObject::ID); |
| 500 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 507 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 501 &parent_->transaction_dispatcher_host_->map_, transaction_id, | 508 &parent_->transaction_dispatcher_host_->map_, transaction_id, |
| 502 IndexedDBHostMsg_IndexGetObject::ID); | 509 IndexedDBHostMsg_IndexGetObject::ID); |
| 503 if (!idb_transaction || !idb_index) | 510 if (!idb_transaction || !idb_index) |
| 504 return; | 511 return; |
| 505 | 512 |
| 513 *ec = 0; |
| 506 scoped_ptr<WebIDBCallbacks> callbacks( | 514 scoped_ptr<WebIDBCallbacks> callbacks( |
| 507 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); | 515 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); |
| 508 idb_index->getObject(key, callbacks.release(), *idb_transaction, *ec); | 516 idb_index->getObject(key, callbacks.release(), *idb_transaction, *ec); |
| 509 } | 517 } |
| 510 | 518 |
| 511 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( | 519 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( |
| 512 int idb_index_id, | 520 int idb_index_id, |
| 513 int32 response_id, | 521 int32 response_id, |
| 514 const IndexedDBKey& key, | 522 const IndexedDBKey& key, |
| 515 int32 transaction_id, | 523 int32 transaction_id, |
| 516 WebKit::WebExceptionCode* ec) { | 524 WebKit::WebExceptionCode* ec) { |
| 517 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 525 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 518 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 526 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 519 &map_, idb_index_id, IndexedDBHostMsg_IndexGetKey::ID); | 527 &map_, idb_index_id, IndexedDBHostMsg_IndexGetKey::ID); |
| 520 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 528 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 521 &parent_->transaction_dispatcher_host_->map_, transaction_id, | 529 &parent_->transaction_dispatcher_host_->map_, transaction_id, |
| 522 IndexedDBHostMsg_IndexGetKey::ID); | 530 IndexedDBHostMsg_IndexGetKey::ID); |
| 523 if (!idb_transaction || !idb_index) | 531 if (!idb_transaction || !idb_index) |
| 524 return; | 532 return; |
| 525 | 533 |
| 534 *ec = 0; |
| 526 scoped_ptr<WebIDBCallbacks> callbacks( | 535 scoped_ptr<WebIDBCallbacks> callbacks( |
| 527 new IndexedDBCallbacks<WebIDBKey>(parent_, response_id)); | 536 new IndexedDBCallbacks<WebIDBKey>(parent_, response_id)); |
| 528 idb_index->getKey(key, callbacks.release(), *idb_transaction, *ec); | 537 idb_index->getKey(key, callbacks.release(), *idb_transaction, *ec); |
| 529 } | 538 } |
| 530 | 539 |
| 531 void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( | 540 void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( |
| 532 int32 object_id) { | 541 int32 object_id) { |
| 533 parent_->DestroyObject(&map_, object_id, IndexedDBHostMsg_IndexDestroyed::ID); | 542 parent_->DestroyObject(&map_, object_id, IndexedDBHostMsg_IndexDestroyed::ID); |
| 534 } | 543 } |
| 535 | 544 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 WebKit::WebExceptionCode* ec) { | 615 WebKit::WebExceptionCode* ec) { |
| 607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 616 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 608 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 617 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 609 &map_, idb_object_store_id, IndexedDBHostMsg_ObjectStoreGet::ID); | 618 &map_, idb_object_store_id, IndexedDBHostMsg_ObjectStoreGet::ID); |
| 610 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 619 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 611 &parent_->transaction_dispatcher_host_->map_, transaction_id, | 620 &parent_->transaction_dispatcher_host_->map_, transaction_id, |
| 612 IndexedDBHostMsg_ObjectStoreGet::ID); | 621 IndexedDBHostMsg_ObjectStoreGet::ID); |
| 613 if (!idb_transaction || !idb_object_store) | 622 if (!idb_transaction || !idb_object_store) |
| 614 return; | 623 return; |
| 615 | 624 |
| 625 *ec = 0; |
| 616 scoped_ptr<WebIDBCallbacks> callbacks( | 626 scoped_ptr<WebIDBCallbacks> callbacks( |
| 617 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); | 627 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); |
| 618 idb_object_store->get(key, callbacks.release(), *idb_transaction, *ec); | 628 idb_object_store->get(key, callbacks.release(), *idb_transaction, *ec); |
| 619 } | 629 } |
| 620 | 630 |
| 621 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( | 631 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( |
| 622 const IndexedDBHostMsg_ObjectStorePut_Params& params, | 632 const IndexedDBHostMsg_ObjectStorePut_Params& params, |
| 623 WebKit::WebExceptionCode* ec) { | 633 WebKit::WebExceptionCode* ec) { |
| 624 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 634 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 625 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 635 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 626 &map_, params.idb_object_store_id, IndexedDBHostMsg_ObjectStorePut::ID); | 636 &map_, params.idb_object_store_id, IndexedDBHostMsg_ObjectStorePut::ID); |
| 627 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 637 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 628 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, | 638 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 629 IndexedDBHostMsg_ObjectStorePut::ID); | 639 IndexedDBHostMsg_ObjectStorePut::ID); |
| 630 if (!idb_transaction || !idb_object_store) | 640 if (!idb_transaction || !idb_object_store) |
| 631 return; | 641 return; |
| 632 | 642 |
| 643 *ec = 0; |
| 633 scoped_ptr<WebIDBCallbacks> callbacks( | 644 scoped_ptr<WebIDBCallbacks> callbacks( |
| 634 new IndexedDBCallbacks<WebIDBKey>(parent_, params.response_id)); | 645 new IndexedDBCallbacks<WebIDBKey>(parent_, params.response_id)); |
| 635 idb_object_store->put(params.serialized_value, params.key, params.add_only, | 646 idb_object_store->put(params.serialized_value, params.key, params.add_only, |
| 636 callbacks.release(), *idb_transaction, *ec); | 647 callbacks.release(), *idb_transaction, *ec); |
| 637 } | 648 } |
| 638 | 649 |
| 639 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( | 650 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( |
| 640 int idb_object_store_id, | 651 int idb_object_store_id, |
| 641 int32 response_id, | 652 int32 response_id, |
| 642 const IndexedDBKey& key, | 653 const IndexedDBKey& key, |
| 643 int32 transaction_id, | 654 int32 transaction_id, |
| 644 WebKit::WebExceptionCode* ec) { | 655 WebKit::WebExceptionCode* ec) { |
| 645 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 656 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 646 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 657 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 647 &map_, idb_object_store_id, IndexedDBHostMsg_ObjectStoreDelete::ID); | 658 &map_, idb_object_store_id, IndexedDBHostMsg_ObjectStoreDelete::ID); |
| 648 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 659 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 649 &parent_->transaction_dispatcher_host_->map_, transaction_id, | 660 &parent_->transaction_dispatcher_host_->map_, transaction_id, |
| 650 IndexedDBHostMsg_ObjectStoreDelete::ID); | 661 IndexedDBHostMsg_ObjectStoreDelete::ID); |
| 651 if (!idb_transaction || !idb_object_store) | 662 if (!idb_transaction || !idb_object_store) |
| 652 return; | 663 return; |
| 653 | 664 |
| 665 *ec = 0; |
| 654 scoped_ptr<WebIDBCallbacks> callbacks( | 666 scoped_ptr<WebIDBCallbacks> callbacks( |
| 655 new IndexedDBCallbacks<void>(parent_, response_id)); | 667 new IndexedDBCallbacks<void>(parent_, response_id)); |
| 656 idb_object_store->deleteFunction( | 668 idb_object_store->deleteFunction( |
| 657 key, callbacks.release(), *idb_transaction, *ec); | 669 key, callbacks.release(), *idb_transaction, *ec); |
| 658 } | 670 } |
| 659 | 671 |
| 660 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex( | 672 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex( |
| 661 const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params, | 673 const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params, |
| 662 int32* index_id, WebKit::WebExceptionCode* ec) { | 674 int32* index_id, WebKit::WebExceptionCode* ec) { |
| 663 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 675 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 664 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 676 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 665 &map_, params.idb_object_store_id, | 677 &map_, params.idb_object_store_id, |
| 666 IndexedDBHostMsg_ObjectStoreCreateIndex::ID); | 678 IndexedDBHostMsg_ObjectStoreCreateIndex::ID); |
| 667 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 679 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 668 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, | 680 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 669 IndexedDBHostMsg_ObjectStoreCreateIndex::ID); | 681 IndexedDBHostMsg_ObjectStoreCreateIndex::ID); |
| 670 if (!idb_object_store || !idb_transaction) | 682 if (!idb_object_store || !idb_transaction) |
| 671 return; | 683 return; |
| 672 | 684 |
| 685 *ec = 0; |
| 673 WebIDBIndex* index = idb_object_store->createIndex( | 686 WebIDBIndex* index = idb_object_store->createIndex( |
| 674 params.name, params.key_path, params.unique, *idb_transaction, *ec); | 687 params.name, params.key_path, params.unique, *idb_transaction, *ec); |
| 675 *index_id = *ec ? 0 : parent_->Add(index); | 688 *index_id = *ec ? 0 : parent_->Add(index); |
| 676 } | 689 } |
| 677 | 690 |
| 678 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex( | 691 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex( |
| 679 int32 idb_object_store_id, | 692 int32 idb_object_store_id, |
| 680 const string16& name, | 693 const string16& name, |
| 681 int32* idb_index_id, | 694 int32* idb_index_id, |
| 682 WebKit::WebExceptionCode* ec) { | 695 WebKit::WebExceptionCode* ec) { |
| 683 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 696 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 684 &map_, idb_object_store_id, IndexedDBHostMsg_ObjectStoreIndex::ID); | 697 &map_, idb_object_store_id, IndexedDBHostMsg_ObjectStoreIndex::ID); |
| 685 if (!idb_object_store) | 698 if (!idb_object_store) |
| 686 return; | 699 return; |
| 687 | 700 |
| 701 *ec = 0; |
| 688 WebIDBIndex* index = idb_object_store->index(name, *ec); | 702 WebIDBIndex* index = idb_object_store->index(name, *ec); |
| 689 *idb_index_id = parent_->Add(index); | 703 *idb_index_id = parent_->Add(index); |
| 690 } | 704 } |
| 691 | 705 |
| 692 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDeleteIndex( | 706 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDeleteIndex( |
| 693 int32 idb_object_store_id, | 707 int32 idb_object_store_id, |
| 694 const string16& name, | 708 const string16& name, |
| 695 int32 transaction_id, | 709 int32 transaction_id, |
| 696 WebKit::WebExceptionCode* ec) { | 710 WebKit::WebExceptionCode* ec) { |
| 697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 711 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 698 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 712 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 699 &map_, idb_object_store_id, IndexedDBHostMsg_ObjectStoreDeleteIndex::ID); | 713 &map_, idb_object_store_id, IndexedDBHostMsg_ObjectStoreDeleteIndex::ID); |
| 700 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 714 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 701 &parent_->transaction_dispatcher_host_->map_, transaction_id, | 715 &parent_->transaction_dispatcher_host_->map_, transaction_id, |
| 702 IndexedDBHostMsg_ObjectStoreDeleteIndex::ID); | 716 IndexedDBHostMsg_ObjectStoreDeleteIndex::ID); |
| 703 if (!idb_object_store || !idb_transaction) | 717 if (!idb_object_store || !idb_transaction) |
| 704 return; | 718 return; |
| 705 | 719 |
| 720 *ec = 0; |
| 706 idb_object_store->deleteIndex(name, *idb_transaction, *ec); | 721 idb_object_store->deleteIndex(name, *idb_transaction, *ec); |
| 707 } | 722 } |
| 708 | 723 |
| 709 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnOpenCursor( | 724 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnOpenCursor( |
| 710 const IndexedDBHostMsg_ObjectStoreOpenCursor_Params& params, | 725 const IndexedDBHostMsg_ObjectStoreOpenCursor_Params& params, |
| 711 WebKit::WebExceptionCode* ec) { | 726 WebKit::WebExceptionCode* ec) { |
| 712 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 727 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 713 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 728 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 714 &parent_->object_store_dispatcher_host_->map_, | 729 &parent_->object_store_dispatcher_host_->map_, |
| 715 params.idb_object_store_id, IndexedDBHostMsg_ObjectStoreOpenCursor::ID); | 730 params.idb_object_store_id, IndexedDBHostMsg_ObjectStoreOpenCursor::ID); |
| 716 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 731 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 717 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, | 732 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 718 IndexedDBHostMsg_ObjectStoreOpenCursor::ID); | 733 IndexedDBHostMsg_ObjectStoreOpenCursor::ID); |
| 719 if (!idb_transaction || !idb_object_store) | 734 if (!idb_transaction || !idb_object_store) |
| 720 return; | 735 return; |
| 721 | 736 |
| 737 *ec = 0; |
| 722 scoped_ptr<WebIDBCallbacks> callbacks( | 738 scoped_ptr<WebIDBCallbacks> callbacks( |
| 723 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); | 739 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); |
| 724 idb_object_store->openCursor( | 740 idb_object_store->openCursor( |
| 725 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 741 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 726 params.upper_open), | 742 params.upper_open), |
| 727 params.direction, callbacks.release(), *idb_transaction, *ec); | 743 params.direction, callbacks.release(), *idb_transaction, *ec); |
| 728 } | 744 } |
| 729 | 745 |
| 730 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( | 746 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( |
| 731 int32 object_id) { | 747 int32 object_id) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 int32 cursor_id, | 826 int32 cursor_id, |
| 811 int32 response_id, | 827 int32 response_id, |
| 812 const SerializedScriptValue& value, | 828 const SerializedScriptValue& value, |
| 813 WebKit::WebExceptionCode* ec) { | 829 WebKit::WebExceptionCode* ec) { |
| 814 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 830 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 815 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 831 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( |
| 816 &map_, cursor_id, IndexedDBHostMsg_CursorUpdate::ID); | 832 &map_, cursor_id, IndexedDBHostMsg_CursorUpdate::ID); |
| 817 if (!idb_cursor) | 833 if (!idb_cursor) |
| 818 return; | 834 return; |
| 819 | 835 |
| 836 *ec = 0; |
| 820 idb_cursor->update( | 837 idb_cursor->update( |
| 821 value, new IndexedDBCallbacks<void>(parent_, response_id), *ec); | 838 value, new IndexedDBCallbacks<void>(parent_, response_id), *ec); |
| 822 } | 839 } |
| 823 | 840 |
| 824 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( | 841 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( |
| 825 int32 cursor_id, | 842 int32 cursor_id, |
| 826 int32 response_id, | 843 int32 response_id, |
| 827 const IndexedDBKey& key, | 844 const IndexedDBKey& key, |
| 828 WebKit::WebExceptionCode* ec) { | 845 WebKit::WebExceptionCode* ec) { |
| 829 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 846 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 830 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 847 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( |
| 831 &map_, cursor_id, IndexedDBHostMsg_CursorContinue::ID); | 848 &map_, cursor_id, IndexedDBHostMsg_CursorContinue::ID); |
| 832 if (!idb_cursor) | 849 if (!idb_cursor) |
| 833 return; | 850 return; |
| 834 | 851 |
| 852 *ec = 0; |
| 835 idb_cursor->continueFunction( | 853 idb_cursor->continueFunction( |
| 836 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id), *ec); | 854 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id), *ec); |
| 837 } | 855 } |
| 838 | 856 |
| 839 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( | 857 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( |
| 840 int32 cursor_id, | 858 int32 cursor_id, |
| 841 int32 response_id, | 859 int32 response_id, |
| 842 WebKit::WebExceptionCode* ec) { | 860 WebKit::WebExceptionCode* ec) { |
| 843 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 861 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 844 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 862 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( |
| 845 &map_, cursor_id, IndexedDBHostMsg_CursorUpdate::ID); | 863 &map_, cursor_id, IndexedDBHostMsg_CursorUpdate::ID); |
| 846 if (!idb_cursor) | 864 if (!idb_cursor) |
| 847 return; | 865 return; |
| 848 | 866 |
| 867 *ec = 0; |
| 849 // TODO(jorlow): This should be delete. | 868 // TODO(jorlow): This should be delete. |
| 850 idb_cursor->remove(new IndexedDBCallbacks<void>(parent_, response_id), *ec); | 869 idb_cursor->remove(new IndexedDBCallbacks<void>(parent_, response_id), *ec); |
| 851 } | 870 } |
| 852 | 871 |
| 853 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 872 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 854 int32 object_id) { | 873 int32 object_id) { |
| 855 parent_->DestroyObject( | 874 parent_->DestroyObject( |
| 856 &map_, object_id, IndexedDBHostMsg_CursorDestroyed::ID); | 875 &map_, object_id, IndexedDBHostMsg_CursorDestroyed::ID); |
| 857 } | 876 } |
| 858 | 877 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 } | 937 } |
| 919 | 938 |
| 920 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnObjectStore( | 939 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnObjectStore( |
| 921 int32 transaction_id, const string16& name, int32* object_store_id, | 940 int32 transaction_id, const string16& name, int32* object_store_id, |
| 922 WebKit::WebExceptionCode* ec) { | 941 WebKit::WebExceptionCode* ec) { |
| 923 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 942 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 924 &map_, transaction_id, IndexedDBHostMsg_TransactionObjectStore::ID); | 943 &map_, transaction_id, IndexedDBHostMsg_TransactionObjectStore::ID); |
| 925 if (!idb_transaction) | 944 if (!idb_transaction) |
| 926 return; | 945 return; |
| 927 | 946 |
| 947 *ec = 0; |
| 928 WebIDBObjectStore* object_store = idb_transaction->objectStore(name, *ec); | 948 WebIDBObjectStore* object_store = idb_transaction->objectStore(name, *ec); |
| 929 *object_store_id = object_store ? parent_->Add(object_store) : 0; | 949 *object_store_id = object_store ? parent_->Add(object_store) : 0; |
| 930 } | 950 } |
| 931 | 951 |
| 932 void IndexedDBDispatcherHost:: | 952 void IndexedDBDispatcherHost:: |
| 933 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) { | 953 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) { |
| 934 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 954 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 935 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 955 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 936 &map_, transaction_id, | 956 &map_, transaction_id, |
| 937 IndexedDBHostMsg_TransactionDidCompleteTaskEvents::ID); | 957 IndexedDBHostMsg_TransactionDidCompleteTaskEvents::ID); |
| 938 if (!idb_transaction) | 958 if (!idb_transaction) |
| 939 return; | 959 return; |
| 940 | 960 |
| 941 idb_transaction->didCompleteTaskEvents(); | 961 idb_transaction->didCompleteTaskEvents(); |
| 942 } | 962 } |
| 943 | 963 |
| 944 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 964 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 945 int32 object_id) { | 965 int32 object_id) { |
| 946 parent_->DestroyObject( | 966 parent_->DestroyObject( |
| 947 &map_, object_id, IndexedDBHostMsg_TransactionDestroyed::ID); | 967 &map_, object_id, IndexedDBHostMsg_TransactionDestroyed::ID); |
| 948 } | 968 } |
| OLD | NEW |