Commit 86901a59 authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

Fix file handle leaks in BackgroundFetchDataManagerTest tests.

Tests using BackgroundFetchDataManagerTest::MatchCache inadvetantly held
files in the profile dir open beyond the lifetime of the test function,
inhibiting ScopedTempDir's ability to clean them up during
TestBrowserContext destruction. This change causes MatchCache to wait
until the main RunLoop goes idle, thereby allowing for residual tasks to
be posted and run upon destruction of the response given to
DidMatchCache.

BUG=546640,1016662

Change-Id: I4e2a989ec2b744b61b75e3ba2d09270c0eab3c70
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1882310Reviewed-by: default avatarRayan Kanso <rayankans@chromium.org>
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Auto-Submit: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709850}
parent ede9016a
...@@ -478,12 +478,16 @@ class BackgroundFetchDataManagerTest ...@@ -478,12 +478,16 @@ class BackgroundFetchDataManagerTest
origin(), CacheStorageOwner::kBackgroundFetch); origin(), CacheStorageOwner::kBackgroundFetch);
auto match_options = blink::mojom::CacheQueryOptions::New(); auto match_options = blink::mojom::CacheQueryOptions::New();
match_options->ignore_search = true; match_options->ignore_search = true;
// Note: QuitWhenIdleClosure is used rather than QuitClosure to allow
// destruction of the fetch response given to DidMatchCache to post a
// series of tasks that ultimately tear down the connection and allow
// resources to be freed (including an open file in the cache).
cache_storage.value()->MatchCache( cache_storage.value()->MatchCache(
kExampleUniqueId, BackgroundFetchSettledFetch::CloneRequest(request), kExampleUniqueId, BackgroundFetchSettledFetch::CloneRequest(request),
std::move(match_options), std::move(match_options),
/* trace_id= */ 0, /* trace_id= */ 0,
base::BindOnce(&BackgroundFetchDataManagerTest::DidMatchCache, base::BindOnce(&BackgroundFetchDataManagerTest::DidMatchCache,
base::Unretained(this), run_loop.QuitClosure(), base::Unretained(this), run_loop.QuitWhenIdleClosure(),
&result)); &result));
run_loop.Run(); run_loop.Run();
......
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