| Index: content/browser/indexed_db/indexed_db_transaction.cc
|
| diff --git a/content/browser/indexed_db/indexed_db_transaction.cc b/content/browser/indexed_db/indexed_db_transaction.cc
|
| index a7f17b6178c24bf5c0675393ed399c392177d648..768cf1dc2f8a96929a372b0659c6a882821619f5 100644
|
| --- a/content/browser/indexed_db/indexed_db_transaction.cc
|
| +++ b/content/browser/indexed_db/indexed_db_transaction.cc
|
| @@ -21,8 +21,19 @@
|
|
|
| namespace content {
|
|
|
| +namespace {
|
| +
|
| const int64_t kInactivityTimeoutPeriodSeconds = 60;
|
|
|
| +// Helper for posting a task to call IndexedDBTransaction::Commit when we know
|
| +// the transaction had no requests and therefore the commit must succeed.
|
| +void CommitUnused(scoped_refptr<IndexedDBTransaction> transaction) {
|
| + leveldb::Status status = transaction->Commit();
|
| + DCHECK(status.ok());
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| IndexedDBTransaction::TaskQueue::TaskQueue() {}
|
| IndexedDBTransaction::TaskQueue::~TaskQueue() { clear(); }
|
|
|
| @@ -204,8 +215,16 @@ void IndexedDBTransaction::Start() {
|
| state_ = STARTED;
|
| diagnostics_.start_time = base::Time::Now();
|
|
|
| - if (!used_)
|
| + if (!used_) {
|
| + if (commit_pending_) {
|
| + // The transaction has never had requests issued against it, but the
|
| + // front-end previously requested a commit; do the commit now, but not
|
| + // re-entrantly as that may renter the coordinator.
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE, base::Bind(&CommitUnused, make_scoped_refptr(this)));
|
| + }
|
| return;
|
| + }
|
|
|
| RunTasksIfStarted();
|
| }
|
| @@ -253,6 +272,12 @@ leveldb::Status IndexedDBTransaction::Commit() {
|
| DCHECK(!used_ || state_ == STARTED);
|
| commit_pending_ = true;
|
|
|
| + // Front-end has requested a commit, but this transaction is blocked by
|
| + // other transactions. The commit will be initiated when the transaction
|
| + // coordinator unblocks this transaction.
|
| + if (state_ != STARTED)
|
| + return leveldb::Status::OK();
|
| +
|
| // Front-end has requested a commit, but there may be tasks like
|
| // create_index which are considered synchronous by the front-end
|
| // but are processed asynchronously.
|
|
|