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 CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_
6 #define CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h"
11 #include "components/scheduler/scheduler_export.h"
12 #include "third_party/WebKit/public/platform/WebScheduler.h"
13 #include "third_party/WebKit/public/platform/WebThread.h"
16 class SingleThreadTaskRunner
;
22 class SingleThreadIdleTaskRunner
;
24 class WebTaskRunnerImpl
;
26 class SCHEDULER_EXPORT WebSchedulerImpl
: public blink::WebScheduler
{
29 ChildScheduler
* child_scheduler
,
30 scoped_refptr
<SingleThreadIdleTaskRunner
> idle_task_runner
,
31 scoped_refptr
<base::SingleThreadTaskRunner
> loading_task_runner
,
32 scoped_refptr
<TaskQueue
> timer_task_runner
);
33 ~WebSchedulerImpl() override
;
35 // blink::WebScheduler implementation:
36 virtual void shutdown();
37 virtual bool shouldYieldForHighPriorityWork();
38 virtual bool canExceedIdleDeadlineIfRequired();
39 virtual void postIdleTask(const blink::WebTraceLocation
& location
,
40 blink::WebThread::IdleTask
* task
);
41 virtual void postNonNestableIdleTask(const blink::WebTraceLocation
& location
,
42 blink::WebThread::IdleTask
* task
);
43 virtual void postIdleTaskAfterWakeup(const blink::WebTraceLocation
& location
,
44 blink::WebThread::IdleTask
* task
);
45 virtual blink::WebTaskRunner
* loadingTaskRunner();
46 virtual blink::WebTaskRunner
* timerTaskRunner();
48 // TODO(alexclarke): Remove when possible.
49 virtual void postTimerTaskAt(const blink::WebTraceLocation
& location
,
50 blink::WebTaskRunner::Task
* task
,
51 double monotonicTime
);
54 static void runIdleTask(scoped_ptr
<blink::WebThread::IdleTask
> task
,
55 base::TimeTicks deadline
);
57 ChildScheduler
* child_scheduler_
; // NOT OWNED
58 scoped_refptr
<SingleThreadIdleTaskRunner
> idle_task_runner_
;
59 scoped_refptr
<TaskQueue
> timer_task_runner_
;
60 scoped_ptr
<WebTaskRunnerImpl
> loading_web_task_runner_
;
61 scoped_ptr
<WebTaskRunnerImpl
> timer_web_task_runner_
;
64 } // namespace scheduler
66 #endif // CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_