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

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

Issue 180163010: IndexedDB: Don't timeout read-only transactions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Abort the transaction to avoid leaks Created 6 years, 9 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
« no previous file with comments | « content/browser/indexed_db/indexed_db_transaction.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d0228bcd9a14f2e3737e57543270058f8084baae..f9f4add8e2878ff6c746cf58b38a5a51438d6b55 100644
--- a/content/browser/indexed_db/indexed_db_transaction_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_transaction_unittest.cc
@@ -48,7 +48,7 @@ TEST_F(IndexedDBTransactionTest, Timeout) {
id,
new MockIndexedDBDatabaseCallbacks(),
scope,
- indexed_db::TRANSACTION_READ_ONLY,
+ indexed_db::TRANSACTION_READ_WRITE,
db_,
new IndexedDBFakeBackingStore::FakeTransaction(commit_success));
db_->TransactionCreated(transaction);
@@ -77,6 +77,38 @@ TEST_F(IndexedDBTransactionTest, Timeout) {
EXPECT_FALSE(transaction->IsTimeoutTimerRunning());
}
+TEST_F(IndexedDBTransactionTest, NoTimeoutReadOnly) {
+ const int64 id = 0;
+ const std::set<int64> scope;
+ const bool commit_success = true;
+ scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction(
+ id,
+ new MockIndexedDBDatabaseCallbacks(),
+ scope,
+ indexed_db::TRANSACTION_READ_ONLY,
+ db_,
+ new IndexedDBFakeBackingStore::FakeTransaction(commit_success));
+ db_->TransactionCreated(transaction);
+
+ // No conflicting transactions, so coordinator will start it immediately:
+ EXPECT_EQ(IndexedDBTransaction::STARTED, transaction->state());
+ EXPECT_FALSE(transaction->IsTimeoutTimerRunning());
+
+ // Schedule a task - timer won't be started until it's processed.
+ transaction->ScheduleTask(base::Bind(
+ &IndexedDBTransactionTest::DummyOperation, base::Unretained(this)));
+ EXPECT_FALSE(transaction->IsTimeoutTimerRunning());
+
+ // Transaction is read-only, so no need to time it out.
+ RunPostedTasks();
+ EXPECT_FALSE(transaction->IsTimeoutTimerRunning());
+
+ // Clean up to avoid leaks.
+ transaction->Abort();
+ EXPECT_EQ(IndexedDBTransaction::FINISHED, transaction->state());
+ EXPECT_FALSE(transaction->IsTimeoutTimerRunning());
+}
+
class AbortObserver {
public:
AbortObserver() : abort_task_called_(false) {}
« no previous file with comments | « content/browser/indexed_db/indexed_db_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698