0

[base] Rename SequencedTaskSource::OnSystemIdle() to OnIdle().

Reason: The method is invoked when the thread running the task source
is idle, not when the system idle.

Bug: 1503967
Change-Id: I9f59259056ee834b3789a6aeb4fcb37808aeb7c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5131495
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Commit-Queue: Francois Pierre Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1239116}
This commit is contained in:
François Doray
2023-12-19 14:28:45 +00:00
committed by Chromium LUCI CQ
parent 2e49f0e10b
commit b62a51de7d
7 changed files with 18 additions and 19 deletions

@ -763,7 +763,7 @@ bool SequenceManagerImpl::HasPendingHighResolutionTasks() {
return main_thread_only().wake_up_queue->has_pending_high_resolution_tasks();
}
bool SequenceManagerImpl::OnSystemIdle() {
bool SequenceManagerImpl::OnIdle() {
bool have_work_to_do = false;
if (main_thread_only().time_domain) {
auto wakeup = main_thread_only().wake_up_queue->GetNextDelayedWakeUp();

@ -141,7 +141,7 @@ class BASE_EXPORT SequenceManagerImpl
LazyNow* lazy_now,
SelectTaskOption option = SelectTaskOption::kDefault) override;
bool HasPendingHighResolutionTasks() override;
bool OnSystemIdle() override;
bool OnIdle() override;
void MaybeEmitTaskDetails(
perfetto::EventContext& ctx,
const SequencedTaskSource::SelectedTask& selected_task) const override;
@ -342,8 +342,8 @@ class BASE_EXPORT SequenceManagerImpl
ObserverList<CurrentThread::DestructionObserver>::Unchecked
destruction_observers;
// If non-null, invoked the next time OnSystemIdle() completes without
// scheduling additional work.
// If non-null, invoked the next time OnIdle() completes without scheduling
// additional work.
OnceClosure on_next_idle_callback;
};

@ -4771,20 +4771,20 @@ class MockTimeDomain : public TimeDomain {
} // namespace
TEST_P(SequenceManagerTest, OnSystemIdleTimeDomainNotification) {
TEST_P(SequenceManagerTest, OnIdleTimeDomainNotification) {
if (GetUnderlyingRunnerType() != RunnerType::kMessagePump)
return;
auto queue = CreateTaskQueue();
// If we call OnSystemIdle, we expect registered TimeDomains to receive a call
// to MaybeFastForwardToWakeUp. If no run loop has requested quit on idle,
// the parameter passed in should be false.
// If we call OnIdle, we expect registered TimeDomains to receive a call to
// MaybeFastForwardToWakeUp. If no run loop has requested quit on idle, the
// parameter passed in should be false.
StrictMock<MockTimeDomain> mock_time_domain;
sequence_manager()->SetTimeDomain(&mock_time_domain);
EXPECT_CALL(mock_time_domain, MaybeFastForwardToWakeUp(false))
.WillOnce(Return(false));
sequence_manager()->OnSystemIdle();
sequence_manager()->OnIdle();
sequence_manager()->ResetTimeDomain();
Mock::VerifyAndClearExpectations(&mock_time_domain);
@ -4795,7 +4795,7 @@ TEST_P(SequenceManagerTest, OnSystemIdleTimeDomainNotification) {
EXPECT_CALL(mock_time_domain, MaybeFastForwardToWakeUp(true))
.WillOnce(Return(false));
sequence_manager()->SetTimeDomain(&mock_time_domain);
sequence_manager()->OnSystemIdle();
sequence_manager()->OnIdle();
sequence_manager()->ResetTimeDomain();
}));

@ -78,7 +78,7 @@ class SequencedTaskSource {
// Called when we have run out of immediate work. If more immediate work
// becomes available as a result of any processing done by this callback,
// return true to schedule a future DoWork.
virtual bool OnSystemIdle() = 0;
virtual bool OnIdle() = 0;
// Called prior to running `selected_task` to emit trace event data for it.
virtual void MaybeEmitTaskDetails(

@ -252,10 +252,9 @@ void ThreadControllerImpl::DoWork(WorkType work_type) {
LazyNow lazy_now_after_work(time_source_);
absl::optional<WakeUp> next_wake_up =
sequence_->GetPendingWakeUp(&lazy_now_after_work);
// The OnSystemIdle callback allows the TimeDomains to advance virtual time
// in which case we now have immediate work to do.
if ((next_wake_up && next_wake_up->is_immediate()) ||
sequence_->OnSystemIdle()) {
// The OnIdle() callback allows the TimeDomains to advance virtual time in
// which case we now have immediate work to do.
if ((next_wake_up && next_wake_up->is_immediate()) || sequence_->OnIdle()) {
// The next task needs to run immediately, post a continuation if
// another thread didn't get there first.
if (work_deduplicator_.DidCheckForMoreWork(

@ -573,9 +573,9 @@ bool ThreadControllerWithMessagePumpImpl::DoIdleWork() {
}
#endif // BUILDFLAG(IS_WIN)
if (main_thread_only().task_source->OnSystemIdle()) {
// The OnSystemIdle() callback resulted in more immediate work, so schedule
// a DoWork callback. For some message pumps returning true from here is
if (main_thread_only().task_source->OnIdle()) {
// The OnIdle() callback resulted in more immediate work, so schedule a
// DoWork callback. For some message pumps returning true from here is
// sufficient to do that but not on mac.
pump_->ScheduleWork();
return false;

@ -181,7 +181,7 @@ class FakeSequencedTaskSource : public SequencedTaskSource {
has_pending_high_resolution_tasks = state;
}
bool OnSystemIdle() override { return false; }
bool OnIdle() override { return false; }
void MaybeEmitTaskDetails(perfetto::EventContext& ctx,
const SelectedTask& selected_task) const override {}