Commit 952dcb20 authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

Fix temp dir leaks in tests that use TestBrowserContext.

This plugs 40 leaked directories in content_unittests.

BUG=546640

Change-Id: I0712ba333c15445476511f5313d7bdb0532c89c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1971735
Auto-Submit: Greg Thompson <grt@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726713}
parent 7c1cb615
...@@ -8,12 +8,10 @@ ...@@ -8,12 +8,10 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/test/null_task_runner.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/permission_controller_delegate.h" #include "content/public/browser/permission_controller_delegate.h"
#include "content/public/test/mock_resource_context.h" #include "content/public/test/mock_resource_context.h"
#include "content/public/test/test_utils.h"
#include "content/test/mock_background_sync_controller.h" #include "content/test/mock_background_sync_controller.h"
#include "content/test/mock_ssl_host_state_delegate.h" #include "content/test/mock_ssl_host_state_delegate.h"
#include "storage/browser/quota/special_storage_policy.h" #include "storage/browser/quota/special_storage_policy.h"
...@@ -45,12 +43,15 @@ TestBrowserContext::~TestBrowserContext() { ...@@ -45,12 +43,15 @@ TestBrowserContext::~TestBrowserContext() {
NotifyWillBeDestroyed(this); NotifyWillBeDestroyed(this);
ShutdownStoragePartitions(); ShutdownStoragePartitions();
// disk_cache::SimpleBackendImpl performs all disk IO on the ThreadPool // Various things that were just torn down above post tasks to other
// threads. The cache is initialized in the directory owned by // sequences that eventually bounce back to the main thread and out again.
// |browser_context_dir_| and so ScopedTempDir destructor may race with cache // Run all such tasks now before the instance is destroyed so that the
// IO (see https://crbug.com/910029 for example). Let all pending IO // |browser_context_dir_| can be fully cleaned up.
// operations finish before destroying |browser_context_dir_|. RunAllPendingInMessageLoop(BrowserThread::IO);
base::ThreadPoolInstance::Get()->FlushForTesting(); RunAllTasksUntilIdle();
EXPECT_TRUE(!browser_context_dir_.IsValid() || browser_context_dir_.Delete())
<< browser_context_dir_.GetPath();
} }
base::FilePath TestBrowserContext::TakePath() { base::FilePath TestBrowserContext::TakePath() {
......
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