OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_ | |
6 #define CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/time/time.h" | |
11 #include "content/common/content_export.h" | |
12 #include "third_party/WebKit/public/platform/WebScheduler.h" | |
13 #include "third_party/WebKit/public/platform/WebThread.h" | |
14 | |
15 namespace base { | |
16 class SingleThreadTaskRunner; | |
17 } | |
18 | |
19 namespace content { | |
20 | |
21 class ChildScheduler; | |
22 class SingleThreadIdleTaskRunner; | |
23 | |
24 class CONTENT_EXPORT WebSchedulerImpl : public blink::WebScheduler { | |
25 public: | |
26 WebSchedulerImpl( | |
27 ChildScheduler* child_scheduler, | |
28 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner, | |
29 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, | |
30 scoped_refptr<base::SingleThreadTaskRunner> timer_task_runner); | |
31 ~WebSchedulerImpl() override; | |
32 | |
33 // blink::WebScheduler implementation: | |
34 virtual bool shouldYieldForHighPriorityWork(); | |
35 virtual bool canExceedIdleDeadlineIfRequired(); | |
36 virtual void postIdleTask(const blink::WebTraceLocation& location, | |
37 blink::WebThread::IdleTask* task); | |
38 virtual void postNonNestableIdleTask(const blink::WebTraceLocation& location, | |
39 blink::WebThread::IdleTask* task); | |
40 virtual void postIdleTaskAfterWakeup(const blink::WebTraceLocation& location, | |
41 blink::WebThread::IdleTask* task); | |
42 virtual void postLoadingTask(const blink::WebTraceLocation& location, | |
43 blink::WebThread::Task* task); | |
44 virtual void postTimerTask(const blink::WebTraceLocation& location, | |
45 blink::WebThread::Task* task, | |
46 long long delayMs); | |
47 | |
48 private: | |
49 static void runIdleTask(scoped_ptr<blink::WebThread::IdleTask> task, | |
50 base::TimeTicks deadline); | |
51 static void runTask(scoped_ptr<blink::WebThread::Task> task); | |
52 | |
53 ChildScheduler* child_scheduler_; // NOT OWNED | |
54 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; | |
55 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; | |
56 scoped_refptr<base::SingleThreadTaskRunner> timer_task_runner_; | |
57 }; | |
58 | |
59 } // namespace content | |
60 | |
61 #endif // CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_ | |
OLD | NEW |