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

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: Review feedback 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..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.
« 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