Commit 53cb0fcd authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

Make sure all callbacks are executed in ServiceWorkerBrowserTest

This CL attempts to fix flakiness of some service worker browsertests.

Before this CL, we destroyed ServiceWorkerContextWrapper in
TearDownOnMainThread() without waiting for all callbacks are executed.
This caused DCHECK hit in mojo callbacks of
ServiceWorkerStorageControl because destroying the wrapper also
destroys a mojo connection to ServiceWorkerStorageControl. Mojo
callbacks need to be executed before the corresponding remote is
destroyed.

Bug: 1137529
Change-Id: I3060d5ba687e8164c6f29f1e24395ce09c26abfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2467037Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816429}
parent ccde9c9f
...@@ -348,8 +348,10 @@ class ServiceWorkerBrowserTest : public ContentBrowserTest { ...@@ -348,8 +348,10 @@ class ServiceWorkerBrowserTest : public ContentBrowserTest {
} }
void TearDownOnMainThread() override { void TearDownOnMainThread() override {
RunOnCoreThread( base::RunLoop loop;
base::BindOnce(&self::TearDownOnCoreThread, base::Unretained(this))); RunOnCoreThread(base::BindOnce(&self::TearDownOnCoreThread,
base::Unretained(this), loop.QuitClosure()));
loop.Run();
wrapper_ = nullptr; wrapper_ = nullptr;
} }
...@@ -368,7 +370,16 @@ class ServiceWorkerBrowserTest : public ContentBrowserTest { ...@@ -368,7 +370,16 @@ class ServiceWorkerBrowserTest : public ContentBrowserTest {
} }
virtual void SetUpOnCoreThread() {} virtual void SetUpOnCoreThread() {}
virtual void TearDownOnCoreThread() {}
virtual void TearDownOnCoreThread(base::OnceClosure callback) {
// Flush remote storage control so that all pending callbacks are executed.
wrapper()
->context()
->registry()
->GetRemoteStorageControl()
.FlushForTesting();
std::move(callback).Run();
}
ServiceWorkerContextWrapper* wrapper() { return wrapper_.get(); } ServiceWorkerContextWrapper* wrapper() { return wrapper_.get(); }
ServiceWorkerContext* public_context() { return wrapper(); } ServiceWorkerContext* public_context() { return wrapper(); }
......
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