Commit e5e945ed authored by Nicolas Ouellet-Payeur's avatar Nicolas Ouellet-Payeur Committed by Commit Bot

[Sync] Destroy leveldb::DB on a file thread

Previously, the LevelDB object was destroyed on the UI thread, but it
in reality its destructor can do file IO. This wasn't causing problems,
because the object is deleted late during teardown (after the UI
thread gets a ScopedAllowBlocking).

With this patch, delete the LevelDB object on a ThreadPool thread, so
this fact is made more explicit and won't cause problems if we change
profile teardown order.

Bug: 1134321, 88586
Change-Id: I81ede6325b616eb7baecb532379034f0efeea7e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443710Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Auto-Submit: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814189}
parent dd47c538
......@@ -51,7 +51,9 @@ ModelTypeStoreBackend::CreateUninitialized() {
return new ModelTypeStoreBackend(/*env=*/nullptr);
}
ModelTypeStoreBackend::~ModelTypeStoreBackend() {}
ModelTypeStoreBackend::~ModelTypeStoreBackend() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
base::Optional<ModelError> ModelTypeStoreBackend::Init(
const base::FilePath& path) {
......
......@@ -116,6 +116,7 @@ ModelTypeStoreServiceImpl::ModelTypeStoreServiceImpl(
ModelTypeStoreServiceImpl::~ModelTypeStoreServiceImpl() {
DCHECK_CALLED_ON_VALID_SEQUENCE(ui_sequence_checker_);
backend_task_runner_->ReleaseSoon(FROM_HERE, std::move(store_backend_));
}
const base::FilePath& ModelTypeStoreServiceImpl::GetSyncDataPath() const {
......
......@@ -45,7 +45,7 @@ class ModelTypeStoreServiceImpl : public ModelTypeStoreService {
const scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
// Constructed in the UI thread, used and destroyed in |backend_task_runner_|.
const scoped_refptr<ModelTypeStoreBackend> store_backend_;
scoped_refptr<ModelTypeStoreBackend> store_backend_;
SEQUENCE_CHECKER(ui_sequence_checker_);
......
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