Commit 23303e6f authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

IndexedDB: Unregister cursors from transactions more consistently.

IndexedDBCursor now calls IndexedDBTransaction::UnregisterOpenCursor()
in Close(), which is called by the destructor.

The previous setup missed an edge case where calling
IndexedDBCursor::Close() directly would not unregister the cursor. This
behavior was relied upon in IndexedDBTransaction::CloseOpenCursors(),
but was not intended at other callsites.

Bug: 1005753
Change-Id: I91944138d05faa2d91ecc03b1040ec16ca1a7e5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1821675Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699937}
parent 166ca3b2
......@@ -62,8 +62,6 @@ IndexedDBCursor::IndexedDBCursor(
}
IndexedDBCursor::~IndexedDBCursor() {
if (transaction_)
transaction_->UnregisterOpenCursor(this);
// Call to make sure we complete our lifetime trace.
Close();
}
......@@ -405,6 +403,8 @@ void IndexedDBCursor::Close() {
closed_ = true;
cursor_.reset();
saved_cursor_.reset();
if (transaction_)
transaction_->UnregisterOpenCursor(this);
transaction_.reset();
}
......
......@@ -540,9 +540,13 @@ void IndexedDBTransaction::CloseOpenCursorBindings() {
void IndexedDBTransaction::CloseOpenCursors() {
IDB_TRACE1("IndexedDBTransaction::CloseOpenCursors", "txn.id", id());
for (auto* cursor : open_cursors_)
cursor->Close();
// IndexedDBCursor::Close() indirectly mutates |open_cursors_|, when it calls
// IndexedDBTransaction::UnregisterOpenCursor().
std::set<IndexedDBCursor*> open_cursors = std::move(open_cursors_);
open_cursors_.clear();
for (auto* cursor : open_cursors)
cursor->Close();
}
void IndexedDBTransaction::AddPendingObserver(
......
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