diff options
Diffstat (limited to 'chromium/content/browser/indexed_db/indexed_db_factory_unittest.cc')
-rw-r--r-- | chromium/content/browser/indexed_db/indexed_db_factory_unittest.cc | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/chromium/content/browser/indexed_db/indexed_db_factory_unittest.cc b/chromium/content/browser/indexed_db/indexed_db_factory_unittest.cc index 2384f769124..0031ef8024b 100644 --- a/chromium/content/browser/indexed_db/indexed_db_factory_unittest.cc +++ b/chromium/content/browser/indexed_db/indexed_db_factory_unittest.cc @@ -180,6 +180,9 @@ TEST_F(IndexedDBFactoryTest, BackingStoreLazyClose) { } TEST_F(IndexedDBFactoryTest, BackingStoreNoSweeping) { + base::test::ScopedFeatureList feature_list; + feature_list.InitWithFeatures( + {}, {kIDBTombstoneDeletion, kIDBTombstoneStatistics}); context()->TaskRunner()->PostTask( FROM_HERE, base::BindOnce( @@ -209,7 +212,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreNoSweeping) { EXPECT_FALSE(store_ptr->close_timer()->IsRunning()); factory->TestReleaseBackingStore(store_ptr, false); EXPECT_TRUE(store_ptr->close_timer()->IsRunning()); - store_ptr->close_timer()->user_task().Run(); + store_ptr->close_timer()->FireNow(); // Backing store should be totally closed. EXPECT_FALSE(factory->IsBackingStoreOpen(origin)); @@ -225,7 +228,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreNoSweeping) { // Sweep should NOT be occurring. EXPECT_TRUE(store_ptr->close_timer()->IsRunning()); - store_ptr->close_timer()->user_task().Run(); + store_ptr->close_timer()->FireNow(); // Backing store should be totally closed. EXPECT_FALSE(factory->IsBackingStoreOpen(origin)); @@ -268,7 +271,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreRunPreCloseTasks) { EXPECT_FALSE(store_ptr->close_timer()->IsRunning()); factory->TestReleaseBackingStore(store_ptr, false); EXPECT_TRUE(store_ptr->close_timer()->IsRunning()); - store_ptr->close_timer()->user_task().Run(); + store_ptr->close_timer()->FireNow(); // Backing store should be totally closed. EXPECT_FALSE(factory->IsBackingStoreOpen(origin)); @@ -284,8 +287,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreRunPreCloseTasks) { // Sweep should be occuring. EXPECT_TRUE(store_ptr->close_timer()->IsRunning()); - store_ptr->close_timer()->user_task().Run(); - store_ptr->close_timer()->AbandonAndStop(); + store_ptr->close_timer()->FireNow(); ASSERT_NE(nullptr, store_ptr->pre_close_task_queue()); EXPECT_TRUE(store_ptr->pre_close_task_queue()->started()); @@ -309,8 +311,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreRunPreCloseTasks) { // Sweep should be occuring. EXPECT_TRUE(store_ptr->close_timer()->IsRunning()); - store_ptr->close_timer()->user_task().Run(); - store_ptr->close_timer()->AbandonAndStop(); + store_ptr->close_timer()->FireNow(); ASSERT_NE(nullptr, store_ptr->pre_close_task_queue()); EXPECT_TRUE(store_ptr->pre_close_task_queue()->started()); @@ -324,6 +325,41 @@ TEST_F(IndexedDBFactoryTest, BackingStoreRunPreCloseTasks) { RunAllTasksUntilIdle(); } +TEST_F(IndexedDBFactoryTest, BackingStoreCloseImmediatelySwitch) { + base::test::ScopedFeatureList feature_list; + feature_list.InitWithFeatures({kIDBTombstoneStatistics}, + {kIDBTombstoneDeletion}); + base::CommandLine::ForCurrentProcess()->AppendSwitch( + kIDBCloseImmediatelySwitch); + + context()->TaskRunner()->PostTask( + FROM_HERE, + base::BindOnce( + [](IndexedDBContextImpl* context) { + base::SimpleTestClock clock; + clock.SetNow(base::Time::Now()); + + scoped_refptr<MockIDBFactory> factory = + base::MakeRefCounted<MockIDBFactory>(context, &clock); + + const Origin origin = Origin::Create(GURL("http://localhost:81")); + + scoped_refptr<IndexedDBBackingStore> store = + factory->TestOpenBackingStore(origin, context->data_path()); + + // Give up the local refptr so that the factory has the only + // outstanding reference. + IndexedDBBackingStore* store_ptr = store.get(); + store = nullptr; + EXPECT_FALSE(store_ptr->close_timer()->IsRunning()); + factory->TestReleaseBackingStore(store_ptr, false); + EXPECT_FALSE(factory->IsBackingStoreOpen(origin)); + }, + base::Unretained(context()))); + + RunAllTasksUntilIdle(); +} + TEST_F(IndexedDBFactoryTest, MemoryBackingStoreLifetime) { context()->TaskRunner()->PostTask( FROM_HERE, |