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

Unified Diff: content/browser/indexed_db/indexed_db_database_unittest.cc

Issue 2642943002: Allow closing IndexedDB database before deleting (Closed)
Patch Set: Actually pass the flag Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_database_unittest.cc
diff --git a/content/browser/indexed_db/indexed_db_database_unittest.cc b/content/browser/indexed_db/indexed_db_database_unittest.cc
index 63d1443e73062f7e16846c23594d3e8c0c45189a..7f83107d086685b504a095189cd2f9f471eed22b 100644
--- a/content/browser/indexed_db/indexed_db_database_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_database_unittest.cc
@@ -204,7 +204,7 @@ TEST_F(IndexedDBDatabaseTest, PendingDelete) {
EXPECT_FALSE(backing_store->HasOneRef()); // local and db
scoped_refptr<MockCallbacks> request2(new MockCallbacks());
- db->DeleteDatabase(request2);
+ db->DeleteDatabase(request2, false /* force_delete */);
EXPECT_EQ(db->ConnectionCount(), 1UL);
EXPECT_EQ(db->ActiveOpenDeleteCount(), 1UL);
EXPECT_EQ(db->PendingOpenDeleteCount(), 0UL);
@@ -228,6 +228,47 @@ TEST_F(IndexedDBDatabaseTest, PendingDelete) {
EXPECT_TRUE(request2->success_called());
}
+TEST_F(IndexedDBDatabaseTest, ForceDelete) {
+ scoped_refptr<IndexedDBFakeBackingStore> backing_store =
+ new IndexedDBFakeBackingStore();
+ EXPECT_TRUE(backing_store->HasOneRef()); // local
+
+ scoped_refptr<MockIndexedDBFactory> factory = new MockIndexedDBFactory();
+ scoped_refptr<IndexedDBDatabase> db;
+ leveldb::Status s;
+ std::tie(db, s) =
+ IndexedDBDatabase::Create(ASCIIToUTF16("db"), backing_store.get(),
+ factory.get(), IndexedDBDatabase::Identifier());
+ ASSERT_TRUE(s.ok());
+ EXPECT_FALSE(backing_store->HasOneRef()); // local and db
+
+ scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks());
+ scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1(
+ new MockIndexedDBDatabaseCallbacks());
+ const int64_t transaction_id1 = 1;
+ std::unique_ptr<IndexedDBPendingConnection> connection(
+ base::MakeUnique<IndexedDBPendingConnection>(
+ request1, callbacks1, kFakeChildProcessId, transaction_id1,
+ IndexedDBDatabaseMetadata::DEFAULT_VERSION));
+ db->OpenConnection(std::move(connection));
+
+ EXPECT_EQ(db->ConnectionCount(), 1UL);
+ EXPECT_EQ(db->ActiveOpenDeleteCount(), 0UL);
+ EXPECT_EQ(db->PendingOpenDeleteCount(), 0UL);
+ EXPECT_FALSE(backing_store->HasOneRef()); // local and db
+
+ scoped_refptr<MockCallbacks> request2(new MockCallbacks());
+ db->DeleteDatabase(request2, true /* force_delete */);
+ EXPECT_EQ(db->ConnectionCount(), 0UL);
+ EXPECT_EQ(db->ActiveOpenDeleteCount(), 0UL);
+ EXPECT_EQ(db->PendingOpenDeleteCount(), 0UL);
+ EXPECT_FALSE(request2->blocked_called());
+
+ EXPECT_FALSE(db->backing_store());
+ EXPECT_TRUE(backing_store->HasOneRef()); // local
+ EXPECT_TRUE(request2->success_called());
+}
+
leveldb::Status DummyOperation(IndexedDBTransaction* transaction) {
return leveldb::Status::OK();
}

Powered by Google App Engine
This is Rietveld 408576698