[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:

committed by
Chromium LUCI CQ

parent
2e49f0e10b
commit
b62a51de7d
@@ -763,7 +763,7 @@ bool SequenceManagerImpl::HasPendingHighResolutionTasks() {
|
|||||||
return main_thread_only().wake_up_queue->has_pending_high_resolution_tasks();
|
return main_thread_only().wake_up_queue->has_pending_high_resolution_tasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SequenceManagerImpl::OnSystemIdle() {
|
bool SequenceManagerImpl::OnIdle() {
|
||||||
bool have_work_to_do = false;
|
bool have_work_to_do = false;
|
||||||
if (main_thread_only().time_domain) {
|
if (main_thread_only().time_domain) {
|
||||||
auto wakeup = main_thread_only().wake_up_queue->GetNextDelayedWakeUp();
|
auto wakeup = main_thread_only().wake_up_queue->GetNextDelayedWakeUp();
|
||||||
|
@@ -141,7 +141,7 @@ class BASE_EXPORT SequenceManagerImpl
|
|||||||
LazyNow* lazy_now,
|
LazyNow* lazy_now,
|
||||||
SelectTaskOption option = SelectTaskOption::kDefault) override;
|
SelectTaskOption option = SelectTaskOption::kDefault) override;
|
||||||
bool HasPendingHighResolutionTasks() override;
|
bool HasPendingHighResolutionTasks() override;
|
||||||
bool OnSystemIdle() override;
|
bool OnIdle() override;
|
||||||
void MaybeEmitTaskDetails(
|
void MaybeEmitTaskDetails(
|
||||||
perfetto::EventContext& ctx,
|
perfetto::EventContext& ctx,
|
||||||
const SequencedTaskSource::SelectedTask& selected_task) const override;
|
const SequencedTaskSource::SelectedTask& selected_task) const override;
|
||||||
@@ -342,8 +342,8 @@ class BASE_EXPORT SequenceManagerImpl
|
|||||||
ObserverList<CurrentThread::DestructionObserver>::Unchecked
|
ObserverList<CurrentThread::DestructionObserver>::Unchecked
|
||||||
destruction_observers;
|
destruction_observers;
|
||||||
|
|
||||||
// If non-null, invoked the next time OnSystemIdle() completes without
|
// If non-null, invoked the next time OnIdle() completes without scheduling
|
||||||
// scheduling additional work.
|
// additional work.
|
||||||
OnceClosure on_next_idle_callback;
|
OnceClosure on_next_idle_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -4771,20 +4771,20 @@ class MockTimeDomain : public TimeDomain {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TEST_P(SequenceManagerTest, OnSystemIdleTimeDomainNotification) {
|
TEST_P(SequenceManagerTest, OnIdleTimeDomainNotification) {
|
||||||
if (GetUnderlyingRunnerType() != RunnerType::kMessagePump)
|
if (GetUnderlyingRunnerType() != RunnerType::kMessagePump)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto queue = CreateTaskQueue();
|
auto queue = CreateTaskQueue();
|
||||||
|
|
||||||
// If we call OnSystemIdle, we expect registered TimeDomains to receive a call
|
// If we call OnIdle, we expect registered TimeDomains to receive a call to
|
||||||
// to MaybeFastForwardToWakeUp. If no run loop has requested quit on idle,
|
// MaybeFastForwardToWakeUp. If no run loop has requested quit on idle, the
|
||||||
// the parameter passed in should be false.
|
// parameter passed in should be false.
|
||||||
StrictMock<MockTimeDomain> mock_time_domain;
|
StrictMock<MockTimeDomain> mock_time_domain;
|
||||||
sequence_manager()->SetTimeDomain(&mock_time_domain);
|
sequence_manager()->SetTimeDomain(&mock_time_domain);
|
||||||
EXPECT_CALL(mock_time_domain, MaybeFastForwardToWakeUp(false))
|
EXPECT_CALL(mock_time_domain, MaybeFastForwardToWakeUp(false))
|
||||||
.WillOnce(Return(false));
|
.WillOnce(Return(false));
|
||||||
sequence_manager()->OnSystemIdle();
|
sequence_manager()->OnIdle();
|
||||||
sequence_manager()->ResetTimeDomain();
|
sequence_manager()->ResetTimeDomain();
|
||||||
Mock::VerifyAndClearExpectations(&mock_time_domain);
|
Mock::VerifyAndClearExpectations(&mock_time_domain);
|
||||||
|
|
||||||
@@ -4795,7 +4795,7 @@ TEST_P(SequenceManagerTest, OnSystemIdleTimeDomainNotification) {
|
|||||||
EXPECT_CALL(mock_time_domain, MaybeFastForwardToWakeUp(true))
|
EXPECT_CALL(mock_time_domain, MaybeFastForwardToWakeUp(true))
|
||||||
.WillOnce(Return(false));
|
.WillOnce(Return(false));
|
||||||
sequence_manager()->SetTimeDomain(&mock_time_domain);
|
sequence_manager()->SetTimeDomain(&mock_time_domain);
|
||||||
sequence_manager()->OnSystemIdle();
|
sequence_manager()->OnIdle();
|
||||||
sequence_manager()->ResetTimeDomain();
|
sequence_manager()->ResetTimeDomain();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@@ -78,7 +78,7 @@ class SequencedTaskSource {
|
|||||||
// Called when we have run out of immediate work. If more immediate work
|
// 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,
|
// becomes available as a result of any processing done by this callback,
|
||||||
// return true to schedule a future DoWork.
|
// 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.
|
// Called prior to running `selected_task` to emit trace event data for it.
|
||||||
virtual void MaybeEmitTaskDetails(
|
virtual void MaybeEmitTaskDetails(
|
||||||
|
@@ -252,10 +252,9 @@ void ThreadControllerImpl::DoWork(WorkType work_type) {
|
|||||||
LazyNow lazy_now_after_work(time_source_);
|
LazyNow lazy_now_after_work(time_source_);
|
||||||
absl::optional<WakeUp> next_wake_up =
|
absl::optional<WakeUp> next_wake_up =
|
||||||
sequence_->GetPendingWakeUp(&lazy_now_after_work);
|
sequence_->GetPendingWakeUp(&lazy_now_after_work);
|
||||||
// The OnSystemIdle callback allows the TimeDomains to advance virtual time
|
// The OnIdle() callback allows the TimeDomains to advance virtual time in
|
||||||
// in which case we now have immediate work to do.
|
// which case we now have immediate work to do.
|
||||||
if ((next_wake_up && next_wake_up->is_immediate()) ||
|
if ((next_wake_up && next_wake_up->is_immediate()) || sequence_->OnIdle()) {
|
||||||
sequence_->OnSystemIdle()) {
|
|
||||||
// The next task needs to run immediately, post a continuation if
|
// The next task needs to run immediately, post a continuation if
|
||||||
// another thread didn't get there first.
|
// another thread didn't get there first.
|
||||||
if (work_deduplicator_.DidCheckForMoreWork(
|
if (work_deduplicator_.DidCheckForMoreWork(
|
||||||
|
@@ -573,9 +573,9 @@ bool ThreadControllerWithMessagePumpImpl::DoIdleWork() {
|
|||||||
}
|
}
|
||||||
#endif // BUILDFLAG(IS_WIN)
|
#endif // BUILDFLAG(IS_WIN)
|
||||||
|
|
||||||
if (main_thread_only().task_source->OnSystemIdle()) {
|
if (main_thread_only().task_source->OnIdle()) {
|
||||||
// The OnSystemIdle() callback resulted in more immediate work, so schedule
|
// The OnIdle() callback resulted in more immediate work, so schedule a
|
||||||
// a DoWork callback. For some message pumps returning true from here is
|
// DoWork callback. For some message pumps returning true from here is
|
||||||
// sufficient to do that but not on mac.
|
// sufficient to do that but not on mac.
|
||||||
pump_->ScheduleWork();
|
pump_->ScheduleWork();
|
||||||
return false;
|
return false;
|
||||||
|
@@ -181,7 +181,7 @@ class FakeSequencedTaskSource : public SequencedTaskSource {
|
|||||||
has_pending_high_resolution_tasks = state;
|
has_pending_high_resolution_tasks = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnSystemIdle() override { return false; }
|
bool OnIdle() override { return false; }
|
||||||
|
|
||||||
void MaybeEmitTaskDetails(perfetto::EventContext& ctx,
|
void MaybeEmitTaskDetails(perfetto::EventContext& ctx,
|
||||||
const SelectedTask& selected_task) const override {}
|
const SelectedTask& selected_task) const override {}
|
||||||
|
Reference in New Issue
Block a user