| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_ | 5 #ifndef CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_ |
| 6 #define CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_ | 6 #define CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "components/scheduler/scheduler_export.h" | 11 #include "components/scheduler/scheduler_export.h" |
| 12 #include "third_party/WebKit/public/platform/WebScheduler.h" | 12 #include "third_party/WebKit/public/platform/WebScheduler.h" |
| 13 #include "third_party/WebKit/public/platform/WebThread.h" | 13 #include "third_party/WebKit/public/platform/WebThread.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace scheduler { | 19 namespace scheduler { |
| 20 | 20 |
| 21 class ChildScheduler; | 21 class ChildScheduler; |
| 22 class SingleThreadIdleTaskRunner; | 22 class SingleThreadIdleTaskRunner; |
| 23 class TaskQueue; | 23 class TaskQueue; |
| 24 class WebTaskRunnerImpl; |
| 24 | 25 |
| 25 class SCHEDULER_EXPORT WebSchedulerImpl : public blink::WebScheduler { | 26 class SCHEDULER_EXPORT WebSchedulerImpl : public blink::WebScheduler { |
| 26 public: | 27 public: |
| 27 WebSchedulerImpl( | 28 WebSchedulerImpl( |
| 28 ChildScheduler* child_scheduler, | 29 ChildScheduler* child_scheduler, |
| 29 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner, | 30 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner, |
| 30 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, | 31 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, |
| 31 scoped_refptr<TaskQueue> timer_task_runner); | 32 scoped_refptr<TaskQueue> timer_task_runner); |
| 32 ~WebSchedulerImpl() override; | 33 ~WebSchedulerImpl() override; |
| 33 | 34 |
| 34 // blink::WebScheduler implementation: | 35 // blink::WebScheduler implementation: |
| 35 virtual void shutdown(); | 36 virtual void shutdown(); |
| 36 virtual bool shouldYieldForHighPriorityWork(); | 37 virtual bool shouldYieldForHighPriorityWork(); |
| 37 virtual bool canExceedIdleDeadlineIfRequired(); | 38 virtual bool canExceedIdleDeadlineIfRequired(); |
| 38 virtual void postIdleTask(const blink::WebTraceLocation& location, | 39 virtual void postIdleTask(const blink::WebTraceLocation& location, |
| 39 blink::WebThread::IdleTask* task); | 40 blink::WebThread::IdleTask* task); |
| 40 virtual void postNonNestableIdleTask(const blink::WebTraceLocation& location, | 41 virtual void postNonNestableIdleTask(const blink::WebTraceLocation& location, |
| 41 blink::WebThread::IdleTask* task); | 42 blink::WebThread::IdleTask* task); |
| 42 virtual void postIdleTaskAfterWakeup(const blink::WebTraceLocation& location, | 43 virtual void postIdleTaskAfterWakeup(const blink::WebTraceLocation& location, |
| 43 blink::WebThread::IdleTask* task); | 44 blink::WebThread::IdleTask* task); |
| 45 // TODO(alexclarke): Remove this. |
| 44 virtual void postLoadingTask(const blink::WebTraceLocation& location, | 46 virtual void postLoadingTask(const blink::WebTraceLocation& location, |
| 45 blink::WebThread::Task* task); | 47 blink::WebThread::Task* task); |
| 48 virtual blink::WebTaskRunner* loadingTaskRunner(); |
| 49 virtual blink::WebTaskRunner* timerTaskRunner(); |
| 50 |
| 46 // TODO(alexclarke): Remove when possible. | 51 // TODO(alexclarke): Remove when possible. |
| 47 virtual void postTimerTaskAt(const blink::WebTraceLocation& location, | 52 virtual void postTimerTaskAt(const blink::WebTraceLocation& location, |
| 48 blink::WebThread::Task* task, | 53 blink::WebThread::Task* task, |
| 49 double monotonicTime); | 54 double monotonicTime); |
| 55 // TODO(alexclarke): Remove when possible. |
| 56 virtual void postTimerTaskAt(const blink::WebTraceLocation& location, |
| 57 blink::WebTaskRunner::Task* task, |
| 58 double monotonicTime); |
| 59 // TODO(alexclarke): Remove this. |
| 50 virtual void postTimerTask(const blink::WebTraceLocation& location, | 60 virtual void postTimerTask(const blink::WebTraceLocation& location, |
| 51 blink::WebThread::Task* task, | 61 blink::WebThread::Task* task, |
| 52 double delaySecs); | 62 double delaySecs); |
| 53 // TODO(alexclarke): Remove once the Blink side patch lands. | 63 // TODO(alexclarke): Remove this. |
| 54 virtual void postTimerTask(const blink::WebTraceLocation& location, | 64 virtual void postTimerTask(const blink::WebTraceLocation& location, |
| 55 blink::WebThread::Task* task, | 65 blink::WebThread::Task* task, |
| 56 long long delayMs); | 66 long long delayMs); |
| 57 | 67 |
| 58 private: | 68 private: |
| 59 static void runIdleTask(scoped_ptr<blink::WebThread::IdleTask> task, | 69 static void runIdleTask(scoped_ptr<blink::WebThread::IdleTask> task, |
| 60 base::TimeTicks deadline); | 70 base::TimeTicks deadline); |
| 61 static void runTask(scoped_ptr<blink::WebThread::Task> task); | 71 static void runTask(scoped_ptr<blink::WebThread::Task> task); |
| 62 | 72 |
| 63 ChildScheduler* child_scheduler_; // NOT OWNED | 73 ChildScheduler* child_scheduler_; // NOT OWNED |
| 64 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; | 74 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; |
| 65 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; | 75 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; |
| 66 scoped_refptr<TaskQueue> timer_task_runner_; | 76 scoped_refptr<TaskQueue> timer_task_runner_; |
| 77 scoped_ptr<WebTaskRunnerImpl> loading_web_task_runner_; |
| 78 scoped_ptr<WebTaskRunnerImpl> timer_web_task_runner_; |
| 67 }; | 79 }; |
| 68 | 80 |
| 69 } // namespace scheduler | 81 } // namespace scheduler |
| 70 | 82 |
| 71 #endif // CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_ | 83 #endif // CONTENT_CHILD_SCHEDULER_BASE_WEB_SCHEDULER_IMPL_H_ |
| OLD | NEW |