Commit 5abf54aa authored by Peter K. Lee's avatar Peter K. Lee Committed by Commit Bot

Allows TestChromeBrowserState to block during setup and destructor

Some EG tests use TestChromeBrowserState and they need blocking IO
in some scopes.

Bug: 1020027
Change-Id: I7766071a724967860cffe4139f00bd3f5bb2dcd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898539
Commit-Queue: Peter Lee <pkl@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712638}
parent aae0f8ea
......@@ -155,15 +155,28 @@ TestChromeBrowserState::TestChromeBrowserState(
}
TestChromeBrowserState::~TestChromeBrowserState() {
// Allows blocking in this scope for testing.
base::ScopedAllowBlockingForTesting allow_bocking;
// If this TestChromeBrowserState owns an incognito TestChromeBrowserState,
// tear it down first.
otr_browser_state_.reset();
BrowserStateDependencyManager::GetInstance()->DestroyBrowserStateServices(
this);
// The destructor of temp_dir_ will perform IO, so it needs to be deleted
// here while |allow_bocking| is still in scope. Keeps the same logic as
// ScopedTempDir::~ScopedTempDir().
if (temp_dir_.IsValid()) {
ignore_result(temp_dir_.Delete());
}
}
void TestChromeBrowserState::Init() {
// Allows blocking in this scope so directory manipulation can happen in this
// scope for testing.
base::ScopedAllowBlockingForTesting allow_bocking;
// If threads have been initialized, we should be on the UI thread.
DCHECK(!web::WebThread::IsThreadInitialized(web::WebThread::UI) ||
web::WebThread::CurrentlyOn(web::WebThread::UI));
......
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