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_backing_store.h" | 5 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); | 466 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); |
467 EXPECT_EQ(m_value3.bits, result_value.bits); | 467 EXPECT_EQ(m_value3.bits, result_value.bits); |
468 EXPECT_TRUE(CheckBlobInfoMatches(result_value.blob_info)); | 468 EXPECT_TRUE(CheckBlobInfoMatches(result_value.blob_info)); |
469 EXPECT_TRUE(CheckBlobReadsMatchWrites(result_value.blob_info)); | 469 EXPECT_TRUE(CheckBlobReadsMatchWrites(result_value.blob_info)); |
470 } | 470 } |
471 | 471 |
472 { | 472 { |
473 IndexedDBBackingStore::Transaction transaction3(backing_store_.get()); | 473 IndexedDBBackingStore::Transaction transaction3(backing_store_.get()); |
474 transaction3.Begin(); | 474 transaction3.Begin(); |
475 IndexedDBValue result_value; | 475 IndexedDBValue result_value; |
476 size_t delete_count = 0; | 476 EXPECT_TRUE( |
477 EXPECT_TRUE(backing_store_ | 477 backing_store_ |
478 ->DeleteRange(&transaction3, 1, 1, | 478 ->DeleteRange(&transaction3, 1, 1, IndexedDBKeyRange(m_key3)) |
479 IndexedDBKeyRange(m_key3), &delete_count) | 479 .ok()); |
480 .ok()); | |
481 EXPECT_EQ(1UL, delete_count); | |
482 scoped_refptr<TestCallback> callback(new TestCallback()); | 480 scoped_refptr<TestCallback> callback(new TestCallback()); |
483 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); | 481 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); |
484 task_runner_->RunUntilIdle(); | 482 task_runner_->RunUntilIdle(); |
485 EXPECT_TRUE(callback->called); | 483 EXPECT_TRUE(callback->called); |
486 EXPECT_TRUE(callback->succeeded); | 484 EXPECT_TRUE(callback->succeeded); |
487 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); | 485 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); |
488 EXPECT_TRUE(CheckBlobRemovals()); | 486 EXPECT_TRUE(CheckBlobRemovals()); |
489 } | 487 } |
490 } | 488 } |
491 | 489 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 task_runner_->RunUntilIdle(); | 554 task_runner_->RunUntilIdle(); |
557 EXPECT_TRUE(callback->called); | 555 EXPECT_TRUE(callback->called); |
558 EXPECT_TRUE(callback->succeeded); | 556 EXPECT_TRUE(callback->succeeded); |
559 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); | 557 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); |
560 } | 558 } |
561 | 559 |
562 { | 560 { |
563 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); | 561 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); |
564 transaction2.Begin(); | 562 transaction2.Begin(); |
565 IndexedDBValue result_value; | 563 IndexedDBValue result_value; |
566 size_t delete_count = 0; | |
567 EXPECT_TRUE( | 564 EXPECT_TRUE( |
568 backing_store_ | 565 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok()); |
569 ->DeleteRange(&transaction2, 1, i + 1, ranges[i], &delete_count) | |
570 .ok()); | |
571 EXPECT_EQ(2UL, delete_count); | |
572 scoped_refptr<TestCallback> callback(new TestCallback()); | 566 scoped_refptr<TestCallback> callback(new TestCallback()); |
573 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); | 567 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); |
574 task_runner_->RunUntilIdle(); | 568 task_runner_->RunUntilIdle(); |
575 EXPECT_TRUE(callback->called); | 569 EXPECT_TRUE(callback->called); |
576 EXPECT_TRUE(callback->succeeded); | 570 EXPECT_TRUE(callback->succeeded); |
577 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); | 571 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); |
578 ASSERT_EQ(2UL, backing_store_->removals().size()); | 572 ASSERT_EQ(2UL, backing_store_->removals().size()); |
579 EXPECT_EQ(backing_store_->writes()[1].key(), | 573 EXPECT_EQ(backing_store_->writes()[1].key(), |
580 backing_store_->removals()[0]); | 574 backing_store_->removals()[0]); |
581 EXPECT_EQ(backing_store_->writes()[2].key(), | 575 EXPECT_EQ(backing_store_->writes()[2].key(), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 task_runner_->RunUntilIdle(); | 644 task_runner_->RunUntilIdle(); |
651 EXPECT_TRUE(callback->called); | 645 EXPECT_TRUE(callback->called); |
652 EXPECT_TRUE(callback->succeeded); | 646 EXPECT_TRUE(callback->succeeded); |
653 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); | 647 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); |
654 } | 648 } |
655 | 649 |
656 { | 650 { |
657 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); | 651 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); |
658 transaction2.Begin(); | 652 transaction2.Begin(); |
659 IndexedDBValue result_value; | 653 IndexedDBValue result_value; |
660 size_t delete_count = 0; | |
661 EXPECT_TRUE( | 654 EXPECT_TRUE( |
662 backing_store_ | 655 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok()); |
663 ->DeleteRange(&transaction2, 1, i + 1, ranges[i], &delete_count) | |
664 .ok()); | |
665 EXPECT_EQ(0UL, delete_count); | |
666 scoped_refptr<TestCallback> callback(new TestCallback()); | 656 scoped_refptr<TestCallback> callback(new TestCallback()); |
667 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); | 657 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); |
668 task_runner_->RunUntilIdle(); | 658 task_runner_->RunUntilIdle(); |
669 EXPECT_TRUE(callback->called); | 659 EXPECT_TRUE(callback->called); |
670 EXPECT_TRUE(callback->succeeded); | 660 EXPECT_TRUE(callback->succeeded); |
671 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); | 661 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); |
672 EXPECT_EQ(0UL, backing_store_->removals().size()); | 662 EXPECT_EQ(0UL, backing_store_->removals().size()); |
673 } | 663 } |
674 } | 664 } |
675 } | 665 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 EXPECT_TRUE(CheckBlobInfoMatches(read_result_value.blob_info)); | 739 EXPECT_TRUE(CheckBlobInfoMatches(read_result_value.blob_info)); |
750 EXPECT_TRUE(CheckBlobReadsMatchWrites(read_result_value.blob_info)); | 740 EXPECT_TRUE(CheckBlobReadsMatchWrites(read_result_value.blob_info)); |
751 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { | 741 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { |
752 read_result_value.blob_info[i].mark_used_callback().Run(); | 742 read_result_value.blob_info[i].mark_used_callback().Run(); |
753 } | 743 } |
754 } | 744 } |
755 | 745 |
756 { | 746 { |
757 IndexedDBBackingStore::Transaction transaction3(backing_store_.get()); | 747 IndexedDBBackingStore::Transaction transaction3(backing_store_.get()); |
758 transaction3.Begin(); | 748 transaction3.Begin(); |
759 size_t delete_count = 0; | 749 EXPECT_TRUE( |
760 EXPECT_TRUE(backing_store_ | 750 backing_store_ |
761 ->DeleteRange(&transaction3, 1, 1, | 751 ->DeleteRange(&transaction3, 1, 1, IndexedDBKeyRange(m_key3)) |
762 IndexedDBKeyRange(m_key3), &delete_count) | 752 .ok()); |
763 .ok()); | |
764 EXPECT_EQ(1UL, delete_count); | |
765 scoped_refptr<TestCallback> callback(new TestCallback()); | 753 scoped_refptr<TestCallback> callback(new TestCallback()); |
766 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); | 754 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); |
767 task_runner_->RunUntilIdle(); | 755 task_runner_->RunUntilIdle(); |
768 EXPECT_TRUE(callback->called); | 756 EXPECT_TRUE(callback->called); |
769 EXPECT_TRUE(callback->succeeded); | 757 EXPECT_TRUE(callback->succeeded); |
770 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); | 758 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); |
771 EXPECT_EQ(0U, backing_store_->removals().size()); | 759 EXPECT_EQ(0U, backing_store_->removals().size()); |
772 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { | 760 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { |
773 read_result_value.blob_info[i].release_callback().Run( | 761 read_result_value.blob_info[i].release_callback().Run( |
774 read_result_value.blob_info[i].file_path()); | 762 read_result_value.blob_info[i].file_path()); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 | 1146 |
1159 // Dictionary, message key and more. | 1147 // Dictionary, message key and more. |
1160 ASSERT_TRUE(WriteFile(info_path, "{\"message\":\"foo\",\"bar\":5}")); | 1148 ASSERT_TRUE(WriteFile(info_path, "{\"message\":\"foo\",\"bar\":5}")); |
1161 EXPECT_TRUE( | 1149 EXPECT_TRUE( |
1162 IndexedDBBackingStore::ReadCorruptionInfo(path_base, origin, &message)); | 1150 IndexedDBBackingStore::ReadCorruptionInfo(path_base, origin, &message)); |
1163 EXPECT_FALSE(PathExists(info_path)); | 1151 EXPECT_FALSE(PathExists(info_path)); |
1164 EXPECT_EQ("foo", message); | 1152 EXPECT_EQ("foo", message); |
1165 } | 1153 } |
1166 | 1154 |
1167 } // namespace content | 1155 } // namespace content |
OLD | NEW |