Chromium Code Reviews| 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..4aad02aa01acb3973f313e015361bf00ee7620fe 100644 |
| --- a/content/browser/indexed_db/indexed_db_transaction.cc |
| +++ b/content/browser/indexed_db/indexed_db_transaction.cc |
| @@ -198,14 +198,29 @@ void IndexedDBTransaction::UnregisterOpenCursor(IndexedDBCursor* cursor) { |
| open_cursors_.erase(cursor); |
| } |
| +namespace { |
| +void CommitUnused(scoped_refptr<IndexedDBTransaction> transaction) { |
|
cmumford
2016/06/22 16:53:37
Do you want an anonymous namespace inside of the "
jsbell
2016/06/22 18:53:04
Yeah, we mostly put anon/helpers at the top, so mo
|
| + leveldb::Status status = transaction->Commit(); |
| + DCHECK(status.ok()); |
| +} |
| +} // namespace |
| + |
| void IndexedDBTransaction::Start() { |
| // TransactionCoordinator has started this transaction. |
| DCHECK_EQ(CREATED, state_); |
| 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 requested a commit initiate the commit |
|
cmumford
2016/06/22 16:53:37
Nit: oddly worded "commit initiate the commit".
jsbell
2016/06/22 18:53:04
Fixed, thx.
|
| + // 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 +268,9 @@ leveldb::Status IndexedDBTransaction::Commit() { |
| DCHECK(!used_ || state_ == STARTED); |
| commit_pending_ = true; |
| + if (state_ != STARTED) |
|
cmumford
2016/06/22 16:53:37
Nit: Possibly worthy of a short comment - your cal
jsbell
2016/06/22 18:53:04
Done.
|
| + 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. |