Commit c93f15a9 authored by Wez's avatar Wez Committed by Commit Bot

[content] Clean up quit of main message loop in //content Shell.

Layout tests were migrated off RunLoop::QuitCurrentWhenIdleDeprecated()
to an explicit Shell::QuitMainMessageLoopForTesting() API by
https://chromium-review.googlesource.com/c/chromium/src/+/1106814

This changed the BlinkTestController's quit-main-message-loop semantics
such that multiple requests to quit the loop are now fatal, where
previously the second and subsequent requests would be silently
ignored, but left the potential for bugs due to async tasks quitting the
"current" loop rather than the one intended by the controller.

Fix the Shell API such that BlinkTestController quits the loop directly
rather than posting a quit task, and fix QuitMainMessageLoopForTesting()
to support being called multiple times.

Bug: 851416, 1051782
Change-Id: I3a9d3f78be2a22ceeef04611dc3a0cf0a25ee34c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071860Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Peter Beverloo <peter@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744392}
parent c41cf6ad
...@@ -192,8 +192,8 @@ void Shell::SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure) { ...@@ -192,8 +192,8 @@ void Shell::SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure) {
} }
void Shell::QuitMainMessageLoopForTesting() { void Shell::QuitMainMessageLoopForTesting() {
DCHECK(*g_quit_main_message_loop); if (*g_quit_main_message_loop)
std::move(*g_quit_main_message_loop).Run(); std::move(*g_quit_main_message_loop).Run();
} }
void Shell::SetShellCreatedCallback( void Shell::SetShellCreatedCallback(
......
...@@ -118,8 +118,7 @@ class Shell : public WebContentsDelegate, ...@@ -118,8 +118,7 @@ class Shell : public WebContentsDelegate,
static void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure); static void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure);
// Used by the BlinkTestController to stop the message loop before closing all // Used by the BlinkTestController to stop the message loop before closing all
// windows, for specific tests. Fails if called after the message loop has // windows, for specific tests. Has no effect if the loop is already quitting.
// already been signalled to quit.
static void QuitMainMessageLoopForTesting(); static void QuitMainMessageLoopForTesting();
// Used for content_browsertests. Called once. // Used for content_browsertests. Called once.
......
...@@ -1429,15 +1429,13 @@ void BlinkTestController::OnResetDone() { ...@@ -1429,15 +1429,13 @@ void BlinkTestController::OnResetDone() {
return; return;
} }
base::ThreadTaskRunnerHandle::Get()->PostTask( Shell::QuitMainMessageLoopForTesting();
FROM_HERE, base::BindOnce(&Shell::QuitMainMessageLoopForTesting));
} }
void BlinkTestController::OnLeakDetectionDone( void BlinkTestController::OnLeakDetectionDone(
const LeakDetector::LeakDetectionReport& report) { const LeakDetector::LeakDetectionReport& report) {
if (!report.leaked) { if (!report.leaked) {
base::ThreadTaskRunnerHandle::Get()->PostTask( Shell::QuitMainMessageLoopForTesting();
FROM_HERE, base::BindOnce(&Shell::QuitMainMessageLoopForTesting));
return; return;
} }
......
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