Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: content/browser/indexed_db/indexed_db_backing_store_unittest.cc

Issue 501183003: Remove implicit conversions from scoped_refptr to T* in content/browser/indexed_db/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_backing_store.h" 5 #include "content/browser/indexed_db/indexed_db_backing_store.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 class IndexedDBBackingStoreTest : public testing::Test { 229 class IndexedDBBackingStoreTest : public testing::Test {
230 public: 230 public:
231 IndexedDBBackingStoreTest() {} 231 IndexedDBBackingStoreTest() {}
232 virtual void SetUp() { 232 virtual void SetUp() {
233 const GURL origin("http://localhost:81"); 233 const GURL origin("http://localhost:81");
234 task_runner_ = new base::TestSimpleTaskRunner(); 234 task_runner_ = new base::TestSimpleTaskRunner();
235 special_storage_policy_ = new MockSpecialStoragePolicy(); 235 special_storage_policy_ = new MockSpecialStoragePolicy();
236 special_storage_policy_->SetAllUnlimited(true); 236 special_storage_policy_->SetAllUnlimited(true);
237 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 237 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
238 idb_context_ = new IndexedDBContextImpl( 238 idb_context_ = new IndexedDBContextImpl(temp_dir_.path(),
239 temp_dir_.path(), special_storage_policy_, NULL, task_runner_); 239 special_storage_policy_.get(),
240 idb_factory_ = new TestIDBFactory(idb_context_); 240 NULL,
241 task_runner_.get());
242 idb_factory_ = new TestIDBFactory(idb_context_.get());
241 backing_store_ = 243 backing_store_ =
242 idb_factory_->OpenBackingStoreForTest(origin, &url_request_context_); 244 idb_factory_->OpenBackingStoreForTest(origin, &url_request_context_);
243 245
244 // useful keys and values during tests 246 // useful keys and values during tests
245 m_value1 = IndexedDBValue("value1", std::vector<IndexedDBBlobInfo>()); 247 m_value1 = IndexedDBValue("value1", std::vector<IndexedDBBlobInfo>());
246 m_value2 = IndexedDBValue("value2", std::vector<IndexedDBBlobInfo>()); 248 m_value2 = IndexedDBValue("value2", std::vector<IndexedDBBlobInfo>());
247 249
248 m_blob_info.push_back( 250 m_blob_info.push_back(
249 IndexedDBBlobInfo("uuid 3", base::UTF8ToUTF16("blob type"), 1)); 251 IndexedDBBlobInfo("uuid 3", base::UTF8ToUTF16("blob type"), 1));
250 m_blob_info.push_back( 252 m_blob_info.push_back(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 368
367 protected: 369 protected:
368 virtual ~TestCallback() {} 370 virtual ~TestCallback() {}
369 371
370 private: 372 private:
371 DISALLOW_COPY_AND_ASSIGN(TestCallback); 373 DISALLOW_COPY_AND_ASSIGN(TestCallback);
372 }; 374 };
373 375
374 TEST_F(IndexedDBBackingStoreTest, PutGetConsistency) { 376 TEST_F(IndexedDBBackingStoreTest, PutGetConsistency) {
375 { 377 {
376 IndexedDBBackingStore::Transaction transaction1(backing_store_); 378 IndexedDBBackingStore::Transaction transaction1(backing_store_.get());
377 transaction1.Begin(); 379 transaction1.Begin();
378 ScopedVector<storage::BlobDataHandle> handles; 380 ScopedVector<storage::BlobDataHandle> handles;
379 IndexedDBBackingStore::RecordIdentifier record; 381 IndexedDBBackingStore::RecordIdentifier record;
380 leveldb::Status s = backing_store_->PutRecord( 382 leveldb::Status s = backing_store_->PutRecord(
381 &transaction1, 1, 1, m_key1, &m_value1, &handles, &record); 383 &transaction1, 1, 1, m_key1, &m_value1, &handles, &record);
382 EXPECT_TRUE(s.ok()); 384 EXPECT_TRUE(s.ok());
383 scoped_refptr<TestCallback> callback(new TestCallback()); 385 scoped_refptr<TestCallback> callback(new TestCallback());
384 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok()); 386 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok());
385 EXPECT_TRUE(callback->called); 387 EXPECT_TRUE(callback->called);
386 EXPECT_TRUE(callback->succeeded); 388 EXPECT_TRUE(callback->succeeded);
387 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); 389 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok());
388 } 390 }
389 391
390 { 392 {
391 IndexedDBBackingStore::Transaction transaction2(backing_store_); 393 IndexedDBBackingStore::Transaction transaction2(backing_store_.get());
392 transaction2.Begin(); 394 transaction2.Begin();
393 IndexedDBValue result_value; 395 IndexedDBValue result_value;
394 EXPECT_TRUE( 396 EXPECT_TRUE(
395 backing_store_->GetRecord(&transaction2, 1, 1, m_key1, &result_value) 397 backing_store_->GetRecord(&transaction2, 1, 1, m_key1, &result_value)
396 .ok()); 398 .ok());
397 scoped_refptr<TestCallback> callback(new TestCallback()); 399 scoped_refptr<TestCallback> callback(new TestCallback());
398 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); 400 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok());
399 EXPECT_TRUE(callback->called); 401 EXPECT_TRUE(callback->called);
400 EXPECT_TRUE(callback->succeeded); 402 EXPECT_TRUE(callback->succeeded);
401 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); 403 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok());
402 EXPECT_EQ(m_value1.bits, result_value.bits); 404 EXPECT_EQ(m_value1.bits, result_value.bits);
403 } 405 }
404 } 406 }
405 407
406 TEST_F(IndexedDBBackingStoreTest, PutGetConsistencyWithBlobs) { 408 TEST_F(IndexedDBBackingStoreTest, PutGetConsistencyWithBlobs) {
407 { 409 {
408 IndexedDBBackingStore::Transaction transaction1(backing_store_); 410 IndexedDBBackingStore::Transaction transaction1(backing_store_.get());
409 transaction1.Begin(); 411 transaction1.Begin();
410 ScopedVector<storage::BlobDataHandle> handles; 412 ScopedVector<storage::BlobDataHandle> handles;
411 IndexedDBBackingStore::RecordIdentifier record; 413 IndexedDBBackingStore::RecordIdentifier record;
412 EXPECT_TRUE(backing_store_->PutRecord(&transaction1, 414 EXPECT_TRUE(backing_store_->PutRecord(&transaction1,
413 1, 415 1,
414 1, 416 1,
415 m_key3, 417 m_key3,
416 &m_value3, 418 &m_value3,
417 &handles, 419 &handles,
418 &record).ok()); 420 &record).ok());
419 scoped_refptr<TestCallback> callback(new TestCallback()); 421 scoped_refptr<TestCallback> callback(new TestCallback());
420 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok()); 422 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok());
421 task_runner_->RunUntilIdle(); 423 task_runner_->RunUntilIdle();
422 EXPECT_TRUE(CheckBlobWrites()); 424 EXPECT_TRUE(CheckBlobWrites());
423 EXPECT_TRUE(callback->called); 425 EXPECT_TRUE(callback->called);
424 EXPECT_TRUE(callback->succeeded); 426 EXPECT_TRUE(callback->succeeded);
425 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); 427 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok());
426 } 428 }
427 429
428 { 430 {
429 IndexedDBBackingStore::Transaction transaction2(backing_store_); 431 IndexedDBBackingStore::Transaction transaction2(backing_store_.get());
430 transaction2.Begin(); 432 transaction2.Begin();
431 IndexedDBValue result_value; 433 IndexedDBValue result_value;
432 EXPECT_TRUE( 434 EXPECT_TRUE(
433 backing_store_->GetRecord(&transaction2, 1, 1, m_key3, &result_value) 435 backing_store_->GetRecord(&transaction2, 1, 1, m_key3, &result_value)
434 .ok()); 436 .ok());
435 scoped_refptr<TestCallback> callback(new TestCallback()); 437 scoped_refptr<TestCallback> callback(new TestCallback());
436 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); 438 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok());
437 EXPECT_TRUE(callback->called); 439 EXPECT_TRUE(callback->called);
438 EXPECT_TRUE(callback->succeeded); 440 EXPECT_TRUE(callback->succeeded);
439 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); 441 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok());
440 EXPECT_EQ(m_value3.bits, result_value.bits); 442 EXPECT_EQ(m_value3.bits, result_value.bits);
441 EXPECT_TRUE(CheckBlobInfoMatches(result_value.blob_info)); 443 EXPECT_TRUE(CheckBlobInfoMatches(result_value.blob_info));
442 EXPECT_TRUE(CheckBlobReadsMatchWrites(result_value.blob_info)); 444 EXPECT_TRUE(CheckBlobReadsMatchWrites(result_value.blob_info));
443 } 445 }
444 446
445 { 447 {
446 IndexedDBBackingStore::Transaction transaction3(backing_store_); 448 IndexedDBBackingStore::Transaction transaction3(backing_store_.get());
447 transaction3.Begin(); 449 transaction3.Begin();
448 IndexedDBValue result_value; 450 IndexedDBValue result_value;
449 EXPECT_TRUE(backing_store_->DeleteRange(&transaction3, 451 EXPECT_TRUE(backing_store_->DeleteRange(&transaction3,
450 1, 452 1,
451 1, 453 1,
452 IndexedDBKeyRange(m_key3)).ok()); 454 IndexedDBKeyRange(m_key3)).ok());
453 scoped_refptr<TestCallback> callback(new TestCallback()); 455 scoped_refptr<TestCallback> callback(new TestCallback());
454 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); 456 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok());
455 task_runner_->RunUntilIdle(); 457 task_runner_->RunUntilIdle();
456 EXPECT_TRUE(callback->called); 458 EXPECT_TRUE(callback->called);
(...skipping 26 matching lines...) Expand all
483 std::vector<IndexedDBBlobInfo> blob_info0, blob_info1, blob_info2, 485 std::vector<IndexedDBBlobInfo> blob_info0, blob_info1, blob_info2,
484 blob_info3; 486 blob_info3;
485 blob_info0.push_back(blob0); 487 blob_info0.push_back(blob0);
486 blob_info1.push_back(blob1); 488 blob_info1.push_back(blob1);
487 blob_info2.push_back(blob2); 489 blob_info2.push_back(blob2);
488 blob_info3.push_back(blob3); 490 blob_info3.push_back(blob3);
489 IndexedDBValue value0 = IndexedDBValue("value0", blob_info0); 491 IndexedDBValue value0 = IndexedDBValue("value0", blob_info0);
490 IndexedDBValue value1 = IndexedDBValue("value1", blob_info1); 492 IndexedDBValue value1 = IndexedDBValue("value1", blob_info1);
491 IndexedDBValue value2 = IndexedDBValue("value2", blob_info2); 493 IndexedDBValue value2 = IndexedDBValue("value2", blob_info2);
492 IndexedDBValue value3 = IndexedDBValue("value3", blob_info3); 494 IndexedDBValue value3 = IndexedDBValue("value3", blob_info3);
493 IndexedDBBackingStore::Transaction transaction1(backing_store_); 495 IndexedDBBackingStore::Transaction transaction1(backing_store_.get());
494 transaction1.Begin(); 496 transaction1.Begin();
495 ScopedVector<storage::BlobDataHandle> handles; 497 ScopedVector<storage::BlobDataHandle> handles;
496 IndexedDBBackingStore::RecordIdentifier record; 498 IndexedDBBackingStore::RecordIdentifier record;
497 EXPECT_TRUE(backing_store_->PutRecord(&transaction1, 499 EXPECT_TRUE(backing_store_->PutRecord(&transaction1,
498 1, 500 1,
499 i + 1, 501 i + 1,
500 key0, 502 key0,
501 &value0, 503 &value0,
502 &handles, 504 &handles,
503 &record).ok()); 505 &record).ok());
(...skipping 20 matching lines...) Expand all
524 &record).ok()); 526 &record).ok());
525 scoped_refptr<TestCallback> callback(new TestCallback()); 527 scoped_refptr<TestCallback> callback(new TestCallback());
526 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok()); 528 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok());
527 task_runner_->RunUntilIdle(); 529 task_runner_->RunUntilIdle();
528 EXPECT_TRUE(callback->called); 530 EXPECT_TRUE(callback->called);
529 EXPECT_TRUE(callback->succeeded); 531 EXPECT_TRUE(callback->succeeded);
530 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); 532 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok());
531 } 533 }
532 534
533 { 535 {
534 IndexedDBBackingStore::Transaction transaction2(backing_store_); 536 IndexedDBBackingStore::Transaction transaction2(backing_store_.get());
535 transaction2.Begin(); 537 transaction2.Begin();
536 IndexedDBValue result_value; 538 IndexedDBValue result_value;
537 EXPECT_TRUE( 539 EXPECT_TRUE(
538 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok()); 540 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok());
539 scoped_refptr<TestCallback> callback(new TestCallback()); 541 scoped_refptr<TestCallback> callback(new TestCallback());
540 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); 542 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok());
541 task_runner_->RunUntilIdle(); 543 task_runner_->RunUntilIdle();
542 EXPECT_TRUE(callback->called); 544 EXPECT_TRUE(callback->called);
543 EXPECT_TRUE(callback->succeeded); 545 EXPECT_TRUE(callback->succeeded);
544 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); 546 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok());
(...skipping 28 matching lines...) Expand all
573 std::vector<IndexedDBBlobInfo> blob_info0, blob_info1, blob_info2, 575 std::vector<IndexedDBBlobInfo> blob_info0, blob_info1, blob_info2,
574 blob_info3; 576 blob_info3;
575 blob_info0.push_back(blob0); 577 blob_info0.push_back(blob0);
576 blob_info1.push_back(blob1); 578 blob_info1.push_back(blob1);
577 blob_info2.push_back(blob2); 579 blob_info2.push_back(blob2);
578 blob_info3.push_back(blob3); 580 blob_info3.push_back(blob3);
579 IndexedDBValue value0 = IndexedDBValue("value0", blob_info0); 581 IndexedDBValue value0 = IndexedDBValue("value0", blob_info0);
580 IndexedDBValue value1 = IndexedDBValue("value1", blob_info1); 582 IndexedDBValue value1 = IndexedDBValue("value1", blob_info1);
581 IndexedDBValue value2 = IndexedDBValue("value2", blob_info2); 583 IndexedDBValue value2 = IndexedDBValue("value2", blob_info2);
582 IndexedDBValue value3 = IndexedDBValue("value3", blob_info3); 584 IndexedDBValue value3 = IndexedDBValue("value3", blob_info3);
583 IndexedDBBackingStore::Transaction transaction1(backing_store_); 585 IndexedDBBackingStore::Transaction transaction1(backing_store_.get());
584 transaction1.Begin(); 586 transaction1.Begin();
585 ScopedVector<storage::BlobDataHandle> handles; 587 ScopedVector<storage::BlobDataHandle> handles;
586 IndexedDBBackingStore::RecordIdentifier record; 588 IndexedDBBackingStore::RecordIdentifier record;
587 EXPECT_TRUE(backing_store_->PutRecord(&transaction1, 589 EXPECT_TRUE(backing_store_->PutRecord(&transaction1,
588 1, 590 1,
589 i + 1, 591 i + 1,
590 key0, 592 key0,
591 &value0, 593 &value0,
592 &handles, 594 &handles,
593 &record).ok()); 595 &record).ok());
(...skipping 20 matching lines...) Expand all
614 &record).ok()); 616 &record).ok());
615 scoped_refptr<TestCallback> callback(new TestCallback()); 617 scoped_refptr<TestCallback> callback(new TestCallback());
616 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok()); 618 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok());
617 task_runner_->RunUntilIdle(); 619 task_runner_->RunUntilIdle();
618 EXPECT_TRUE(callback->called); 620 EXPECT_TRUE(callback->called);
619 EXPECT_TRUE(callback->succeeded); 621 EXPECT_TRUE(callback->succeeded);
620 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); 622 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok());
621 } 623 }
622 624
623 { 625 {
624 IndexedDBBackingStore::Transaction transaction2(backing_store_); 626 IndexedDBBackingStore::Transaction transaction2(backing_store_.get());
625 transaction2.Begin(); 627 transaction2.Begin();
626 IndexedDBValue result_value; 628 IndexedDBValue result_value;
627 EXPECT_TRUE( 629 EXPECT_TRUE(
628 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok()); 630 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok());
629 scoped_refptr<TestCallback> callback(new TestCallback()); 631 scoped_refptr<TestCallback> callback(new TestCallback());
630 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); 632 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok());
631 task_runner_->RunUntilIdle(); 633 task_runner_->RunUntilIdle();
632 EXPECT_TRUE(callback->called); 634 EXPECT_TRUE(callback->called);
633 EXPECT_TRUE(callback->succeeded); 635 EXPECT_TRUE(callback->succeeded);
634 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); 636 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok());
635 EXPECT_EQ(0UL, backing_store_->removals().size()); 637 EXPECT_EQ(0UL, backing_store_->removals().size());
636 } 638 }
637 } 639 }
638 } 640 }
639 641
640 TEST_F(IndexedDBBackingStoreTest, LiveBlobJournal) { 642 TEST_F(IndexedDBBackingStoreTest, LiveBlobJournal) {
641 { 643 {
642 IndexedDBBackingStore::Transaction transaction1(backing_store_); 644 IndexedDBBackingStore::Transaction transaction1(backing_store_.get());
643 transaction1.Begin(); 645 transaction1.Begin();
644 ScopedVector<storage::BlobDataHandle> handles; 646 ScopedVector<storage::BlobDataHandle> handles;
645 IndexedDBBackingStore::RecordIdentifier record; 647 IndexedDBBackingStore::RecordIdentifier record;
646 EXPECT_TRUE(backing_store_->PutRecord(&transaction1, 648 EXPECT_TRUE(backing_store_->PutRecord(&transaction1,
647 1, 649 1,
648 1, 650 1,
649 m_key3, 651 m_key3,
650 &m_value3, 652 &m_value3,
651 &handles, 653 &handles,
652 &record).ok()); 654 &record).ok());
653 scoped_refptr<TestCallback> callback(new TestCallback()); 655 scoped_refptr<TestCallback> callback(new TestCallback());
654 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok()); 656 EXPECT_TRUE(transaction1.CommitPhaseOne(callback).ok());
655 task_runner_->RunUntilIdle(); 657 task_runner_->RunUntilIdle();
656 EXPECT_TRUE(CheckBlobWrites()); 658 EXPECT_TRUE(CheckBlobWrites());
657 EXPECT_TRUE(callback->called); 659 EXPECT_TRUE(callback->called);
658 EXPECT_TRUE(callback->succeeded); 660 EXPECT_TRUE(callback->succeeded);
659 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); 661 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok());
660 } 662 }
661 663
662 IndexedDBValue read_result_value; 664 IndexedDBValue read_result_value;
663 { 665 {
664 IndexedDBBackingStore::Transaction transaction2(backing_store_); 666 IndexedDBBackingStore::Transaction transaction2(backing_store_.get());
665 transaction2.Begin(); 667 transaction2.Begin();
666 EXPECT_TRUE( 668 EXPECT_TRUE(
667 backing_store_->GetRecord( 669 backing_store_->GetRecord(
668 &transaction2, 1, 1, m_key3, &read_result_value) 670 &transaction2, 1, 1, m_key3, &read_result_value)
669 .ok()); 671 .ok());
670 scoped_refptr<TestCallback> callback(new TestCallback()); 672 scoped_refptr<TestCallback> callback(new TestCallback());
671 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); 673 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok());
672 EXPECT_TRUE(callback->called); 674 EXPECT_TRUE(callback->called);
673 EXPECT_TRUE(callback->succeeded); 675 EXPECT_TRUE(callback->succeeded);
674 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); 676 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok());
675 EXPECT_EQ(m_value3.bits, read_result_value.bits); 677 EXPECT_EQ(m_value3.bits, read_result_value.bits);
676 EXPECT_TRUE(CheckBlobInfoMatches(read_result_value.blob_info)); 678 EXPECT_TRUE(CheckBlobInfoMatches(read_result_value.blob_info));
677 EXPECT_TRUE(CheckBlobReadsMatchWrites(read_result_value.blob_info)); 679 EXPECT_TRUE(CheckBlobReadsMatchWrites(read_result_value.blob_info));
678 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { 680 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) {
679 read_result_value.blob_info[i].mark_used_callback().Run(); 681 read_result_value.blob_info[i].mark_used_callback().Run();
680 } 682 }
681 } 683 }
682 684
683 { 685 {
684 IndexedDBBackingStore::Transaction transaction3(backing_store_); 686 IndexedDBBackingStore::Transaction transaction3(backing_store_.get());
685 transaction3.Begin(); 687 transaction3.Begin();
686 EXPECT_TRUE(backing_store_->DeleteRange(&transaction3, 688 EXPECT_TRUE(backing_store_->DeleteRange(&transaction3,
687 1, 689 1,
688 1, 690 1,
689 IndexedDBKeyRange(m_key3)).ok()); 691 IndexedDBKeyRange(m_key3)).ok());
690 scoped_refptr<TestCallback> callback(new TestCallback()); 692 scoped_refptr<TestCallback> callback(new TestCallback());
691 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); 693 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok());
692 task_runner_->RunUntilIdle(); 694 task_runner_->RunUntilIdle();
693 EXPECT_TRUE(callback->called); 695 EXPECT_TRUE(callback->called);
694 EXPECT_TRUE(callback->succeeded); 696 EXPECT_TRUE(callback->succeeded);
(...skipping 16 matching lines...) Expand all
711 const int64 high_object_store_id = 1ULL << 39; 713 const int64 high_object_store_id = 1ULL << 39;
712 // index_ids are capped at 32 bits for storage purposes. 714 // index_ids are capped at 32 bits for storage purposes.
713 const int64 high_index_id = 1ULL << 29; 715 const int64 high_index_id = 1ULL << 29;
714 716
715 const int64 invalid_high_index_id = 1ULL << 37; 717 const int64 invalid_high_index_id = 1ULL << 37;
716 718
717 const IndexedDBKey& index_key = m_key2; 719 const IndexedDBKey& index_key = m_key2;
718 std::string index_key_raw; 720 std::string index_key_raw;
719 EncodeIDBKey(index_key, &index_key_raw); 721 EncodeIDBKey(index_key, &index_key_raw);
720 { 722 {
721 IndexedDBBackingStore::Transaction transaction1(backing_store_); 723 IndexedDBBackingStore::Transaction transaction1(backing_store_.get());
722 transaction1.Begin(); 724 transaction1.Begin();
723 ScopedVector<storage::BlobDataHandle> handles; 725 ScopedVector<storage::BlobDataHandle> handles;
724 IndexedDBBackingStore::RecordIdentifier record; 726 IndexedDBBackingStore::RecordIdentifier record;
725 leveldb::Status s = backing_store_->PutRecord(&transaction1, 727 leveldb::Status s = backing_store_->PutRecord(&transaction1,
726 high_database_id, 728 high_database_id,
727 high_object_store_id, 729 high_object_store_id,
728 m_key1, 730 m_key1,
729 &m_value1, 731 &m_value1,
730 &handles, 732 &handles,
731 &record); 733 &record);
(...skipping 18 matching lines...) Expand all
750 scoped_refptr<TestCallback> callback(new TestCallback()); 752 scoped_refptr<TestCallback> callback(new TestCallback());
751 s = transaction1.CommitPhaseOne(callback); 753 s = transaction1.CommitPhaseOne(callback);
752 EXPECT_TRUE(s.ok()); 754 EXPECT_TRUE(s.ok());
753 EXPECT_TRUE(callback->called); 755 EXPECT_TRUE(callback->called);
754 EXPECT_TRUE(callback->succeeded); 756 EXPECT_TRUE(callback->succeeded);
755 s = transaction1.CommitPhaseTwo(); 757 s = transaction1.CommitPhaseTwo();
756 EXPECT_TRUE(s.ok()); 758 EXPECT_TRUE(s.ok());
757 } 759 }
758 760
759 { 761 {
760 IndexedDBBackingStore::Transaction transaction2(backing_store_); 762 IndexedDBBackingStore::Transaction transaction2(backing_store_.get());
761 transaction2.Begin(); 763 transaction2.Begin();
762 IndexedDBValue result_value; 764 IndexedDBValue result_value;
763 leveldb::Status s = backing_store_->GetRecord(&transaction2, 765 leveldb::Status s = backing_store_->GetRecord(&transaction2,
764 high_database_id, 766 high_database_id,
765 high_object_store_id, 767 high_object_store_id,
766 m_key1, 768 m_key1,
767 &result_value); 769 &result_value);
768 EXPECT_TRUE(s.ok()); 770 EXPECT_TRUE(s.ok());
769 EXPECT_EQ(m_value1.bits, result_value.bits); 771 EXPECT_EQ(m_value1.bits, result_value.bits);
770 772
(...skipping 28 matching lines...) Expand all
799 // Make sure that other invalid ids do not crash. 801 // Make sure that other invalid ids do not crash.
800 TEST_F(IndexedDBBackingStoreTest, InvalidIds) { 802 TEST_F(IndexedDBBackingStoreTest, InvalidIds) {
801 // valid ids for use when testing invalid ids 803 // valid ids for use when testing invalid ids
802 const int64 database_id = 1; 804 const int64 database_id = 1;
803 const int64 object_store_id = 1; 805 const int64 object_store_id = 1;
804 const int64 index_id = kMinimumIndexId; 806 const int64 index_id = kMinimumIndexId;
805 const int64 invalid_low_index_id = 19; // index_ids must be > kMinimumIndexId 807 const int64 invalid_low_index_id = 19; // index_ids must be > kMinimumIndexId
806 808
807 IndexedDBValue result_value; 809 IndexedDBValue result_value;
808 810
809 IndexedDBBackingStore::Transaction transaction1(backing_store_); 811 IndexedDBBackingStore::Transaction transaction1(backing_store_.get());
810 transaction1.Begin(); 812 transaction1.Begin();
811 813
812 ScopedVector<storage::BlobDataHandle> handles; 814 ScopedVector<storage::BlobDataHandle> handles;
813 IndexedDBBackingStore::RecordIdentifier record; 815 IndexedDBBackingStore::RecordIdentifier record;
814 leveldb::Status s = backing_store_->PutRecord(&transaction1, 816 leveldb::Status s = backing_store_->PutRecord(&transaction1,
815 database_id, 817 database_id,
816 KeyPrefix::kInvalidId, 818 KeyPrefix::kInvalidId,
817 m_key1, 819 m_key1,
818 &m_value1, 820 &m_value1,
819 &handles, 821 &handles,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 const bool unique = true; 904 const bool unique = true;
903 const bool multi_entry = true; 905 const bool multi_entry = true;
904 const IndexedDBKeyPath index_key_path(ASCIIToUTF16("index_key")); 906 const IndexedDBKeyPath index_key_path(ASCIIToUTF16("index_key"));
905 907
906 { 908 {
907 leveldb::Status s = backing_store_->CreateIDBDatabaseMetaData( 909 leveldb::Status s = backing_store_->CreateIDBDatabaseMetaData(
908 database_name, version, int_version, &database_id); 910 database_name, version, int_version, &database_id);
909 EXPECT_TRUE(s.ok()); 911 EXPECT_TRUE(s.ok());
910 EXPECT_GT(database_id, 0); 912 EXPECT_GT(database_id, 0);
911 913
912 IndexedDBBackingStore::Transaction transaction(backing_store_); 914 IndexedDBBackingStore::Transaction transaction(backing_store_.get());
913 transaction.Begin(); 915 transaction.Begin();
914 916
915 s = backing_store_->CreateObjectStore(&transaction, 917 s = backing_store_->CreateObjectStore(&transaction,
916 database_id, 918 database_id,
917 object_store_id, 919 object_store_id,
918 object_store_name, 920 object_store_name,
919 object_store_key_path, 921 object_store_key_path,
920 auto_increment); 922 auto_increment);
921 EXPECT_TRUE(s.ok()); 923 EXPECT_TRUE(s.ok());
922 924
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 998
997 std::vector<base::string16> names = backing_store_->GetDatabaseNames(&s); 999 std::vector<base::string16> names = backing_store_->GetDatabaseNames(&s);
998 EXPECT_TRUE(s.ok()); 1000 EXPECT_TRUE(s.ok());
999 EXPECT_EQ(names.size(), 1ULL); 1001 EXPECT_EQ(names.size(), 1ULL);
1000 EXPECT_EQ(names[0], db1_name); 1002 EXPECT_EQ(names[0], db1_name);
1001 } 1003 }
1002 1004
1003 } // namespace 1005 } // namespace
1004 1006
1005 } // namespace content 1007 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.cc ('k') | content/browser/indexed_db/indexed_db_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698