| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); | 452 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); |
| 453 EXPECT_EQ(m_value3.bits, result_value.bits); | 453 EXPECT_EQ(m_value3.bits, result_value.bits); |
| 454 EXPECT_TRUE(CheckBlobInfoMatches(result_value.blob_info)); | 454 EXPECT_TRUE(CheckBlobInfoMatches(result_value.blob_info)); |
| 455 EXPECT_TRUE(CheckBlobReadsMatchWrites(result_value.blob_info)); | 455 EXPECT_TRUE(CheckBlobReadsMatchWrites(result_value.blob_info)); |
| 456 } | 456 } |
| 457 | 457 |
| 458 { | 458 { |
| 459 IndexedDBBackingStore::Transaction transaction3(backing_store_.get()); | 459 IndexedDBBackingStore::Transaction transaction3(backing_store_.get()); |
| 460 transaction3.Begin(); | 460 transaction3.Begin(); |
| 461 IndexedDBValue result_value; | 461 IndexedDBValue result_value; |
| 462 EXPECT_TRUE(backing_store_->DeleteRange(&transaction3, | 462 size_t delete_count = 0; |
| 463 1, | 463 EXPECT_TRUE(backing_store_ |
| 464 1, | 464 ->DeleteRange(&transaction3, 1, 1, |
| 465 IndexedDBKeyRange(m_key3)).ok()); | 465 IndexedDBKeyRange(m_key3), &delete_count) |
| 466 .ok()); |
| 467 EXPECT_EQ(1UL, delete_count); |
| 466 scoped_refptr<TestCallback> callback(new TestCallback()); | 468 scoped_refptr<TestCallback> callback(new TestCallback()); |
| 467 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); | 469 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); |
| 468 task_runner_->RunUntilIdle(); | 470 task_runner_->RunUntilIdle(); |
| 469 EXPECT_TRUE(callback->called); | 471 EXPECT_TRUE(callback->called); |
| 470 EXPECT_TRUE(callback->succeeded); | 472 EXPECT_TRUE(callback->succeeded); |
| 471 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); | 473 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); |
| 472 EXPECT_TRUE(CheckBlobRemovals()); | 474 EXPECT_TRUE(CheckBlobRemovals()); |
| 473 } | 475 } |
| 474 } | 476 } |
| 475 | 477 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 task_runner_->RunUntilIdle(); | 542 task_runner_->RunUntilIdle(); |
| 541 EXPECT_TRUE(callback->called); | 543 EXPECT_TRUE(callback->called); |
| 542 EXPECT_TRUE(callback->succeeded); | 544 EXPECT_TRUE(callback->succeeded); |
| 543 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); | 545 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); |
| 544 } | 546 } |
| 545 | 547 |
| 546 { | 548 { |
| 547 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); | 549 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); |
| 548 transaction2.Begin(); | 550 transaction2.Begin(); |
| 549 IndexedDBValue result_value; | 551 IndexedDBValue result_value; |
| 552 size_t delete_count = 0; |
| 550 EXPECT_TRUE( | 553 EXPECT_TRUE( |
| 551 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok()); | 554 backing_store_ |
| 555 ->DeleteRange(&transaction2, 1, i + 1, ranges[i], &delete_count) |
| 556 .ok()); |
| 557 EXPECT_EQ(2UL, delete_count); |
| 552 scoped_refptr<TestCallback> callback(new TestCallback()); | 558 scoped_refptr<TestCallback> callback(new TestCallback()); |
| 553 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); | 559 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); |
| 554 task_runner_->RunUntilIdle(); | 560 task_runner_->RunUntilIdle(); |
| 555 EXPECT_TRUE(callback->called); | 561 EXPECT_TRUE(callback->called); |
| 556 EXPECT_TRUE(callback->succeeded); | 562 EXPECT_TRUE(callback->succeeded); |
| 557 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); | 563 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); |
| 558 EXPECT_EQ(2UL, backing_store_->removals().size()); | 564 EXPECT_EQ(2UL, backing_store_->removals().size()); |
| 559 EXPECT_EQ(backing_store_->writes()[1].key(), | 565 EXPECT_EQ(backing_store_->writes()[1].key(), |
| 560 backing_store_->removals()[0]); | 566 backing_store_->removals()[0]); |
| 561 EXPECT_EQ(backing_store_->writes()[2].key(), | 567 EXPECT_EQ(backing_store_->writes()[2].key(), |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 task_runner_->RunUntilIdle(); | 636 task_runner_->RunUntilIdle(); |
| 631 EXPECT_TRUE(callback->called); | 637 EXPECT_TRUE(callback->called); |
| 632 EXPECT_TRUE(callback->succeeded); | 638 EXPECT_TRUE(callback->succeeded); |
| 633 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); | 639 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); |
| 634 } | 640 } |
| 635 | 641 |
| 636 { | 642 { |
| 637 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); | 643 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); |
| 638 transaction2.Begin(); | 644 transaction2.Begin(); |
| 639 IndexedDBValue result_value; | 645 IndexedDBValue result_value; |
| 646 size_t delete_count = 0; |
| 640 EXPECT_TRUE( | 647 EXPECT_TRUE( |
| 641 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok()); | 648 backing_store_ |
| 649 ->DeleteRange(&transaction2, 1, i + 1, ranges[i], &delete_count) |
| 650 .ok()); |
| 651 EXPECT_EQ(0UL, delete_count); |
| 642 scoped_refptr<TestCallback> callback(new TestCallback()); | 652 scoped_refptr<TestCallback> callback(new TestCallback()); |
| 643 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); | 653 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); |
| 644 task_runner_->RunUntilIdle(); | 654 task_runner_->RunUntilIdle(); |
| 645 EXPECT_TRUE(callback->called); | 655 EXPECT_TRUE(callback->called); |
| 646 EXPECT_TRUE(callback->succeeded); | 656 EXPECT_TRUE(callback->succeeded); |
| 647 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); | 657 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); |
| 648 EXPECT_EQ(0UL, backing_store_->removals().size()); | 658 EXPECT_EQ(0UL, backing_store_->removals().size()); |
| 649 } | 659 } |
| 650 } | 660 } |
| 651 } | 661 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 EXPECT_TRUE(CheckBlobInfoMatches(read_result_value.blob_info)); | 735 EXPECT_TRUE(CheckBlobInfoMatches(read_result_value.blob_info)); |
| 726 EXPECT_TRUE(CheckBlobReadsMatchWrites(read_result_value.blob_info)); | 736 EXPECT_TRUE(CheckBlobReadsMatchWrites(read_result_value.blob_info)); |
| 727 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { | 737 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { |
| 728 read_result_value.blob_info[i].mark_used_callback().Run(); | 738 read_result_value.blob_info[i].mark_used_callback().Run(); |
| 729 } | 739 } |
| 730 } | 740 } |
| 731 | 741 |
| 732 { | 742 { |
| 733 IndexedDBBackingStore::Transaction transaction3(backing_store_.get()); | 743 IndexedDBBackingStore::Transaction transaction3(backing_store_.get()); |
| 734 transaction3.Begin(); | 744 transaction3.Begin(); |
| 735 EXPECT_TRUE(backing_store_->DeleteRange(&transaction3, | 745 size_t delete_count = 0; |
| 736 1, | 746 EXPECT_TRUE(backing_store_ |
| 737 1, | 747 ->DeleteRange(&transaction3, 1, 1, |
| 738 IndexedDBKeyRange(m_key3)).ok()); | 748 IndexedDBKeyRange(m_key3), &delete_count) |
| 749 .ok()); |
| 750 EXPECT_EQ(1UL, delete_count); |
| 739 scoped_refptr<TestCallback> callback(new TestCallback()); | 751 scoped_refptr<TestCallback> callback(new TestCallback()); |
| 740 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); | 752 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); |
| 741 task_runner_->RunUntilIdle(); | 753 task_runner_->RunUntilIdle(); |
| 742 EXPECT_TRUE(callback->called); | 754 EXPECT_TRUE(callback->called); |
| 743 EXPECT_TRUE(callback->succeeded); | 755 EXPECT_TRUE(callback->succeeded); |
| 744 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); | 756 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); |
| 745 EXPECT_EQ(0U, backing_store_->removals().size()); | 757 EXPECT_EQ(0U, backing_store_->removals().size()); |
| 746 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { | 758 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { |
| 747 read_result_value.blob_info[i].release_callback().Run( | 759 read_result_value.blob_info[i].release_callback().Run( |
| 748 read_result_value.blob_info[i].file_path()); | 760 read_result_value.blob_info[i].file_path()); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 | 1053 |
| 1042 std::vector<base::string16> names = backing_store_->GetDatabaseNames(&s); | 1054 std::vector<base::string16> names = backing_store_->GetDatabaseNames(&s); |
| 1043 EXPECT_TRUE(s.ok()); | 1055 EXPECT_TRUE(s.ok()); |
| 1044 EXPECT_EQ(names.size(), 1ULL); | 1056 EXPECT_EQ(names.size(), 1ULL); |
| 1045 EXPECT_EQ(names[0], db1_name); | 1057 EXPECT_EQ(names[0], db1_name); |
| 1046 } | 1058 } |
| 1047 | 1059 |
| 1048 } // namespace | 1060 } // namespace |
| 1049 | 1061 |
| 1050 } // namespace content | 1062 } // namespace content |
| OLD | NEW |