Commit fc7067fe authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Ensure MessagePumpForUI doesn't run tasks after being aborted.

The previous behaviour of MessagePumpForUI::Abort was to prevent
delayed tasks from running, but non-delayed tasks would continue to run.
This was almost certainly not intentional, and an aborted pump probably
shouldn't be running any tasks at all.

Bug: 780100
Change-Id: I56ad5b0b5d0621450fc62a35c4d927f4975ae6a4
Reviewed-on: https://chromium-review.googlesource.com/748979Reviewed-by: default avatardanakj <danakj@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513303}
parent b8183fe5
...@@ -264,6 +264,10 @@ void AbortMessagePump() { ...@@ -264,6 +264,10 @@ void AbortMessagePump() {
static_cast<base::MessageLoopForUI*>(base::MessageLoop::current())->Abort(); static_cast<base::MessageLoopForUI*>(base::MessageLoop::current())->Abort();
} }
void DoNotRun() {
ASSERT_TRUE(false);
}
void RunTest_AbortDontRunMoreTasks(bool delayed, bool init_java_first) { void RunTest_AbortDontRunMoreTasks(bool delayed, bool init_java_first) {
WaitableEvent test_done_event(WaitableEvent::ResetPolicy::MANUAL, WaitableEvent test_done_event(WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED); WaitableEvent::InitialState::NOT_SIGNALED);
...@@ -286,6 +290,8 @@ void RunTest_AbortDontRunMoreTasks(bool delayed, bool init_java_first) { ...@@ -286,6 +290,8 @@ void RunTest_AbortDontRunMoreTasks(bool delayed, bool init_java_first) {
} else { } else {
java_thread->message_loop()->task_runner()->PostTask( java_thread->message_loop()->task_runner()->PostTask(
FROM_HERE, BindOnce(&AbortMessagePump)); FROM_HERE, BindOnce(&AbortMessagePump));
java_thread->message_loop()->task_runner()->PostTask(FROM_HERE,
BindOnce(&DoNotRun));
} }
// Wait to ensure we catch the correct exception (and don't crash) // Wait to ensure we catch the correct exception (and don't crash)
......
...@@ -35,6 +35,11 @@ static void DoRunLoopOnce(JNIEnv* env, ...@@ -35,6 +35,11 @@ static void DoRunLoopOnce(JNIEnv* env,
base::MessagePumpForUI* pump = base::MessagePumpForUI* pump =
reinterpret_cast<base::MessagePumpForUI*>(native_message_pump); reinterpret_cast<base::MessagePumpForUI*>(native_message_pump);
DCHECK(pump); DCHECK(pump);
// If the pump has been aborted, tasks may continue to be queued up, but
// shouldn't run.
if (pump->ShouldAbort())
return;
// This is based on MessagePumpForUI::DoRunLoop() from desktop. // This is based on MessagePumpForUI::DoRunLoop() from desktop.
// Note however that our system queue is handled in the java side. // Note however that our system queue is handled in the java side.
// In desktop we inspect and process a single system message and then // In desktop we inspect and process a single system message and then
......
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