IndexedDB: Invoke IDBCursor callbacks on destruct

Mojo requires that callbacks be called or bindings they're associated
with be torn down before the connection is terminated.  Previously, the
IDBCursor binding was explicitly closed to ensure the callback state
correct when the connection was terminated.

However, there are cases when the callback is destructed before the
cursor bindings can be closed, like when a task holding a callback
is on the preemptive queue.  This change wraps all cursor callbacks in
a destruct invoke wrapper to handle those cases cleanly.

In-depth:
- the IndexedDBTransaction task queue has tasks that expect to be called
  in the future
- each task contains its args and some of those can be Mojo callbacks
- Mojo callbacks require being called or the binding they're on to be
  closed before they're destroyed
- the CursorImpl bindings can't always be closed when a transaction task
  queue is cleared before the preemptive queue is cleared
- some layout tests would trigger this failure in a flaky way by sometimes
  having CursorContinue callbacks in the transaction task queue when the
  IDB session is aborted
- wrap all cursor callbacks in a special CallbackAbortOnDestruct class
  that calls the callback on destruct if it hasn't yet been called to
  ensure by the time the Mojo connection is torn down no callbacks exist

Bug: 965090
Change-Id: Ib3a066536c5c481bbf4fe6ceee462512465755d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1618261
Commit-Queue: Chase Phillips <cmp@chromium.org>
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662374}
5 files changed