Commit 27877777 authored by jsbell@chromium.org's avatar jsbell@chromium.org

IndexedDB: Don't timeout read-only transactions

Chrome introduced a transaction timeout to deal with potentially wedged
renderers (e.g. JS execution halted, etc) failing to complete transactions,
leaving the browser's transaction queue in a bad state. This was done
for all transactions, but since read-only transactions don't hold up
the queue it's safe to ignore them, which can reduce false-positives.

BUG=339229

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=254846

Review URL: https://codereview.chromium.org/180163010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255673 0039d316-1c4b-4281-b951-d872f2087c98
parent 1a290104
...@@ -318,11 +318,14 @@ void IndexedDBTransaction::ProcessTaskQueue() { ...@@ -318,11 +318,14 @@ void IndexedDBTransaction::ProcessTaskQueue() {
return; return;
// Otherwise, start a timer in case the front-end gets wedged and // Otherwise, start a timer in case the front-end gets wedged and
// never requests further activity. // never requests further activity. Read-only transactions don't
timeout_timer_.Start( // block other transactions, so don't time those out.
FROM_HERE, if (mode_ != indexed_db::TRANSACTION_READ_ONLY) {
base::TimeDelta::FromSeconds(kInactivityTimeoutPeriodSeconds), timeout_timer_.Start(
base::Bind(&IndexedDBTransaction::Timeout, this)); FROM_HERE,
base::TimeDelta::FromSeconds(kInactivityTimeoutPeriodSeconds),
base::Bind(&IndexedDBTransaction::Timeout, this));
}
} }
void IndexedDBTransaction::Timeout() { void IndexedDBTransaction::Timeout() {
......
...@@ -48,7 +48,7 @@ TEST_F(IndexedDBTransactionTest, Timeout) { ...@@ -48,7 +48,7 @@ TEST_F(IndexedDBTransactionTest, Timeout) {
id, id,
new MockIndexedDBDatabaseCallbacks(), new MockIndexedDBDatabaseCallbacks(),
scope, scope,
indexed_db::TRANSACTION_READ_ONLY, indexed_db::TRANSACTION_READ_WRITE,
db_, db_,
new IndexedDBFakeBackingStore::FakeTransaction(commit_success)); new IndexedDBFakeBackingStore::FakeTransaction(commit_success));
db_->TransactionCreated(transaction); db_->TransactionCreated(transaction);
...@@ -77,6 +77,38 @@ TEST_F(IndexedDBTransactionTest, Timeout) { ...@@ -77,6 +77,38 @@ TEST_F(IndexedDBTransactionTest, Timeout) {
EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); 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 { class AbortObserver {
public: public:
AbortObserver() : abort_task_called_(false) {} AbortObserver() : abort_task_called_(false) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment