| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/indexed_db/indexed_db_database.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 return false; | 260 return false; |
| 261 } | 261 } |
| 262 return true; | 262 return true; |
| 263 } | 263 } |
| 264 | 264 |
| 265 void IndexedDBDatabase::CreateObjectStore(int64 transaction_id, | 265 void IndexedDBDatabase::CreateObjectStore(int64 transaction_id, |
| 266 int64 object_store_id, | 266 int64 object_store_id, |
| 267 const base::string16& name, | 267 const base::string16& name, |
| 268 const IndexedDBKeyPath& key_path, | 268 const IndexedDBKeyPath& key_path, |
| 269 bool auto_increment) { | 269 bool auto_increment) { |
| 270 IDB_TRACE("IndexedDBDatabase::CreateObjectStore"); | 270 IDB_TRACE1("IndexedDBDatabase::CreateObjectStore", "txn.id", transaction_id); |
| 271 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 271 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 272 if (!transaction) | 272 if (!transaction) |
| 273 return; | 273 return; |
| 274 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 274 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
| 275 | 275 |
| 276 if (ContainsKey(metadata_.object_stores, object_store_id)) { | 276 if (ContainsKey(metadata_.object_stores, object_store_id)) { |
| 277 DLOG(ERROR) << "Invalid object_store_id"; | 277 DLOG(ERROR) << "Invalid object_store_id"; |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 | 280 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 309 | 309 |
| 310 AddObjectStore(object_store_metadata, object_store_id); | 310 AddObjectStore(object_store_metadata, object_store_id); |
| 311 transaction->ScheduleAbortTask( | 311 transaction->ScheduleAbortTask( |
| 312 base::Bind(&IndexedDBDatabase::CreateObjectStoreAbortOperation, | 312 base::Bind(&IndexedDBDatabase::CreateObjectStoreAbortOperation, |
| 313 this, | 313 this, |
| 314 object_store_id)); | 314 object_store_id)); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void IndexedDBDatabase::DeleteObjectStore(int64 transaction_id, | 317 void IndexedDBDatabase::DeleteObjectStore(int64 transaction_id, |
| 318 int64 object_store_id) { | 318 int64 object_store_id) { |
| 319 IDB_TRACE("IndexedDBDatabase::DeleteObjectStore"); | 319 IDB_TRACE1("IndexedDBDatabase::DeleteObjectStore", "txn.id", transaction_id); |
| 320 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 320 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 321 if (!transaction) | 321 if (!transaction) |
| 322 return; | 322 return; |
| 323 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 323 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
| 324 | 324 |
| 325 if (!ValidateObjectStoreId(object_store_id)) | 325 if (!ValidateObjectStoreId(object_store_id)) |
| 326 return; | 326 return; |
| 327 | 327 |
| 328 transaction->ScheduleTask( | 328 transaction->ScheduleTask( |
| 329 base::Bind(&IndexedDBDatabase::DeleteObjectStoreOperation, | 329 base::Bind(&IndexedDBDatabase::DeleteObjectStoreOperation, |
| 330 this, | 330 this, |
| 331 object_store_id)); | 331 object_store_id)); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void IndexedDBDatabase::CreateIndex(int64 transaction_id, | 334 void IndexedDBDatabase::CreateIndex(int64 transaction_id, |
| 335 int64 object_store_id, | 335 int64 object_store_id, |
| 336 int64 index_id, | 336 int64 index_id, |
| 337 const base::string16& name, | 337 const base::string16& name, |
| 338 const IndexedDBKeyPath& key_path, | 338 const IndexedDBKeyPath& key_path, |
| 339 bool unique, | 339 bool unique, |
| 340 bool multi_entry) { | 340 bool multi_entry) { |
| 341 IDB_TRACE("IndexedDBDatabase::CreateIndex"); | 341 IDB_TRACE1("IndexedDBDatabase::CreateIndex", "txn.id", transaction_id); |
| 342 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 342 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 343 if (!transaction) | 343 if (!transaction) |
| 344 return; | 344 return; |
| 345 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 345 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
| 346 | 346 |
| 347 if (!ValidateObjectStoreIdAndNewIndexId(object_store_id, index_id)) | 347 if (!ValidateObjectStoreIdAndNewIndexId(object_store_id, index_id)) |
| 348 return; | 348 return; |
| 349 | 349 |
| 350 // Index creation is done synchronously since preemptive | 350 // Index creation is done synchronously since preemptive |
| 351 // OpenCursor/SetIndexKeys may follow. | 351 // OpenCursor/SetIndexKeys may follow. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 373 base::Bind(&IndexedDBDatabase::CreateIndexAbortOperation, | 373 base::Bind(&IndexedDBDatabase::CreateIndexAbortOperation, |
| 374 this, | 374 this, |
| 375 object_store_id, | 375 object_store_id, |
| 376 index_id)); | 376 index_id)); |
| 377 } | 377 } |
| 378 | 378 |
| 379 void IndexedDBDatabase::CreateIndexAbortOperation( | 379 void IndexedDBDatabase::CreateIndexAbortOperation( |
| 380 int64 object_store_id, | 380 int64 object_store_id, |
| 381 int64 index_id, | 381 int64 index_id, |
| 382 IndexedDBTransaction* transaction) { | 382 IndexedDBTransaction* transaction) { |
| 383 IDB_TRACE("IndexedDBDatabase::CreateIndexAbortOperation"); | 383 IDB_TRACE1("IndexedDBDatabase::CreateIndexAbortOperation", |
| 384 "txn.id", |
| 385 transaction->id()); |
| 384 DCHECK(!transaction); | 386 DCHECK(!transaction); |
| 385 RemoveIndex(object_store_id, index_id); | 387 RemoveIndex(object_store_id, index_id); |
| 386 } | 388 } |
| 387 | 389 |
| 388 void IndexedDBDatabase::DeleteIndex(int64 transaction_id, | 390 void IndexedDBDatabase::DeleteIndex(int64 transaction_id, |
| 389 int64 object_store_id, | 391 int64 object_store_id, |
| 390 int64 index_id) { | 392 int64 index_id) { |
| 391 IDB_TRACE("IndexedDBDatabase::DeleteIndex"); | 393 IDB_TRACE1("IndexedDBDatabase::DeleteIndex", "txn.id", transaction_id); |
| 392 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 394 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 393 if (!transaction) | 395 if (!transaction) |
| 394 return; | 396 return; |
| 395 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 397 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
| 396 | 398 |
| 397 if (!ValidateObjectStoreIdAndIndexId(object_store_id, index_id)) | 399 if (!ValidateObjectStoreIdAndIndexId(object_store_id, index_id)) |
| 398 return; | 400 return; |
| 399 | 401 |
| 400 transaction->ScheduleTask( | 402 transaction->ScheduleTask( |
| 401 base::Bind(&IndexedDBDatabase::DeleteIndexOperation, | 403 base::Bind(&IndexedDBDatabase::DeleteIndexOperation, |
| 402 this, | 404 this, |
| 403 object_store_id, | 405 object_store_id, |
| 404 index_id)); | 406 index_id)); |
| 405 } | 407 } |
| 406 | 408 |
| 407 void IndexedDBDatabase::DeleteIndexOperation( | 409 void IndexedDBDatabase::DeleteIndexOperation( |
| 408 int64 object_store_id, | 410 int64 object_store_id, |
| 409 int64 index_id, | 411 int64 index_id, |
| 410 IndexedDBTransaction* transaction) { | 412 IndexedDBTransaction* transaction) { |
| 411 IDB_TRACE("IndexedDBDatabase::DeleteIndexOperation"); | 413 IDB_TRACE1( |
| 414 "IndexedDBDatabase::DeleteIndexOperation", "txn.id", transaction->id()); |
| 412 | 415 |
| 413 const IndexedDBIndexMetadata index_metadata = | 416 const IndexedDBIndexMetadata index_metadata = |
| 414 metadata_.object_stores[object_store_id].indexes[index_id]; | 417 metadata_.object_stores[object_store_id].indexes[index_id]; |
| 415 | 418 |
| 416 leveldb::Status s = | 419 leveldb::Status s = |
| 417 backing_store_->DeleteIndex(transaction->BackingStoreTransaction(), | 420 backing_store_->DeleteIndex(transaction->BackingStoreTransaction(), |
| 418 transaction->database()->id(), | 421 transaction->database()->id(), |
| 419 object_store_id, | 422 object_store_id, |
| 420 index_id); | 423 index_id); |
| 421 if (!s.ok()) { | 424 if (!s.ok()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 436 base::Bind(&IndexedDBDatabase::DeleteIndexAbortOperation, | 439 base::Bind(&IndexedDBDatabase::DeleteIndexAbortOperation, |
| 437 this, | 440 this, |
| 438 object_store_id, | 441 object_store_id, |
| 439 index_metadata)); | 442 index_metadata)); |
| 440 } | 443 } |
| 441 | 444 |
| 442 void IndexedDBDatabase::DeleteIndexAbortOperation( | 445 void IndexedDBDatabase::DeleteIndexAbortOperation( |
| 443 int64 object_store_id, | 446 int64 object_store_id, |
| 444 const IndexedDBIndexMetadata& index_metadata, | 447 const IndexedDBIndexMetadata& index_metadata, |
| 445 IndexedDBTransaction* transaction) { | 448 IndexedDBTransaction* transaction) { |
| 446 IDB_TRACE("IndexedDBDatabase::DeleteIndexAbortOperation"); | |
| 447 DCHECK(!transaction); | 449 DCHECK(!transaction); |
| 450 IDB_TRACE1("IndexedDBDatabase::DeleteIndexAbortOperation", |
| 451 "txn.id", |
| 452 transaction->id()); |
| 448 AddIndex(object_store_id, index_metadata, IndexedDBIndexMetadata::kInvalidId); | 453 AddIndex(object_store_id, index_metadata, IndexedDBIndexMetadata::kInvalidId); |
| 449 } | 454 } |
| 450 | 455 |
| 451 void IndexedDBDatabase::Commit(int64 transaction_id) { | 456 void IndexedDBDatabase::Commit(int64 transaction_id) { |
| 452 // The frontend suggests that we commit, but we may have previously initiated | 457 // The frontend suggests that we commit, but we may have previously initiated |
| 453 // an abort, and so have disposed of the transaction. on_abort has already | 458 // an abort, and so have disposed of the transaction. on_abort has already |
| 454 // been dispatched to the frontend, so it will find out about that | 459 // been dispatched to the frontend, so it will find out about that |
| 455 // asynchronously. | 460 // asynchronously. |
| 456 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 461 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 457 if (transaction) | 462 if (transaction) |
| 458 transaction->Commit(); | 463 transaction->Commit(); |
| 459 } | 464 } |
| 460 | 465 |
| 461 void IndexedDBDatabase::Abort(int64 transaction_id) { | 466 void IndexedDBDatabase::Abort(int64 transaction_id) { |
| 462 // If the transaction is unknown, then it has already been aborted by the | 467 // If the transaction is unknown, then it has already been aborted by the |
| 463 // backend before this call so it is safe to ignore it. | 468 // backend before this call so it is safe to ignore it. |
| 464 IDB_TRACE("IndexedDBDatabase::Abort"); | 469 IDB_TRACE1("IndexedDBDatabase::Abort", "txn.id", transaction_id); |
| 465 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 470 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 466 if (transaction) | 471 if (transaction) |
| 467 transaction->Abort(); | 472 transaction->Abort(); |
| 468 } | 473 } |
| 469 | 474 |
| 470 void IndexedDBDatabase::Abort(int64 transaction_id, | 475 void IndexedDBDatabase::Abort(int64 transaction_id, |
| 471 const IndexedDBDatabaseError& error) { | 476 const IndexedDBDatabaseError& error) { |
| 472 IDB_TRACE("IndexedDBDatabase::Abort"); | 477 IDB_TRACE1("IndexedDBDatabase::Abort(error)", "txn.id", transaction_id); |
| 473 // If the transaction is unknown, then it has already been aborted by the | 478 // If the transaction is unknown, then it has already been aborted by the |
| 474 // backend before this call so it is safe to ignore it. | 479 // backend before this call so it is safe to ignore it. |
| 475 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 480 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 476 if (transaction) | 481 if (transaction) |
| 477 transaction->Abort(error); | 482 transaction->Abort(error); |
| 478 } | 483 } |
| 479 | 484 |
| 480 void IndexedDBDatabase::Get(int64 transaction_id, | 485 void IndexedDBDatabase::Get(int64 transaction_id, |
| 481 int64 object_store_id, | 486 int64 object_store_id, |
| 482 int64 index_id, | 487 int64 index_id, |
| 483 scoped_ptr<IndexedDBKeyRange> key_range, | 488 scoped_ptr<IndexedDBKeyRange> key_range, |
| 484 bool key_only, | 489 bool key_only, |
| 485 scoped_refptr<IndexedDBCallbacks> callbacks) { | 490 scoped_refptr<IndexedDBCallbacks> callbacks) { |
| 486 IDB_TRACE("IndexedDBDatabase::Get"); | 491 IDB_TRACE1("IndexedDBDatabase::Get", "txn.id", transaction_id); |
| 487 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 492 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 488 if (!transaction) | 493 if (!transaction) |
| 489 return; | 494 return; |
| 490 | 495 |
| 491 if (!ValidateObjectStoreIdAndOptionalIndexId(object_store_id, index_id)) | 496 if (!ValidateObjectStoreIdAndOptionalIndexId(object_store_id, index_id)) |
| 492 return; | 497 return; |
| 493 | 498 |
| 494 transaction->ScheduleTask(base::Bind( | 499 transaction->ScheduleTask(base::Bind( |
| 495 &IndexedDBDatabase::GetOperation, | 500 &IndexedDBDatabase::GetOperation, |
| 496 this, | 501 this, |
| 497 object_store_id, | 502 object_store_id, |
| 498 index_id, | 503 index_id, |
| 499 Passed(&key_range), | 504 Passed(&key_range), |
| 500 key_only ? indexed_db::CURSOR_KEY_ONLY : indexed_db::CURSOR_KEY_AND_VALUE, | 505 key_only ? indexed_db::CURSOR_KEY_ONLY : indexed_db::CURSOR_KEY_AND_VALUE, |
| 501 callbacks)); | 506 callbacks)); |
| 502 } | 507 } |
| 503 | 508 |
| 504 void IndexedDBDatabase::GetOperation( | 509 void IndexedDBDatabase::GetOperation( |
| 505 int64 object_store_id, | 510 int64 object_store_id, |
| 506 int64 index_id, | 511 int64 index_id, |
| 507 scoped_ptr<IndexedDBKeyRange> key_range, | 512 scoped_ptr<IndexedDBKeyRange> key_range, |
| 508 indexed_db::CursorType cursor_type, | 513 indexed_db::CursorType cursor_type, |
| 509 scoped_refptr<IndexedDBCallbacks> callbacks, | 514 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 510 IndexedDBTransaction* transaction) { | 515 IndexedDBTransaction* transaction) { |
| 511 IDB_TRACE("IndexedDBDatabase::GetOperation"); | 516 IDB_TRACE1("IndexedDBDatabase::GetOperation", "txn.id", transaction->id()); |
| 512 | 517 |
| 513 DCHECK(metadata_.object_stores.find(object_store_id) != | 518 DCHECK(metadata_.object_stores.find(object_store_id) != |
| 514 metadata_.object_stores.end()); | 519 metadata_.object_stores.end()); |
| 515 const IndexedDBObjectStoreMetadata& object_store_metadata = | 520 const IndexedDBObjectStoreMetadata& object_store_metadata = |
| 516 metadata_.object_stores[object_store_id]; | 521 metadata_.object_stores[object_store_id]; |
| 517 | 522 |
| 518 const IndexedDBKey* key; | 523 const IndexedDBKey* key; |
| 519 | 524 |
| 520 leveldb::Status s; | 525 leveldb::Status s; |
| 521 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; | 526 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 }; | 721 }; |
| 717 | 722 |
| 718 void IndexedDBDatabase::Put(int64 transaction_id, | 723 void IndexedDBDatabase::Put(int64 transaction_id, |
| 719 int64 object_store_id, | 724 int64 object_store_id, |
| 720 IndexedDBValue* value, | 725 IndexedDBValue* value, |
| 721 ScopedVector<webkit_blob::BlobDataHandle>* handles, | 726 ScopedVector<webkit_blob::BlobDataHandle>* handles, |
| 722 scoped_ptr<IndexedDBKey> key, | 727 scoped_ptr<IndexedDBKey> key, |
| 723 PutMode put_mode, | 728 PutMode put_mode, |
| 724 scoped_refptr<IndexedDBCallbacks> callbacks, | 729 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 725 const std::vector<IndexKeys>& index_keys) { | 730 const std::vector<IndexKeys>& index_keys) { |
| 726 IDB_TRACE("IndexedDBDatabase::Put"); | 731 IDB_TRACE1("IndexedDBDatabase::Put", "txn.id", transaction_id); |
| 727 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 732 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 728 if (!transaction) | 733 if (!transaction) |
| 729 return; | 734 return; |
| 730 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); | 735 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); |
| 731 | 736 |
| 732 if (!ValidateObjectStoreId(object_store_id)) | 737 if (!ValidateObjectStoreId(object_store_id)) |
| 733 return; | 738 return; |
| 734 | 739 |
| 735 DCHECK(key); | 740 DCHECK(key); |
| 736 DCHECK(value); | 741 DCHECK(value); |
| 737 scoped_ptr<PutOperationParams> params(new PutOperationParams()); | 742 scoped_ptr<PutOperationParams> params(new PutOperationParams()); |
| 738 params->object_store_id = object_store_id; | 743 params->object_store_id = object_store_id; |
| 739 params->value.swap(*value); | 744 params->value.swap(*value); |
| 740 params->handles.swap(*handles); | 745 params->handles.swap(*handles); |
| 741 params->key = key.Pass(); | 746 params->key = key.Pass(); |
| 742 params->put_mode = put_mode; | 747 params->put_mode = put_mode; |
| 743 params->callbacks = callbacks; | 748 params->callbacks = callbacks; |
| 744 params->index_keys = index_keys; | 749 params->index_keys = index_keys; |
| 745 transaction->ScheduleTask(base::Bind( | 750 transaction->ScheduleTask(base::Bind( |
| 746 &IndexedDBDatabase::PutOperation, this, base::Passed(¶ms))); | 751 &IndexedDBDatabase::PutOperation, this, base::Passed(¶ms))); |
| 747 } | 752 } |
| 748 | 753 |
| 749 void IndexedDBDatabase::PutOperation(scoped_ptr<PutOperationParams> params, | 754 void IndexedDBDatabase::PutOperation(scoped_ptr<PutOperationParams> params, |
| 750 IndexedDBTransaction* transaction) { | 755 IndexedDBTransaction* transaction) { |
| 751 IDB_TRACE("IndexedDBDatabase::PutOperation"); | 756 IDB_TRACE1("IndexedDBDatabase::PutOperation", "txn.id", transaction->id()); |
| 752 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); | 757 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); |
| 753 bool key_was_generated = false; | 758 bool key_was_generated = false; |
| 754 | 759 |
| 755 DCHECK(metadata_.object_stores.find(params->object_store_id) != | 760 DCHECK(metadata_.object_stores.find(params->object_store_id) != |
| 756 metadata_.object_stores.end()); | 761 metadata_.object_stores.end()); |
| 757 const IndexedDBObjectStoreMetadata& object_store = | 762 const IndexedDBObjectStoreMetadata& object_store = |
| 758 metadata_.object_stores[params->object_store_id]; | 763 metadata_.object_stores[params->object_store_id]; |
| 759 DCHECK(object_store.auto_increment || params->key->IsValid()); | 764 DCHECK(object_store.auto_increment || params->key->IsValid()); |
| 760 | 765 |
| 761 scoped_ptr<IndexedDBKey> key; | 766 scoped_ptr<IndexedDBKey> key; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 } | 884 } |
| 880 } | 885 } |
| 881 | 886 |
| 882 params->callbacks->OnSuccess(*key); | 887 params->callbacks->OnSuccess(*key); |
| 883 } | 888 } |
| 884 | 889 |
| 885 void IndexedDBDatabase::SetIndexKeys(int64 transaction_id, | 890 void IndexedDBDatabase::SetIndexKeys(int64 transaction_id, |
| 886 int64 object_store_id, | 891 int64 object_store_id, |
| 887 scoped_ptr<IndexedDBKey> primary_key, | 892 scoped_ptr<IndexedDBKey> primary_key, |
| 888 const std::vector<IndexKeys>& index_keys) { | 893 const std::vector<IndexKeys>& index_keys) { |
| 889 IDB_TRACE("IndexedDBDatabase::SetIndexKeys"); | 894 IDB_TRACE1("IndexedDBDatabase::SetIndexKeys", "txn.id", transaction_id); |
| 890 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 895 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 891 if (!transaction) | 896 if (!transaction) |
| 892 return; | 897 return; |
| 893 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 898 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
| 894 | 899 |
| 895 // TODO(alecflett): This method could be asynchronous, but we need to | 900 // TODO(alecflett): This method could be asynchronous, but we need to |
| 896 // evaluate if it's worth the extra complexity. | 901 // evaluate if it's worth the extra complexity. |
| 897 IndexedDBBackingStore::RecordIdentifier record_identifier; | 902 IndexedDBBackingStore::RecordIdentifier record_identifier; |
| 898 bool found = false; | 903 bool found = false; |
| 899 leveldb::Status s = backing_store_->KeyExistsInObjectStore( | 904 leveldb::Status s = backing_store_->KeyExistsInObjectStore( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 backing_store_, | 959 backing_store_, |
| 955 transaction->BackingStoreTransaction(), | 960 transaction->BackingStoreTransaction(), |
| 956 id(), | 961 id(), |
| 957 object_store_id); | 962 object_store_id); |
| 958 } | 963 } |
| 959 } | 964 } |
| 960 | 965 |
| 961 void IndexedDBDatabase::SetIndexesReady(int64 transaction_id, | 966 void IndexedDBDatabase::SetIndexesReady(int64 transaction_id, |
| 962 int64, | 967 int64, |
| 963 const std::vector<int64>& index_ids) { | 968 const std::vector<int64>& index_ids) { |
| 964 IDB_TRACE("IndexedDBDatabase::SetIndexesReady"); | 969 IDB_TRACE1("IndexedDBDatabase::SetIndexesReady", "txn.id", transaction_id); |
| 965 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 970 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 966 if (!transaction) | 971 if (!transaction) |
| 967 return; | 972 return; |
| 968 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 973 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
| 969 | 974 |
| 970 transaction->ScheduleTask( | 975 transaction->ScheduleTask( |
| 971 IndexedDBDatabase::PREEMPTIVE_TASK, | 976 IndexedDBDatabase::PREEMPTIVE_TASK, |
| 972 base::Bind(&IndexedDBDatabase::SetIndexesReadyOperation, | 977 base::Bind(&IndexedDBDatabase::SetIndexesReadyOperation, |
| 973 this, | 978 this, |
| 974 index_ids.size())); | 979 index_ids.size())); |
| 975 } | 980 } |
| 976 | 981 |
| 977 void IndexedDBDatabase::SetIndexesReadyOperation( | 982 void IndexedDBDatabase::SetIndexesReadyOperation( |
| 978 size_t index_count, | 983 size_t index_count, |
| 979 IndexedDBTransaction* transaction) { | 984 IndexedDBTransaction* transaction) { |
| 980 IDB_TRACE("IndexedDBDatabase::SetIndexesReadyOperation"); | 985 IDB_TRACE1("IndexedDBDatabase::SetIndexesReadyOperation", |
| 986 "txn.id", |
| 987 transaction->id()); |
| 981 for (size_t i = 0; i < index_count; ++i) | 988 for (size_t i = 0; i < index_count; ++i) |
| 982 transaction->DidCompletePreemptiveEvent(); | 989 transaction->DidCompletePreemptiveEvent(); |
| 983 } | 990 } |
| 984 | 991 |
| 985 struct IndexedDBDatabase::OpenCursorOperationParams { | 992 struct IndexedDBDatabase::OpenCursorOperationParams { |
| 986 OpenCursorOperationParams() {} | 993 OpenCursorOperationParams() {} |
| 987 int64 object_store_id; | 994 int64 object_store_id; |
| 988 int64 index_id; | 995 int64 index_id; |
| 989 scoped_ptr<IndexedDBKeyRange> key_range; | 996 scoped_ptr<IndexedDBKeyRange> key_range; |
| 990 indexed_db::CursorDirection direction; | 997 indexed_db::CursorDirection direction; |
| 991 indexed_db::CursorType cursor_type; | 998 indexed_db::CursorType cursor_type; |
| 992 IndexedDBDatabase::TaskType task_type; | 999 IndexedDBDatabase::TaskType task_type; |
| 993 scoped_refptr<IndexedDBCallbacks> callbacks; | 1000 scoped_refptr<IndexedDBCallbacks> callbacks; |
| 994 | 1001 |
| 995 private: | 1002 private: |
| 996 DISALLOW_COPY_AND_ASSIGN(OpenCursorOperationParams); | 1003 DISALLOW_COPY_AND_ASSIGN(OpenCursorOperationParams); |
| 997 }; | 1004 }; |
| 998 | 1005 |
| 999 void IndexedDBDatabase::OpenCursor( | 1006 void IndexedDBDatabase::OpenCursor( |
| 1000 int64 transaction_id, | 1007 int64 transaction_id, |
| 1001 int64 object_store_id, | 1008 int64 object_store_id, |
| 1002 int64 index_id, | 1009 int64 index_id, |
| 1003 scoped_ptr<IndexedDBKeyRange> key_range, | 1010 scoped_ptr<IndexedDBKeyRange> key_range, |
| 1004 indexed_db::CursorDirection direction, | 1011 indexed_db::CursorDirection direction, |
| 1005 bool key_only, | 1012 bool key_only, |
| 1006 TaskType task_type, | 1013 TaskType task_type, |
| 1007 scoped_refptr<IndexedDBCallbacks> callbacks) { | 1014 scoped_refptr<IndexedDBCallbacks> callbacks) { |
| 1008 IDB_TRACE("IndexedDBDatabase::OpenCursor"); | 1015 IDB_TRACE1("IndexedDBDatabase::OpenCursor", "txn.id", transaction_id); |
| 1009 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 1016 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 1010 if (!transaction) | 1017 if (!transaction) |
| 1011 return; | 1018 return; |
| 1012 | 1019 |
| 1013 if (!ValidateObjectStoreIdAndOptionalIndexId(object_store_id, index_id)) | 1020 if (!ValidateObjectStoreIdAndOptionalIndexId(object_store_id, index_id)) |
| 1014 return; | 1021 return; |
| 1015 | 1022 |
| 1016 scoped_ptr<OpenCursorOperationParams> params(new OpenCursorOperationParams()); | 1023 scoped_ptr<OpenCursorOperationParams> params(new OpenCursorOperationParams()); |
| 1017 params->object_store_id = object_store_id; | 1024 params->object_store_id = object_store_id; |
| 1018 params->index_id = index_id; | 1025 params->index_id = index_id; |
| 1019 params->key_range = key_range.Pass(); | 1026 params->key_range = key_range.Pass(); |
| 1020 params->direction = direction; | 1027 params->direction = direction; |
| 1021 params->cursor_type = | 1028 params->cursor_type = |
| 1022 key_only ? indexed_db::CURSOR_KEY_ONLY : indexed_db::CURSOR_KEY_AND_VALUE; | 1029 key_only ? indexed_db::CURSOR_KEY_ONLY : indexed_db::CURSOR_KEY_AND_VALUE; |
| 1023 params->task_type = task_type; | 1030 params->task_type = task_type; |
| 1024 params->callbacks = callbacks; | 1031 params->callbacks = callbacks; |
| 1025 transaction->ScheduleTask(base::Bind( | 1032 transaction->ScheduleTask(base::Bind( |
| 1026 &IndexedDBDatabase::OpenCursorOperation, this, base::Passed(¶ms))); | 1033 &IndexedDBDatabase::OpenCursorOperation, this, base::Passed(¶ms))); |
| 1027 } | 1034 } |
| 1028 | 1035 |
| 1029 void IndexedDBDatabase::OpenCursorOperation( | 1036 void IndexedDBDatabase::OpenCursorOperation( |
| 1030 scoped_ptr<OpenCursorOperationParams> params, | 1037 scoped_ptr<OpenCursorOperationParams> params, |
| 1031 IndexedDBTransaction* transaction) { | 1038 IndexedDBTransaction* transaction) { |
| 1032 IDB_TRACE("IndexedDBDatabase::OpenCursorOperation"); | 1039 IDB_TRACE1( |
| 1040 "IndexedDBDatabase::OpenCursorOperation", "txn.id", transaction->id()); |
| 1033 | 1041 |
| 1034 // The frontend has begun indexing, so this pauses the transaction | 1042 // The frontend has begun indexing, so this pauses the transaction |
| 1035 // until the indexing is complete. This can't happen any earlier | 1043 // until the indexing is complete. This can't happen any earlier |
| 1036 // because we don't want to switch to early mode in case multiple | 1044 // because we don't want to switch to early mode in case multiple |
| 1037 // indexes are being created in a row, with Put()'s in between. | 1045 // indexes are being created in a row, with Put()'s in between. |
| 1038 if (params->task_type == IndexedDBDatabase::PREEMPTIVE_TASK) | 1046 if (params->task_type == IndexedDBDatabase::PREEMPTIVE_TASK) |
| 1039 transaction->AddPreemptiveEvent(); | 1047 transaction->AddPreemptiveEvent(); |
| 1040 | 1048 |
| 1041 leveldb::Status s; | 1049 leveldb::Status s; |
| 1042 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; | 1050 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 transaction); | 1113 transaction); |
| 1106 params->callbacks->OnSuccess( | 1114 params->callbacks->OnSuccess( |
| 1107 cursor, cursor->key(), cursor->primary_key(), cursor->Value()); | 1115 cursor, cursor->key(), cursor->primary_key(), cursor->Value()); |
| 1108 } | 1116 } |
| 1109 | 1117 |
| 1110 void IndexedDBDatabase::Count(int64 transaction_id, | 1118 void IndexedDBDatabase::Count(int64 transaction_id, |
| 1111 int64 object_store_id, | 1119 int64 object_store_id, |
| 1112 int64 index_id, | 1120 int64 index_id, |
| 1113 scoped_ptr<IndexedDBKeyRange> key_range, | 1121 scoped_ptr<IndexedDBKeyRange> key_range, |
| 1114 scoped_refptr<IndexedDBCallbacks> callbacks) { | 1122 scoped_refptr<IndexedDBCallbacks> callbacks) { |
| 1115 IDB_TRACE("IndexedDBDatabase::Count"); | 1123 IDB_TRACE1("IndexedDBDatabase::Count", "txn.id", transaction_id); |
| 1116 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 1124 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 1117 if (!transaction) | 1125 if (!transaction) |
| 1118 return; | 1126 return; |
| 1119 | 1127 |
| 1120 if (!ValidateObjectStoreIdAndOptionalIndexId(object_store_id, index_id)) | 1128 if (!ValidateObjectStoreIdAndOptionalIndexId(object_store_id, index_id)) |
| 1121 return; | 1129 return; |
| 1122 | 1130 |
| 1123 transaction->ScheduleTask(base::Bind(&IndexedDBDatabase::CountOperation, | 1131 transaction->ScheduleTask(base::Bind(&IndexedDBDatabase::CountOperation, |
| 1124 this, | 1132 this, |
| 1125 object_store_id, | 1133 object_store_id, |
| 1126 index_id, | 1134 index_id, |
| 1127 base::Passed(&key_range), | 1135 base::Passed(&key_range), |
| 1128 callbacks)); | 1136 callbacks)); |
| 1129 } | 1137 } |
| 1130 | 1138 |
| 1131 void IndexedDBDatabase::CountOperation( | 1139 void IndexedDBDatabase::CountOperation( |
| 1132 int64 object_store_id, | 1140 int64 object_store_id, |
| 1133 int64 index_id, | 1141 int64 index_id, |
| 1134 scoped_ptr<IndexedDBKeyRange> key_range, | 1142 scoped_ptr<IndexedDBKeyRange> key_range, |
| 1135 scoped_refptr<IndexedDBCallbacks> callbacks, | 1143 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 1136 IndexedDBTransaction* transaction) { | 1144 IndexedDBTransaction* transaction) { |
| 1137 IDB_TRACE("IndexedDBDatabase::CountOperation"); | 1145 IDB_TRACE1("IndexedDBDatabase::CountOperation", "txn.id", transaction->id()); |
| 1138 uint32 count = 0; | 1146 uint32 count = 0; |
| 1139 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; | 1147 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; |
| 1140 | 1148 |
| 1141 leveldb::Status s; | 1149 leveldb::Status s; |
| 1142 if (index_id == IndexedDBIndexMetadata::kInvalidId) { | 1150 if (index_id == IndexedDBIndexMetadata::kInvalidId) { |
| 1143 backing_store_cursor = backing_store_->OpenObjectStoreKeyCursor( | 1151 backing_store_cursor = backing_store_->OpenObjectStoreKeyCursor( |
| 1144 transaction->BackingStoreTransaction(), | 1152 transaction->BackingStoreTransaction(), |
| 1145 id(), | 1153 id(), |
| 1146 object_store_id, | 1154 object_store_id, |
| 1147 *key_range, | 1155 *key_range, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1178 // TODO(cmumford): Check for database corruption. | 1186 // TODO(cmumford): Check for database corruption. |
| 1179 | 1187 |
| 1180 callbacks->OnSuccess(count); | 1188 callbacks->OnSuccess(count); |
| 1181 } | 1189 } |
| 1182 | 1190 |
| 1183 void IndexedDBDatabase::DeleteRange( | 1191 void IndexedDBDatabase::DeleteRange( |
| 1184 int64 transaction_id, | 1192 int64 transaction_id, |
| 1185 int64 object_store_id, | 1193 int64 object_store_id, |
| 1186 scoped_ptr<IndexedDBKeyRange> key_range, | 1194 scoped_ptr<IndexedDBKeyRange> key_range, |
| 1187 scoped_refptr<IndexedDBCallbacks> callbacks) { | 1195 scoped_refptr<IndexedDBCallbacks> callbacks) { |
| 1188 IDB_TRACE("IndexedDBDatabase::DeleteRange"); | 1196 IDB_TRACE1("IndexedDBDatabase::DeleteRange", "txn.id", transaction_id); |
| 1189 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 1197 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 1190 if (!transaction) | 1198 if (!transaction) |
| 1191 return; | 1199 return; |
| 1192 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); | 1200 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); |
| 1193 | 1201 |
| 1194 if (!ValidateObjectStoreId(object_store_id)) | 1202 if (!ValidateObjectStoreId(object_store_id)) |
| 1195 return; | 1203 return; |
| 1196 | 1204 |
| 1197 transaction->ScheduleTask(base::Bind(&IndexedDBDatabase::DeleteRangeOperation, | 1205 transaction->ScheduleTask(base::Bind(&IndexedDBDatabase::DeleteRangeOperation, |
| 1198 this, | 1206 this, |
| 1199 object_store_id, | 1207 object_store_id, |
| 1200 base::Passed(&key_range), | 1208 base::Passed(&key_range), |
| 1201 callbacks)); | 1209 callbacks)); |
| 1202 } | 1210 } |
| 1203 | 1211 |
| 1204 void IndexedDBDatabase::DeleteRangeOperation( | 1212 void IndexedDBDatabase::DeleteRangeOperation( |
| 1205 int64 object_store_id, | 1213 int64 object_store_id, |
| 1206 scoped_ptr<IndexedDBKeyRange> key_range, | 1214 scoped_ptr<IndexedDBKeyRange> key_range, |
| 1207 scoped_refptr<IndexedDBCallbacks> callbacks, | 1215 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 1208 IndexedDBTransaction* transaction) { | 1216 IndexedDBTransaction* transaction) { |
| 1209 IDB_TRACE("IndexedDBDatabase::DeleteRangeOperation"); | 1217 IDB_TRACE1( |
| 1218 "IndexedDBDatabase::DeleteRangeOperation", "txn.id", transaction->id()); |
| 1210 leveldb::Status s = | 1219 leveldb::Status s = |
| 1211 backing_store_->DeleteRange(transaction->BackingStoreTransaction(), | 1220 backing_store_->DeleteRange(transaction->BackingStoreTransaction(), |
| 1212 id(), | 1221 id(), |
| 1213 object_store_id, | 1222 object_store_id, |
| 1214 *key_range); | 1223 *key_range); |
| 1215 if (!s.ok()) { | 1224 if (!s.ok()) { |
| 1216 base::string16 error_string = | 1225 base::string16 error_string = |
| 1217 ASCIIToUTF16("Internal error deleting data in range"); | 1226 ASCIIToUTF16("Internal error deleting data in range"); |
| 1218 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1227 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| 1219 error_string); | 1228 error_string); |
| 1220 transaction->Abort(error); | 1229 transaction->Abort(error); |
| 1221 if (leveldb_env::IsCorruption(s)) { | 1230 if (leveldb_env::IsCorruption(s)) { |
| 1222 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 1231 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
| 1223 error); | 1232 error); |
| 1224 } | 1233 } |
| 1225 return; | 1234 return; |
| 1226 } | 1235 } |
| 1227 callbacks->OnSuccess(); | 1236 callbacks->OnSuccess(); |
| 1228 } | 1237 } |
| 1229 | 1238 |
| 1230 void IndexedDBDatabase::Clear(int64 transaction_id, | 1239 void IndexedDBDatabase::Clear(int64 transaction_id, |
| 1231 int64 object_store_id, | 1240 int64 object_store_id, |
| 1232 scoped_refptr<IndexedDBCallbacks> callbacks) { | 1241 scoped_refptr<IndexedDBCallbacks> callbacks) { |
| 1233 IDB_TRACE("IndexedDBDatabase::Clear"); | 1242 IDB_TRACE1("IndexedDBDatabase::Clear", "txn.id", transaction_id); |
| 1234 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 1243 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 1235 if (!transaction) | 1244 if (!transaction) |
| 1236 return; | 1245 return; |
| 1237 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); | 1246 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); |
| 1238 | 1247 |
| 1239 if (!ValidateObjectStoreId(object_store_id)) | 1248 if (!ValidateObjectStoreId(object_store_id)) |
| 1240 return; | 1249 return; |
| 1241 | 1250 |
| 1242 transaction->ScheduleTask(base::Bind( | 1251 transaction->ScheduleTask(base::Bind( |
| 1243 &IndexedDBDatabase::ClearOperation, this, object_store_id, callbacks)); | 1252 &IndexedDBDatabase::ClearOperation, this, object_store_id, callbacks)); |
| 1244 } | 1253 } |
| 1245 | 1254 |
| 1246 void IndexedDBDatabase::ClearOperation( | 1255 void IndexedDBDatabase::ClearOperation( |
| 1247 int64 object_store_id, | 1256 int64 object_store_id, |
| 1248 scoped_refptr<IndexedDBCallbacks> callbacks, | 1257 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 1249 IndexedDBTransaction* transaction) { | 1258 IndexedDBTransaction* transaction) { |
| 1250 IDB_TRACE("IndexedDBDatabase::ObjectStoreClearOperation"); | 1259 IDB_TRACE1("IndexedDBDatabase::ClearOperation", "txn.id", transaction->id()); |
| 1251 leveldb::Status s = backing_store_->ClearObjectStore( | 1260 leveldb::Status s = backing_store_->ClearObjectStore( |
| 1252 transaction->BackingStoreTransaction(), id(), object_store_id); | 1261 transaction->BackingStoreTransaction(), id(), object_store_id); |
| 1253 if (!s.ok()) { | 1262 if (!s.ok()) { |
| 1254 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1263 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| 1255 "Internal error clearing object store"); | 1264 "Internal error clearing object store"); |
| 1256 callbacks->OnError(error); | 1265 callbacks->OnError(error); |
| 1257 if (leveldb_env::IsCorruption(s)) { | 1266 if (leveldb_env::IsCorruption(s)) { |
| 1258 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 1267 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
| 1259 error); | 1268 error); |
| 1260 } | 1269 } |
| 1261 return; | 1270 return; |
| 1262 } | 1271 } |
| 1263 callbacks->OnSuccess(); | 1272 callbacks->OnSuccess(); |
| 1264 } | 1273 } |
| 1265 | 1274 |
| 1266 void IndexedDBDatabase::DeleteObjectStoreOperation( | 1275 void IndexedDBDatabase::DeleteObjectStoreOperation( |
| 1267 int64 object_store_id, | 1276 int64 object_store_id, |
| 1268 IndexedDBTransaction* transaction) { | 1277 IndexedDBTransaction* transaction) { |
| 1269 IDB_TRACE("IndexedDBDatabase::DeleteObjectStoreOperation"); | 1278 IDB_TRACE1("IndexedDBDatabase::DeleteObjectStoreOperation", |
| 1279 "txn.id", |
| 1280 transaction->id()); |
| 1270 | 1281 |
| 1271 const IndexedDBObjectStoreMetadata object_store_metadata = | 1282 const IndexedDBObjectStoreMetadata object_store_metadata = |
| 1272 metadata_.object_stores[object_store_id]; | 1283 metadata_.object_stores[object_store_id]; |
| 1273 leveldb::Status s = | 1284 leveldb::Status s = |
| 1274 backing_store_->DeleteObjectStore(transaction->BackingStoreTransaction(), | 1285 backing_store_->DeleteObjectStore(transaction->BackingStoreTransaction(), |
| 1275 transaction->database()->id(), | 1286 transaction->database()->id(), |
| 1276 object_store_id); | 1287 object_store_id); |
| 1277 if (!s.ok()) { | 1288 if (!s.ok()) { |
| 1278 base::string16 error_string = | 1289 base::string16 error_string = |
| 1279 ASCIIToUTF16("Internal error deleting object store '") + | 1290 ASCIIToUTF16("Internal error deleting object store '") + |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1292 base::Bind(&IndexedDBDatabase::DeleteObjectStoreAbortOperation, | 1303 base::Bind(&IndexedDBDatabase::DeleteObjectStoreAbortOperation, |
| 1293 this, | 1304 this, |
| 1294 object_store_metadata)); | 1305 object_store_metadata)); |
| 1295 } | 1306 } |
| 1296 | 1307 |
| 1297 void IndexedDBDatabase::VersionChangeOperation( | 1308 void IndexedDBDatabase::VersionChangeOperation( |
| 1298 int64 version, | 1309 int64 version, |
| 1299 scoped_refptr<IndexedDBCallbacks> callbacks, | 1310 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 1300 scoped_ptr<IndexedDBConnection> connection, | 1311 scoped_ptr<IndexedDBConnection> connection, |
| 1301 IndexedDBTransaction* transaction) { | 1312 IndexedDBTransaction* transaction) { |
| 1302 IDB_TRACE("IndexedDBDatabase::VersionChangeOperation"); | 1313 IDB_TRACE1( |
| 1314 "IndexedDBDatabase::VersionChangeOperation", "txn.id", transaction->id()); |
| 1303 int64 old_version = metadata_.int_version; | 1315 int64 old_version = metadata_.int_version; |
| 1304 DCHECK_GT(version, old_version); | 1316 DCHECK_GT(version, old_version); |
| 1305 | 1317 |
| 1306 if (!backing_store_->UpdateIDBDatabaseIntVersion( | 1318 if (!backing_store_->UpdateIDBDatabaseIntVersion( |
| 1307 transaction->BackingStoreTransaction(), id(), version)) { | 1319 transaction->BackingStoreTransaction(), id(), version)) { |
| 1308 IndexedDBDatabaseError error( | 1320 IndexedDBDatabaseError error( |
| 1309 blink::WebIDBDatabaseExceptionUnknownError, | 1321 blink::WebIDBDatabaseExceptionUnknownError, |
| 1310 ASCIIToUTF16( | 1322 ASCIIToUTF16( |
| 1311 "Internal error writing data to stable storage when " | 1323 "Internal error writing data to stable storage when " |
| 1312 "updating version.")); | 1324 "updating version.")); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 pending_open_calls.pop_front(); | 1442 pending_open_calls.pop_front(); |
| 1431 } | 1443 } |
| 1432 } | 1444 } |
| 1433 } | 1445 } |
| 1434 | 1446 |
| 1435 void IndexedDBDatabase::CreateTransaction( | 1447 void IndexedDBDatabase::CreateTransaction( |
| 1436 int64 transaction_id, | 1448 int64 transaction_id, |
| 1437 IndexedDBConnection* connection, | 1449 IndexedDBConnection* connection, |
| 1438 const std::vector<int64>& object_store_ids, | 1450 const std::vector<int64>& object_store_ids, |
| 1439 uint16 mode) { | 1451 uint16 mode) { |
| 1440 | 1452 IDB_TRACE1("IndexedDBDatabase::CreateTransaction", "txn.id", transaction_id); |
| 1441 IDB_TRACE("IndexedDBDatabase::CreateTransaction"); | |
| 1442 DCHECK(connections_.count(connection)); | 1453 DCHECK(connections_.count(connection)); |
| 1443 DCHECK(transactions_.find(transaction_id) == transactions_.end()); | 1454 DCHECK(transactions_.find(transaction_id) == transactions_.end()); |
| 1444 if (transactions_.find(transaction_id) != transactions_.end()) | 1455 if (transactions_.find(transaction_id) != transactions_.end()) |
| 1445 return; | 1456 return; |
| 1446 | 1457 |
| 1447 // The transaction will add itself to this database's coordinator, which | 1458 // The transaction will add itself to this database's coordinator, which |
| 1448 // manages the lifetime of the object. | 1459 // manages the lifetime of the object. |
| 1449 TransactionCreated(new IndexedDBTransaction( | 1460 TransactionCreated(new IndexedDBTransaction( |
| 1450 transaction_id, | 1461 transaction_id, |
| 1451 connection->callbacks(), | 1462 connection->callbacks(), |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1718 if (factory_) { | 1729 if (factory_) { |
| 1719 factory_->ReleaseDatabase(identifier_, forced); | 1730 factory_->ReleaseDatabase(identifier_, forced); |
| 1720 factory_ = NULL; | 1731 factory_ = NULL; |
| 1721 } | 1732 } |
| 1722 } | 1733 } |
| 1723 } | 1734 } |
| 1724 | 1735 |
| 1725 void IndexedDBDatabase::CreateObjectStoreAbortOperation( | 1736 void IndexedDBDatabase::CreateObjectStoreAbortOperation( |
| 1726 int64 object_store_id, | 1737 int64 object_store_id, |
| 1727 IndexedDBTransaction* transaction) { | 1738 IndexedDBTransaction* transaction) { |
| 1728 IDB_TRACE("IndexedDBDatabase::CreateObjectStoreAbortOperation"); | |
| 1729 DCHECK(!transaction); | 1739 DCHECK(!transaction); |
| 1740 IDB_TRACE1("IndexedDBDatabase::CreateObjectStoreAbortOperation", |
| 1741 "txn.id", |
| 1742 transaction->id()); |
| 1730 RemoveObjectStore(object_store_id); | 1743 RemoveObjectStore(object_store_id); |
| 1731 } | 1744 } |
| 1732 | 1745 |
| 1733 void IndexedDBDatabase::DeleteObjectStoreAbortOperation( | 1746 void IndexedDBDatabase::DeleteObjectStoreAbortOperation( |
| 1734 const IndexedDBObjectStoreMetadata& object_store_metadata, | 1747 const IndexedDBObjectStoreMetadata& object_store_metadata, |
| 1735 IndexedDBTransaction* transaction) { | 1748 IndexedDBTransaction* transaction) { |
| 1736 IDB_TRACE("IndexedDBDatabase::DeleteObjectStoreAbortOperation"); | |
| 1737 DCHECK(!transaction); | 1749 DCHECK(!transaction); |
| 1750 IDB_TRACE1("IndexedDBDatabase::DeleteObjectStoreAbortOperation", |
| 1751 "txn.id", |
| 1752 transaction->id()); |
| 1738 AddObjectStore(object_store_metadata, | 1753 AddObjectStore(object_store_metadata, |
| 1739 IndexedDBObjectStoreMetadata::kInvalidId); | 1754 IndexedDBObjectStoreMetadata::kInvalidId); |
| 1740 } | 1755 } |
| 1741 | 1756 |
| 1742 void IndexedDBDatabase::VersionChangeAbortOperation( | 1757 void IndexedDBDatabase::VersionChangeAbortOperation( |
| 1743 const base::string16& previous_version, | 1758 const base::string16& previous_version, |
| 1744 int64 previous_int_version, | 1759 int64 previous_int_version, |
| 1745 IndexedDBTransaction* transaction) { | 1760 IndexedDBTransaction* transaction) { |
| 1746 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | |
| 1747 DCHECK(!transaction); | 1761 DCHECK(!transaction); |
| 1762 IDB_TRACE1("IndexedDBDatabase::VersionChangeAbortOperation", |
| 1763 "txn.id", |
| 1764 transaction->id()); |
| 1748 metadata_.version = previous_version; | 1765 metadata_.version = previous_version; |
| 1749 metadata_.int_version = previous_int_version; | 1766 metadata_.int_version = previous_int_version; |
| 1750 } | 1767 } |
| 1751 | 1768 |
| 1752 } // namespace content | 1769 } // namespace content |
| OLD | NEW |