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

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

Issue 2712713005: Revert of IndexedDB: Optimize range deletion operations (e.g. clearing a store) (Closed)
Patch Set: Created 3 years, 10 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 <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
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 EXPECT_TRUE( 476 size_t delete_count = 0;
477 backing_store_ 477 EXPECT_TRUE(backing_store_
478 ->DeleteRange(&transaction3, 1, 1, IndexedDBKeyRange(m_key3)) 478 ->DeleteRange(&transaction3, 1, 1,
479 .ok()); 479 IndexedDBKeyRange(m_key3), &delete_count)
480 .ok());
481 EXPECT_EQ(1UL, delete_count);
480 scoped_refptr<TestCallback> callback(new TestCallback()); 482 scoped_refptr<TestCallback> callback(new TestCallback());
481 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); 483 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok());
482 task_runner_->RunUntilIdle(); 484 task_runner_->RunUntilIdle();
483 EXPECT_TRUE(callback->called); 485 EXPECT_TRUE(callback->called);
484 EXPECT_TRUE(callback->succeeded); 486 EXPECT_TRUE(callback->succeeded);
485 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); 487 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok());
486 EXPECT_TRUE(CheckBlobRemovals()); 488 EXPECT_TRUE(CheckBlobRemovals());
487 } 489 }
488 } 490 }
489 491
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 task_runner_->RunUntilIdle(); 556 task_runner_->RunUntilIdle();
555 EXPECT_TRUE(callback->called); 557 EXPECT_TRUE(callback->called);
556 EXPECT_TRUE(callback->succeeded); 558 EXPECT_TRUE(callback->succeeded);
557 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); 559 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok());
558 } 560 }
559 561
560 { 562 {
561 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); 563 IndexedDBBackingStore::Transaction transaction2(backing_store_.get());
562 transaction2.Begin(); 564 transaction2.Begin();
563 IndexedDBValue result_value; 565 IndexedDBValue result_value;
566 size_t delete_count = 0;
564 EXPECT_TRUE( 567 EXPECT_TRUE(
565 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok()); 568 backing_store_
569 ->DeleteRange(&transaction2, 1, i + 1, ranges[i], &delete_count)
570 .ok());
571 EXPECT_EQ(2UL, delete_count);
566 scoped_refptr<TestCallback> callback(new TestCallback()); 572 scoped_refptr<TestCallback> callback(new TestCallback());
567 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); 573 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok());
568 task_runner_->RunUntilIdle(); 574 task_runner_->RunUntilIdle();
569 EXPECT_TRUE(callback->called); 575 EXPECT_TRUE(callback->called);
570 EXPECT_TRUE(callback->succeeded); 576 EXPECT_TRUE(callback->succeeded);
571 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); 577 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok());
572 ASSERT_EQ(2UL, backing_store_->removals().size()); 578 ASSERT_EQ(2UL, backing_store_->removals().size());
573 EXPECT_EQ(backing_store_->writes()[1].key(), 579 EXPECT_EQ(backing_store_->writes()[1].key(),
574 backing_store_->removals()[0]); 580 backing_store_->removals()[0]);
575 EXPECT_EQ(backing_store_->writes()[2].key(), 581 EXPECT_EQ(backing_store_->writes()[2].key(),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 task_runner_->RunUntilIdle(); 650 task_runner_->RunUntilIdle();
645 EXPECT_TRUE(callback->called); 651 EXPECT_TRUE(callback->called);
646 EXPECT_TRUE(callback->succeeded); 652 EXPECT_TRUE(callback->succeeded);
647 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok()); 653 EXPECT_TRUE(transaction1.CommitPhaseTwo().ok());
648 } 654 }
649 655
650 { 656 {
651 IndexedDBBackingStore::Transaction transaction2(backing_store_.get()); 657 IndexedDBBackingStore::Transaction transaction2(backing_store_.get());
652 transaction2.Begin(); 658 transaction2.Begin();
653 IndexedDBValue result_value; 659 IndexedDBValue result_value;
660 size_t delete_count = 0;
654 EXPECT_TRUE( 661 EXPECT_TRUE(
655 backing_store_->DeleteRange(&transaction2, 1, i + 1, ranges[i]).ok()); 662 backing_store_
663 ->DeleteRange(&transaction2, 1, i + 1, ranges[i], &delete_count)
664 .ok());
665 EXPECT_EQ(0UL, delete_count);
656 scoped_refptr<TestCallback> callback(new TestCallback()); 666 scoped_refptr<TestCallback> callback(new TestCallback());
657 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok()); 667 EXPECT_TRUE(transaction2.CommitPhaseOne(callback).ok());
658 task_runner_->RunUntilIdle(); 668 task_runner_->RunUntilIdle();
659 EXPECT_TRUE(callback->called); 669 EXPECT_TRUE(callback->called);
660 EXPECT_TRUE(callback->succeeded); 670 EXPECT_TRUE(callback->succeeded);
661 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok()); 671 EXPECT_TRUE(transaction2.CommitPhaseTwo().ok());
662 EXPECT_EQ(0UL, backing_store_->removals().size()); 672 EXPECT_EQ(0UL, backing_store_->removals().size());
663 } 673 }
664 } 674 }
665 } 675 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 EXPECT_TRUE(CheckBlobInfoMatches(read_result_value.blob_info)); 749 EXPECT_TRUE(CheckBlobInfoMatches(read_result_value.blob_info));
740 EXPECT_TRUE(CheckBlobReadsMatchWrites(read_result_value.blob_info)); 750 EXPECT_TRUE(CheckBlobReadsMatchWrites(read_result_value.blob_info));
741 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { 751 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) {
742 read_result_value.blob_info[i].mark_used_callback().Run(); 752 read_result_value.blob_info[i].mark_used_callback().Run();
743 } 753 }
744 } 754 }
745 755
746 { 756 {
747 IndexedDBBackingStore::Transaction transaction3(backing_store_.get()); 757 IndexedDBBackingStore::Transaction transaction3(backing_store_.get());
748 transaction3.Begin(); 758 transaction3.Begin();
749 EXPECT_TRUE( 759 size_t delete_count = 0;
750 backing_store_ 760 EXPECT_TRUE(backing_store_
751 ->DeleteRange(&transaction3, 1, 1, IndexedDBKeyRange(m_key3)) 761 ->DeleteRange(&transaction3, 1, 1,
752 .ok()); 762 IndexedDBKeyRange(m_key3), &delete_count)
763 .ok());
764 EXPECT_EQ(1UL, delete_count);
753 scoped_refptr<TestCallback> callback(new TestCallback()); 765 scoped_refptr<TestCallback> callback(new TestCallback());
754 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok()); 766 EXPECT_TRUE(transaction3.CommitPhaseOne(callback).ok());
755 task_runner_->RunUntilIdle(); 767 task_runner_->RunUntilIdle();
756 EXPECT_TRUE(callback->called); 768 EXPECT_TRUE(callback->called);
757 EXPECT_TRUE(callback->succeeded); 769 EXPECT_TRUE(callback->succeeded);
758 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok()); 770 EXPECT_TRUE(transaction3.CommitPhaseTwo().ok());
759 EXPECT_EQ(0U, backing_store_->removals().size()); 771 EXPECT_EQ(0U, backing_store_->removals().size());
760 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) { 772 for (size_t i = 0; i < read_result_value.blob_info.size(); ++i) {
761 read_result_value.blob_info[i].release_callback().Run( 773 read_result_value.blob_info[i].release_callback().Run(
762 read_result_value.blob_info[i].file_path()); 774 read_result_value.blob_info[i].file_path());
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 1158
1147 // Dictionary, message key and more. 1159 // Dictionary, message key and more.
1148 ASSERT_TRUE(WriteFile(info_path, "{\"message\":\"foo\",\"bar\":5}")); 1160 ASSERT_TRUE(WriteFile(info_path, "{\"message\":\"foo\",\"bar\":5}"));
1149 EXPECT_TRUE( 1161 EXPECT_TRUE(
1150 IndexedDBBackingStore::ReadCorruptionInfo(path_base, origin, &message)); 1162 IndexedDBBackingStore::ReadCorruptionInfo(path_base, origin, &message));
1151 EXPECT_FALSE(PathExists(info_path)); 1163 EXPECT_FALSE(PathExists(info_path));
1152 EXPECT_EQ("foo", message); 1164 EXPECT_EQ("foo", message);
1153 } 1165 }
1154 1166
1155 } // namespace content 1167 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.cc ('k') | content/browser/indexed_db/indexed_db_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698