Commit 2eea27db authored by Alex Clarke's avatar Alex Clarke Committed by Commit Bot

Fix crash due to OnQueueNextWakeUpChanged firing after queue gone

This wasn't previously possible but the timing of the callback
was changed by patch
https://chromium-review.googlesource.com/c/chromium/src/+/1317629

Bug: 902277
Change-Id: I351872539b4ff2ebcb944a6ea76bd2021249f8ae
Reviewed-on: https://chromium-review.googlesource.com/c/1319613Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605703}
parent 95c5b287
......@@ -3064,6 +3064,20 @@ TEST_P(SequenceManagerTest, ProcessTasksWithTaskTimeObservers) {
UnsetOnTaskHandlers(runners_[0]);
}
TEST_P(SequenceManagerTest, ObserverNotFiredAfterTaskQueueDestructed) {
scoped_refptr<TestTaskQueue> main_tq = CreateTaskQueue();
MockTaskQueueObserver observer;
main_tq->SetObserver(&observer);
// We don't expect the observer to fire if the TaskQueue gets destructed.
EXPECT_CALL(observer, OnQueueNextWakeUpChanged(_, _)).Times(0);
main_tq->PostTask(FROM_HERE, BindOnce(&NopTask));
main_tq = nullptr;
test_task_runner_->FastForwardUntilNoTasksRemain();
}
TEST_P(SequenceManagerTest, GracefulShutdown) {
std::vector<TimeTicks> run_times;
scoped_refptr<TestTaskQueue> main_tq = CreateTaskQueue();
......
......@@ -49,6 +49,7 @@ TaskQueue::~TaskQueue() {
// If we've not been unregistered then this must occur on the main thread.
DCHECK_CALLED_ON_VALID_THREAD(associated_thread_->thread_checker);
impl_->SetOnNextWakeUpChangedCallback(RepeatingCallback<void(TimeTicks)>());
impl_->sequence_manager()->ShutdownTaskQueueGracefully(TakeTaskQueueImpl());
}
......
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