Commit f1f7ebbb authored by Carlos Caballero's avatar Carlos Caballero Committed by Commit Bot

Remove MessageLoop references in /third_party/blink/renderer/platform/scheduler

MessageLoop is going away soon.

This CL was uploaded by git cl split.

R=rmcilroy@chromium.org

Bug: 891670
Change-Id: I123507e4d4145ab7717729ddb122c6eb990f1827
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1944669
Auto-Submit: Carlos Caballero <carlscab@google.com>
Reviewed-by: default avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720428}
parent 3192469f
......@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/task/sequence_manager/sequence_manager.h"
......@@ -450,72 +449,6 @@ TEST_F(IdleHelperTestWithIdlePeriodObserver, TestEnterAndExitIdlePeriod) {
idle_helper_->EndIdlePeriod();
}
class IdleHelperWithMessageLoopTest : public BaseIdleHelperTest {
public:
IdleHelperWithMessageLoopTest()
: BaseIdleHelperTest(std::make_unique<base::MessageLoop>(),
base::TimeDelta()) {}
~IdleHelperWithMessageLoopTest() override = default;
void PostFromNestedRunloop(
Vector<std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>>* tasks) {
for (std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>& pair : *tasks) {
if (pair.second) {
idle_task_runner_->PostIdleTask(FROM_HERE, std::move(pair.first));
} else {
idle_task_runner_->PostNonNestableIdleTask(FROM_HERE,
std::move(pair.first));
}
}
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::kInShortIdlePeriod,
test_task_runner_->NowTicks(),
test_task_runner_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
base::RunLoop(base::RunLoop::Type::kNestableTasksAllowed).RunUntilIdle();
}
void SetUp() override {
EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(AnyNumber());
EXPECT_CALL(*idle_helper_, OnIdlePeriodEnded()).Times(AnyNumber());
EXPECT_CALL(*idle_helper_, OnPendingTasksChanged(_)).Times(AnyNumber());
}
private:
DISALLOW_COPY_AND_ASSIGN(IdleHelperWithMessageLoopTest);
};
TEST_F(IdleHelperWithMessageLoopTest,
NonNestableIdleTaskDoesntExecuteInNestedLoop) {
Vector<String> order;
idle_task_runner_->PostIdleTask(
FROM_HERE, base::BindOnce(&AppendToVectorIdleTestTask, &order, "1"));
idle_task_runner_->PostIdleTask(
FROM_HERE, base::BindOnce(&AppendToVectorIdleTestTask, &order, "2"));
Vector<std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>>
tasks_to_post_from_nested_loop;
tasks_to_post_from_nested_loop.push_back(std::make_pair(
base::BindOnce(&AppendToVectorIdleTestTask, &order, "3"), false));
tasks_to_post_from_nested_loop.push_back(std::make_pair(
base::BindOnce(&AppendToVectorIdleTestTask, &order, "4"), true));
tasks_to_post_from_nested_loop.push_back(std::make_pair(
base::BindOnce(&AppendToVectorIdleTestTask, &order, "5"), true));
default_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&IdleHelperWithMessageLoopTest::PostFromNestedRunloop,
base::Unretained(this),
base::Unretained(&tasks_to_post_from_nested_loop)));
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::kInShortIdlePeriod,
test_task_runner_->NowTicks(),
test_task_runner_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
base::RunLoop().RunUntilIdle();
// Note we expect task 3 to run last because it's non-nestable.
EXPECT_THAT(order, testing::ElementsAre("1", "2", "4", "5", "3"));
}
TEST_F(IdleHelperTestWithIdlePeriodObserver, TestLongIdlePeriod) {
base::TimeTicks expected_deadline =
test_task_runner_->NowTicks() + maximum_idle_period_duration();
......
......@@ -11,7 +11,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/task/post_task.h"
......@@ -2156,85 +2155,6 @@ TEST_P(MainThreadSchedulerImplTest,
EXPECT_DCHECK_DEATH(base::GetContinuationTaskRunner());
}
class MainThreadSchedulerImplWithMessageLoopTest
: public MainThreadSchedulerImplTest {
public:
MainThreadSchedulerImplWithMessageLoopTest()
: message_loop_(new base::MessageLoop()) {}
~MainThreadSchedulerImplWithMessageLoopTest() override = default;
void SetUp() override {
clock_.Advance(base::TimeDelta::FromMilliseconds(5));
Initialize(std::make_unique<MainThreadSchedulerImplForTest>(
base::sequence_manager::SequenceManagerForTest::CreateOnCurrentThread(
base::sequence_manager::SequenceManager::Settings::Builder()
.SetTickClock(&clock_)
.SetAntiStarvationLogicForPrioritiesDisabled(
GetParam() == AntiStarvationLogic::kDisabled)
.Build()),
base::nullopt));
}
// Needed for EnableIdleTasks().
base::TimeTicks Now() override { return clock_.NowTicks(); }
void PostFromNestedRunloop(
Vector<std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>>* tasks) {
for (std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>& pair : *tasks) {
if (pair.second) {
idle_task_runner_->PostIdleTask(FROM_HERE, std::move(pair.first));
} else {
idle_task_runner_->PostNonNestableIdleTask(FROM_HERE,
std::move(pair.first));
}
}
EnableIdleTasks();
base::RunLoop(base::RunLoop::Type::kNestableTasksAllowed).RunUntilIdle();
}
private:
std::unique_ptr<base::MessageLoop> message_loop_;
base::SimpleTestTickClock clock_;
DISALLOW_COPY_AND_ASSIGN(MainThreadSchedulerImplWithMessageLoopTest);
};
INSTANTIATE_TEST_SUITE_P(All,
MainThreadSchedulerImplWithMessageLoopTest,
testing::Values(AntiStarvationLogic::kEnabled,
AntiStarvationLogic::kDisabled),
GetTestNameSuffix);
TEST_P(MainThreadSchedulerImplWithMessageLoopTest,
NonNestableIdleTaskDoesntExecuteInNestedLoop) {
Vector<String> order;
idle_task_runner_->PostIdleTask(
FROM_HERE, base::BindOnce(&AppendToVectorIdleTestTask, &order, "1"));
idle_task_runner_->PostIdleTask(
FROM_HERE, base::BindOnce(&AppendToVectorIdleTestTask, &order, "2"));
Vector<std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>>
tasks_to_post_from_nested_loop;
tasks_to_post_from_nested_loop.push_back(std::make_pair(
base::BindOnce(&AppendToVectorIdleTestTask, &order, "3"), false));
tasks_to_post_from_nested_loop.push_back(std::make_pair(
base::BindOnce(&AppendToVectorIdleTestTask, &order, "4"), true));
tasks_to_post_from_nested_loop.push_back(std::make_pair(
base::BindOnce(&AppendToVectorIdleTestTask, &order, "5"), true));
default_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&MainThreadSchedulerImplWithMessageLoopTest::PostFromNestedRunloop,
base::Unretained(this),
base::Unretained(&tasks_to_post_from_nested_loop)));
EnableIdleTasks();
base::RunLoop().RunUntilIdle();
// Note we expect task 3 to run last because it's non-nestable.
EXPECT_THAT(order, testing::ElementsAre("1", "2", "4", "5", "3"));
}
TEST_P(MainThreadSchedulerImplTest, TestBeginMainFrameNotExpectedUntil) {
base::TimeDelta ten_millis(base::TimeDelta::FromMilliseconds(10));
base::TimeTicks expected_deadline = Now() + ten_millis;
......
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