1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SCHEDULER_CHILD_WORKER_SCHEDULER_IMPL_H_
6 #define COMPONENTS_SCHEDULER_CHILD_WORKER_SCHEDULER_IMPL_H_
8 #include "components/scheduler/child/idle_helper.h"
9 #include "components/scheduler/child/scheduler_helper.h"
10 #include "components/scheduler/child/worker_scheduler.h"
11 #include "components/scheduler/scheduler_export.h"
14 namespace trace_event
{
15 class ConvertableToTraceFormat
;
21 class SchedulerTaskRunnerDelegate
;
23 class SCHEDULER_EXPORT WorkerSchedulerImpl
: public WorkerScheduler
,
24 public IdleHelper::Delegate
{
26 explicit WorkerSchedulerImpl(
27 scoped_refptr
<SchedulerTaskRunnerDelegate
> main_task_runner
);
28 ~WorkerSchedulerImpl() override
;
30 // WorkerScheduler implementation:
31 scoped_refptr
<TaskQueue
> DefaultTaskRunner() override
;
32 scoped_refptr
<SingleThreadIdleTaskRunner
> IdleTaskRunner() override
;
33 bool CanExceedIdleDeadlineIfRequired() const override
;
34 bool ShouldYieldForHighPriorityWork() override
;
35 void AddTaskObserver(base::MessageLoop::TaskObserver
* task_observer
) override
;
36 void RemoveTaskObserver(
37 base::MessageLoop::TaskObserver
* task_observer
) override
;
39 void Shutdown() override
;
41 SchedulerHelper
* GetSchedulerHelperForTesting();
42 base::TimeTicks
CurrentIdleTaskDeadlineForTesting() const;
45 // IdleHelper::Delegate implementation:
46 bool CanEnterLongIdlePeriod(
48 base::TimeDelta
* next_long_idle_period_delay_out
) override
;
49 void IsNotQuiescent() override
{}
50 void OnIdlePeriodStarted() override
{}
51 void OnIdlePeriodEnded() override
{}
54 void MaybeStartLongIdlePeriod();
56 SchedulerHelper helper_
;
57 IdleHelper idle_helper_
;
60 DISALLOW_COPY_AND_ASSIGN(WorkerSchedulerImpl
);
63 } // namespace scheduler
65 #endif // COMPONENTS_SCHEDULER_CHILD_WORKER_SCHEDULER_IMPL_H_