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

Fix ~GCMStoreImpl() performing IO on the UI thread

This is needed to enable DestroyProfileOnBrowserClose by default in
automated tests (crrev.com/c/2503629).

GCMStoreImpl::Backend owns an sql::Database object, which may perform
IO when destroyed. Release it on the blocking task runner, so it
doesn't cause issues when the DestroyProfileOnBrowserClose flag is on.

Bug: 88586
Change-Id: I657ae488c6a55c1608bf45466ea6a3bc0153786f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2511250
Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826278}
parent a8b46244
......@@ -464,6 +464,9 @@ void GCMClientImplTest::SetUp() {
}
void GCMClientImplTest::TearDown() {
gcm_client_.reset();
PumpLoopUntilIdle();
testing::Test::TearDown();
}
void GCMClientImplTest::SetFeatureParams(const base::Feature& feature,
......
......@@ -1203,7 +1203,11 @@ GCMStoreImpl::GCMStoreImpl(
std::move(encryptor))),
blocking_task_runner_(blocking_task_runner) {}
GCMStoreImpl::~GCMStoreImpl() {}
GCMStoreImpl::~GCMStoreImpl() {
// |backend_| owns an sql::Database object, which may perform IO when
// |destroyed.
blocking_task_runner_->ReleaseSoon(FROM_HERE, std::move(backend_));
}
void GCMStoreImpl::Load(StoreOpenMode open_mode, LoadCallback callback) {
blocking_task_runner_->PostTask(
......
......@@ -51,6 +51,8 @@ class GCMStoreImplTest : public testing::Test {
GCMStoreImplTest();
~GCMStoreImplTest() override;
void TearDown() override;
std::unique_ptr<GCMStoreImpl> BuildGCMStore();
void LoadGCMStore(GCMStoreImpl* gcm_store,
std::unique_ptr<GCMStore::LoadResult>* result_dst);
......@@ -85,6 +87,10 @@ GCMStoreImplTest::GCMStoreImplTest()
GCMStoreImplTest::~GCMStoreImplTest() {}
void GCMStoreImplTest::TearDown() {
PumpLoop();
}
std::unique_ptr<GCMStoreImpl> GCMStoreImplTest::BuildGCMStore() {
// Pass an non-existent directory as store path to match the exact behavior in
// the production code. Currently GCMStoreImpl checks if the directory exists
......
......@@ -130,6 +130,7 @@ class MCSClientTest : public testing::Test {
~MCSClientTest() override;
void SetUp() override;
void TearDown() override;
void BuildMCSClient();
void InitializeClient();
......@@ -173,7 +174,7 @@ class MCSClientTest : public testing::Test {
base::SimpleTestClock clock_;
base::ScopedTempDir temp_directory_;
base::test::SingleThreadTaskEnvironment task_environment_;
base::test::TaskEnvironment task_environment_;
std::unique_ptr<base::RunLoop> run_loop_;
std::unique_ptr<GCMStore> gcm_store_;
......@@ -208,6 +209,12 @@ void MCSClientTest::SetUp() {
testing::Test::SetUp();
}
void MCSClientTest::TearDown() {
gcm_store_.reset();
task_environment_.RunUntilIdle();
testing::Test::TearDown();
}
void MCSClientTest::BuildMCSClient() {
gcm_store_.reset(
new GCMStoreImpl(temp_directory_.GetPath(),
......
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