Fix a scoped temp dir leak in ImportantSitesUsageCounterTest
The SQL DB owned by the QuotaManager gets destroyed asynchronously, so
given the current ordering of the parameters:
base::ScopedTempDir temp_dir_;
scoped_refptr<QuotaManager> quota_manager_;
The release of |quota_manager_| will post a task to close the database
stored in temp_dir_ but this is racy with the destruction of
|temp_dir_|.
Bug: 974310
Change-Id: Ib54ea1fe1652028a1bcf6b7f6107a01d3e99f2d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1660833
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Reviewed-by: Ben Wells <benwells@chromium.org>
Auto-Submit: Sébastien Marchand <sebmarchand@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672215}
diff --git a/chrome/browser/engagement/important_sites_usage_counter_unittest.cc b/chrome/browser/engagement/important_sites_usage_counter_unittest.cc
index 1e386c0..7294ff6 100644
--- a/chrome/browser/engagement/important_sites_usage_counter_unittest.cc
+++ b/chrome/browser/engagement/important_sites_usage_counter_unittest.cc
@@ -34,7 +34,11 @@
run_loop_.reset(new base::RunLoop());
}
- void TearDown() override { content::RunAllTasksUntilIdle(); }
+ void TearDown() override {
+ // Release the quota manager and wait for the database to be closed.
+ quota_manager_.reset();
+ content::RunAllTasksUntilIdle();
+ }
TestingProfile* profile() { return &profile_; }