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
;
25 class SCHEDULER_EXPORT WebSchedulerImpl
: public blink::WebScheduler
{
28 ChildScheduler
* child_scheduler
,
29 scoped_refptr
<SingleThreadIdleTaskRunner
> idle_task_runner
,
30 scoped_refptr
<base::SingleThreadTaskRunner
> loading_task_runner
,
31 scoped_refptr
<TaskQueue
> timer_task_runner
);
32 ~WebSchedulerImpl() override
;
34 // blink::WebScheduler implementation:
35 virtual void shutdown();
36 virtual bool shouldYieldForHighPriorityWork();
37 virtual bool canExceedIdleDeadlineIfRequired();
38 virtual void postIdleTask(const blink::WebTraceLocation
& location
,
39 blink::WebThread::IdleTask
* task
);
40 virtual void postNonNestableIdleTask(const blink::WebTraceLocation
& location
,
41 blink::WebThread::IdleTask
* task
);
42 virtual void postIdleTaskAfterWakeup(const blink::WebTraceLocation
& location
,
43 blink::WebThread::IdleTask
* task
);
44 virtual void postLoadingTask(const blink::WebTraceLocation
& location
,
45 blink::WebThread::Task
* task
);
46 // TODO(alexclarke): Remove when possible.
47 virtual void postTimerTaskAt(const blink::WebTraceLocation
& location
,
48 blink::WebThread::Task
* task
,
49 double monotonicTime
);
50 virtual void postTimerTask(const blink::WebTraceLocation
& location
,
51 blink::WebThread::Task
* task
,
53 // TODO(alexclarke): Remove once the Blink side patch lands.
54 virtual void postTimerTask(const blink::WebTraceLocation
& location
,
55 blink::WebThread::Task
* task
,
59 static void runIdleTask(scoped_ptr
<blink::WebThread::IdleTask
> task
,
60 base::TimeTicks deadline
);
61 static void runTask(scoped_ptr
<blink::WebThread::Task
> task
);
63 ChildScheduler
* child_scheduler_
; // NOT OWNED
64 scoped_refptr
<SingleThreadIdleTaskRunner
> idle_task_runner_
;
65 scoped_refptr
<base::SingleThreadTaskRunner
> loading_task_runner_
;
66 scoped_refptr
<TaskQueue
> timer_task_runner_
;
69 } // namespace scheduler
71 #endif // CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_