| Index: content/browser/indexed_db/indexed_db_transaction_unittest.cc
|
| diff --git a/content/browser/indexed_db/indexed_db_transaction_unittest.cc b/content/browser/indexed_db/indexed_db_transaction_unittest.cc
|
| index bcd30a2e29f481c99a855ffbcd9d1379e4046c69..a647c5ccad892b38e6dc1ca0601849f67515d8d9 100644
|
| --- a/content/browser/indexed_db/indexed_db_transaction_unittest.cc
|
| +++ b/content/browser/indexed_db/indexed_db_transaction_unittest.cc
|
| @@ -5,6 +5,7 @@
|
| #include "content/browser/indexed_db/indexed_db_transaction.h"
|
|
|
| #include <stdint.h>
|
| +#include <memory>
|
|
|
| #include "base/bind.h"
|
| #include "base/logging.h"
|
| @@ -20,6 +21,7 @@
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace content {
|
| +const int kFakeProcessId = 10;
|
|
|
| class AbortObserver {
|
| public:
|
| @@ -67,6 +69,7 @@ class IndexedDBTransactionTest : public testing::Test {
|
| protected:
|
| scoped_refptr<IndexedDBFakeBackingStore> backing_store_;
|
| scoped_refptr<IndexedDBDatabase> db_;
|
| + url::Origin fake_connection_origin_;
|
|
|
| private:
|
| scoped_refptr<MockIndexedDBFactory> factory_;
|
| @@ -90,11 +93,12 @@ TEST_F(IndexedDBTransactionTest, Timeout) {
|
| const leveldb::Status commit_success = leveldb::Status::OK();
|
| std::unique_ptr<IndexedDBConnection> connection(
|
| base::MakeUnique<IndexedDBConnection>(
|
| - db_, new MockIndexedDBDatabaseCallbacks()));
|
| - scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction(
|
| - id, connection->GetWeakPtr(), scope,
|
| - blink::WebIDBTransactionModeReadWrite,
|
| - new IndexedDBFakeBackingStore::FakeTransaction(commit_success));
|
| + kFakeProcessId, fake_connection_origin_, db_,
|
| + new MockIndexedDBDatabaseCallbacks()));
|
| + std::unique_ptr<IndexedDBTransaction> transaction =
|
| + std::unique_ptr<IndexedDBTransaction>(new IndexedDBTransaction(
|
| + id, connection.get(), scope, blink::WebIDBTransactionModeReadWrite,
|
| + new IndexedDBFakeBackingStore::FakeTransaction(commit_success)));
|
| db_->TransactionCreated(transaction.get());
|
|
|
| // No conflicting transactions, so coordinator will start it immediately:
|
| @@ -134,10 +138,12 @@ TEST_F(IndexedDBTransactionTest, NoTimeoutReadOnly) {
|
| const leveldb::Status commit_success = leveldb::Status::OK();
|
| std::unique_ptr<IndexedDBConnection> connection(
|
| base::MakeUnique<IndexedDBConnection>(
|
| - db_, new MockIndexedDBDatabaseCallbacks()));
|
| - scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction(
|
| - id, connection->GetWeakPtr(), scope, blink::WebIDBTransactionModeReadOnly,
|
| - new IndexedDBFakeBackingStore::FakeTransaction(commit_success));
|
| + kFakeProcessId, fake_connection_origin_, db_,
|
| + new MockIndexedDBDatabaseCallbacks()));
|
| + std::unique_ptr<IndexedDBTransaction> transaction =
|
| + std::unique_ptr<IndexedDBTransaction>(new IndexedDBTransaction(
|
| + id, connection.get(), scope, blink::WebIDBTransactionModeReadOnly,
|
| + new IndexedDBFakeBackingStore::FakeTransaction(commit_success)));
|
| db_->TransactionCreated(transaction.get());
|
|
|
| // No conflicting transactions, so coordinator will start it immediately:
|
| @@ -165,10 +171,12 @@ TEST_P(IndexedDBTransactionTestMode, ScheduleNormalTask) {
|
| const leveldb::Status commit_success = leveldb::Status::OK();
|
| std::unique_ptr<IndexedDBConnection> connection(
|
| base::MakeUnique<IndexedDBConnection>(
|
| - db_, new MockIndexedDBDatabaseCallbacks()));
|
| - scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction(
|
| - id, connection->GetWeakPtr(), scope, GetParam(),
|
| - new IndexedDBFakeBackingStore::FakeTransaction(commit_success));
|
| + kFakeProcessId, fake_connection_origin_, db_,
|
| + new MockIndexedDBDatabaseCallbacks()));
|
| + std::unique_ptr<IndexedDBTransaction> transaction =
|
| + std::unique_ptr<IndexedDBTransaction>(new IndexedDBTransaction(
|
| + id, connection.get(), scope, GetParam(),
|
| + new IndexedDBFakeBackingStore::FakeTransaction(commit_success)));
|
|
|
| EXPECT_FALSE(transaction->HasPendingTasks());
|
| EXPECT_TRUE(transaction->IsTaskQueueEmpty());
|
| @@ -226,11 +234,13 @@ TEST_F(IndexedDBTransactionTest, SchedulePreemptiveTask) {
|
| const leveldb::Status commit_failure = leveldb::Status::Corruption("Ouch.");
|
| std::unique_ptr<IndexedDBConnection> connection(
|
| base::MakeUnique<IndexedDBConnection>(
|
| - db_, new MockIndexedDBDatabaseCallbacks()));
|
| - scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction(
|
| - id, connection->GetWeakPtr(), scope,
|
| - blink::WebIDBTransactionModeVersionChange,
|
| - new IndexedDBFakeBackingStore::FakeTransaction(commit_failure));
|
| + kFakeProcessId, fake_connection_origin_, db_,
|
| + new MockIndexedDBDatabaseCallbacks()));
|
| + std::unique_ptr<IndexedDBTransaction> transaction =
|
| + std::unique_ptr<IndexedDBTransaction>(new IndexedDBTransaction(
|
| + id, connection.get(), scope,
|
| + blink::WebIDBTransactionModeVersionChange,
|
| + new IndexedDBFakeBackingStore::FakeTransaction(commit_failure)));
|
|
|
| EXPECT_FALSE(transaction->HasPendingTasks());
|
| EXPECT_TRUE(transaction->IsTaskQueueEmpty());
|
| @@ -287,10 +297,12 @@ TEST_P(IndexedDBTransactionTestMode, AbortTasks) {
|
| const leveldb::Status commit_failure = leveldb::Status::Corruption("Ouch.");
|
| std::unique_ptr<IndexedDBConnection> connection(
|
| base::MakeUnique<IndexedDBConnection>(
|
| - db_, new MockIndexedDBDatabaseCallbacks()));
|
| - scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction(
|
| - id, connection->GetWeakPtr(), scope, GetParam(),
|
| - new IndexedDBFakeBackingStore::FakeTransaction(commit_failure));
|
| + kFakeProcessId, fake_connection_origin_, db_,
|
| + new MockIndexedDBDatabaseCallbacks()));
|
| + std::unique_ptr<IndexedDBTransaction> transaction =
|
| + std::unique_ptr<IndexedDBTransaction>(new IndexedDBTransaction(
|
| + id, connection.get(), scope, GetParam(),
|
| + new IndexedDBFakeBackingStore::FakeTransaction(commit_failure)));
|
| db_->TransactionCreated(transaction.get());
|
|
|
| AbortObserver observer;
|
| @@ -316,10 +328,12 @@ TEST_P(IndexedDBTransactionTestMode, AbortPreemptive) {
|
| const leveldb::Status commit_success = leveldb::Status::OK();
|
| std::unique_ptr<IndexedDBConnection> connection(
|
| base::MakeUnique<IndexedDBConnection>(
|
| - db_, new MockIndexedDBDatabaseCallbacks()));
|
| - scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction(
|
| - id, connection->GetWeakPtr(), scope, GetParam(),
|
| - new IndexedDBFakeBackingStore::FakeTransaction(commit_success));
|
| + kFakeProcessId, fake_connection_origin_, db_,
|
| + new MockIndexedDBDatabaseCallbacks()));
|
| + std::unique_ptr<IndexedDBTransaction> transaction =
|
| + std::unique_ptr<IndexedDBTransaction>(new IndexedDBTransaction(
|
| + id, connection.get(), scope, GetParam(),
|
| + new IndexedDBFakeBackingStore::FakeTransaction(commit_success)));
|
| db_->TransactionCreated(transaction.get());
|
|
|
| // No conflicting transactions, so coordinator will start it immediately:
|
| @@ -366,12 +380,14 @@ TEST_F(IndexedDBTransactionTest, IndexedDBObserver) {
|
| const leveldb::Status commit_success = leveldb::Status::OK();
|
| std::unique_ptr<IndexedDBConnection> connection(
|
| base::MakeUnique<IndexedDBConnection>(
|
| - db_, new MockIndexedDBDatabaseCallbacks()));
|
| - scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction(
|
| - id, connection->GetWeakPtr(), scope,
|
| - blink::WebIDBTransactionModeReadWrite,
|
| - new IndexedDBFakeBackingStore::FakeTransaction(commit_success));
|
| - db_->TransactionCreated(transaction.get());
|
| + kFakeProcessId, fake_connection_origin_, db_,
|
| + new MockIndexedDBDatabaseCallbacks()));
|
| +
|
| + IndexedDBTransaction* transaction = connection->StoreTransactionForTesting(
|
| + std::unique_ptr<IndexedDBTransaction>(new IndexedDBTransaction(
|
| + id, connection.get(), scope, blink::WebIDBTransactionModeReadWrite,
|
| + new IndexedDBFakeBackingStore::FakeTransaction(commit_success))));
|
| + db_->TransactionCreated(transaction);
|
|
|
| EXPECT_EQ(0UL, transaction->pending_observers_.size());
|
| EXPECT_EQ(0UL, connection->active_observers().size());
|
|
|