Roll src/third_party/WebKit 605a979:06cb9e9 (svn 202556:202558)
[chromium-blink-merge.git] / components / scheduler / child / worker_scheduler_impl.h
blob65fee33908df69f3961f8216ccac77847f49a494
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"
13 namespace base {
14 namespace trace_event {
15 class ConvertableToTraceFormat;
19 namespace scheduler {
21 class SchedulerTaskRunnerDelegate;
23 class SCHEDULER_EXPORT WorkerSchedulerImpl : public WorkerScheduler,
24 public IdleHelper::Delegate {
25 public:
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;
38 void Init() override;
39 void Shutdown() override;
41 SchedulerHelper* GetSchedulerHelperForTesting();
42 base::TimeTicks CurrentIdleTaskDeadlineForTesting() const;
44 protected:
45 // IdleHelper::Delegate implementation:
46 bool CanEnterLongIdlePeriod(
47 base::TimeTicks now,
48 base::TimeDelta* next_long_idle_period_delay_out) override;
49 void IsNotQuiescent() override {}
50 void OnIdlePeriodStarted() override {}
51 void OnIdlePeriodEnded() override {}
53 private:
54 void MaybeStartLongIdlePeriod();
56 SchedulerHelper helper_;
57 IdleHelper idle_helper_;
58 bool initialized_;
60 DISALLOW_COPY_AND_ASSIGN(WorkerSchedulerImpl);
63 } // namespace scheduler
65 #endif // COMPONENTS_SCHEDULER_CHILD_WORKER_SCHEDULER_IMPL_H_