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

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

Issue 2472213003: [IndexedDB] Refactoring to remove ref ptrs and host transaction ids. (Closed)
Patch Set: comments & rebase Created 4 years, 1 month 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_factory_unittest.cc
diff --git a/content/browser/indexed_db/indexed_db_factory_unittest.cc b/content/browser/indexed_db/indexed_db_factory_unittest.cc
index 005b40c366695935e6ee1c95211c86eab88a5cc7..1ae5420e2f9633ccf68d42a5833a92b5e45417e4 100644
--- a/content/browser/indexed_db/indexed_db_factory_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_factory_unittest.cc
@@ -255,7 +255,7 @@ TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) {
std::unique_ptr<IndexedDBPendingConnection> connection(
base::MakeUnique<IndexedDBPendingConnection>(
callbacks, dummy_database_callbacks, 0 /* child_process_id */,
- 2 /* transaction_id */, 1 /* version */));
+ url::Origin(), 2 /* transaction_id */, 1 /* version */));
factory->Open(name, std::move(connection), nullptr /* request_context */,
origin, temp_directory.GetPath());
EXPECT_TRUE(callbacks->error_called());
@@ -273,8 +273,8 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) {
const int64_t transaction_id = 1;
std::unique_ptr<IndexedDBPendingConnection> connection(
base::MakeUnique<IndexedDBPendingConnection>(
- callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
- IndexedDBDatabaseMetadata::DEFAULT_VERSION));
+ callbacks, db_callbacks, 0 /* child_process_id */, url::Origin(),
+ transaction_id, IndexedDBDatabaseMetadata::DEFAULT_VERSION));
factory()->Open(ASCIIToUTF16("db"), std::move(connection),
nullptr /* request_context */, origin,
temp_directory.GetPath());
@@ -302,8 +302,8 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) {
const int64_t transaction_id = 1;
std::unique_ptr<IndexedDBPendingConnection> connection(
base::MakeUnique<IndexedDBPendingConnection>(
- callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
- IndexedDBDatabaseMetadata::DEFAULT_VERSION));
+ callbacks, db_callbacks, 0 /* child_process_id */, url::Origin(),
+ transaction_id, IndexedDBDatabaseMetadata::DEFAULT_VERSION));
factory()->Open(ASCIIToUTF16("db"), std::move(connection),
nullptr /* request_context */, origin,
temp_directory.GetPath());
@@ -390,8 +390,8 @@ TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) {
const int64_t transaction_id = 1;
std::unique_ptr<IndexedDBPendingConnection> connection(
base::MakeUnique<IndexedDBPendingConnection>(
- callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
- IndexedDBDatabaseMetadata::DEFAULT_VERSION));
+ callbacks, db_callbacks, 0 /* child_process_id */, url::Origin(),
+ transaction_id, IndexedDBDatabaseMetadata::DEFAULT_VERSION));
factory()->Open(ASCIIToUTF16("db"), std::move(connection),
nullptr /* request_context */, origin,
temp_directory.GetPath());
@@ -426,15 +426,21 @@ class UpgradeNeededCallbacks : public MockIndexedDBCallbacks {
void OnUpgradeNeeded(int64_t old_version,
std::unique_ptr<IndexedDBConnection> connection,
+ IndexedDBTransaction* transaction,
const content::IndexedDBDatabaseMetadata& metadata,
const IndexedDBDataLossInfo& data_loss_info) override {
+ transaction_ = transaction;
connection_ = std::move(connection);
}
+ IndexedDBTransaction* transaction() const { return transaction_; }
+
protected:
~UpgradeNeededCallbacks() override {}
private:
+ IndexedDBTransaction* transaction_ = nullptr;
+
DISALLOW_COPY_AND_ASSIGN(UpgradeNeededCallbacks);
};
@@ -468,12 +474,12 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) {
// Open at version 2, then close.
{
- scoped_refptr<MockIndexedDBCallbacks> callbacks(
+ scoped_refptr<UpgradeNeededCallbacks> callbacks(
new UpgradeNeededCallbacks());
std::unique_ptr<IndexedDBPendingConnection> connection(
base::MakeUnique<IndexedDBPendingConnection>(
- callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
- db_version));
+ callbacks, db_callbacks, 0 /* child_process_id */, url::Origin(),
+ transaction_id, db_version));
factory()->Open(db_name, std::move(connection),
nullptr /* request_context */, origin,
temp_directory.GetPath());
@@ -482,7 +488,8 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) {
// Pump the message loop so the upgrade transaction can run.
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(callbacks->connection());
- callbacks->connection()->database()->Commit(transaction_id);
+ EXPECT_NE(callbacks->transaction(), nullptr);
+ callbacks->connection()->database()->Commit(callbacks->transaction());
callbacks->connection()->Close();
EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name));
@@ -494,8 +501,8 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) {
scoped_refptr<ErrorCallbacks> callbacks(new ErrorCallbacks());
std::unique_ptr<IndexedDBPendingConnection> connection(
base::MakeUnique<IndexedDBPendingConnection>(
- callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
- db_version - 1));
+ callbacks, db_callbacks, 0 /* child_process_id */, url::Origin(),
+ transaction_id, db_version - 1));
factory()->Open(db_name, std::move(connection),
nullptr /* request_context */, origin,
temp_directory.GetPath());

Powered by Google App Engine
This is Rietveld 408576698