https://crrev.com/c/2628489 assumed that DatabaseTracker::Shutdown() is
always called before the DatabaseTracker destructor, and introduced a
DCHECK that fires when the assumption is not met.
The DCHECK made some tests flaky, highlighting the fact that the
assumption was not met occasionally. This was because the
StoragePartitionImpl queues a call to DatabaseTracker::Shutdown() by
PostTask()ing on DatabaseTracker's task sequence, which is used to
perform database I/O. The database sequence was using the
SKIP_ON_SHUTDOWN base::TaskShutdownBehavior, so the Shutdown() task was
occasionally cleared without being run.
This CL fixes the issue by making DatabaseTracker's task sequence
BLOCK_SHUTDOWN. This fix introduces the disadvantage that browser
shutdown will wait for WebSQL database I/O to complete. However, this
matches the behavior in some other storage APIs. See
IndexedDBContextImpl, AppCacheServiceImpl, QuotaManagerImpl.
Bug: 1220191
Change-Id: I58d34a273bd6d9c7a8c34317cc77ebaad1b16d2b
Tested: ./out/Release/interactive_ui_tests --gtest_break_on_failure --gtest_repeat=100 --gtest_filter=AllGuestProfileTypes/GuestToolbarViewTest.ExtensionsToolbarContainerForGuest/1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2974245
Reviewed-by: enne <enne@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#894401}