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

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

Issue 2083203002: IndexedDB: Ensure transactions without requests commit in the same order (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | third_party/WebKit/LayoutTests/storage/indexeddb/empty-transaction-order.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/storage/indexeddb/empty-transaction-order.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698