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 #include "components/scheduler/child/web_scheduler_impl.h" | 5 #include "components/scheduler/child/web_scheduler_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "components/scheduler/child/web_task_runner_impl.h" |
9 #include "components/scheduler/child/worker_scheduler.h" | 10 #include "components/scheduler/child/worker_scheduler.h" |
10 #include "third_party/WebKit/public/platform/WebTraceLocation.h" | 11 #include "third_party/WebKit/public/platform/WebTraceLocation.h" |
11 | 12 |
12 namespace scheduler { | 13 namespace scheduler { |
13 | 14 |
14 WebSchedulerImpl::WebSchedulerImpl( | 15 WebSchedulerImpl::WebSchedulerImpl( |
15 ChildScheduler* child_scheduler, | 16 ChildScheduler* child_scheduler, |
16 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner, | 17 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner, |
17 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, | 18 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, |
18 scoped_refptr<TaskQueue> timer_task_runner) | 19 scoped_refptr<TaskQueue> timer_task_runner) |
19 : child_scheduler_(child_scheduler), | 20 : child_scheduler_(child_scheduler), |
20 idle_task_runner_(idle_task_runner), | 21 idle_task_runner_(idle_task_runner), |
21 loading_task_runner_(loading_task_runner), | 22 loading_task_runner_(loading_task_runner), |
22 timer_task_runner_(timer_task_runner) {} | 23 timer_task_runner_(timer_task_runner), |
| 24 loading_web_task_runner_(new WebTaskRunnerImpl(loading_task_runner)), |
| 25 timer_web_task_runner_(new WebTaskRunnerImpl(timer_task_runner)) {} |
23 | 26 |
24 WebSchedulerImpl::~WebSchedulerImpl() { | 27 WebSchedulerImpl::~WebSchedulerImpl() { |
25 } | 28 } |
26 | 29 |
27 void WebSchedulerImpl::shutdown() { | 30 void WebSchedulerImpl::shutdown() { |
28 child_scheduler_->Shutdown(); | 31 child_scheduler_->Shutdown(); |
29 } | 32 } |
30 | 33 |
31 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { | 34 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { |
32 return child_scheduler_->ShouldYieldForHighPriorityWork(); | 35 return child_scheduler_->ShouldYieldForHighPriorityWork(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 DCHECK(timer_task_runner_); | 116 DCHECK(timer_task_runner_); |
114 scoped_ptr<blink::WebThread::Task> scoped_task(task); | 117 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
115 tracked_objects::Location location(web_location.functionName(), | 118 tracked_objects::Location location(web_location.functionName(), |
116 web_location.fileName(), -1, nullptr); | 119 web_location.fileName(), -1, nullptr); |
117 timer_task_runner_->PostDelayedTask( | 120 timer_task_runner_->PostDelayedTask( |
118 location, | 121 location, |
119 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), | 122 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), |
120 base::TimeDelta::FromSecondsD(delaySecs)); | 123 base::TimeDelta::FromSecondsD(delaySecs)); |
121 } | 124 } |
122 | 125 |
| 126 blink::WebTaskRunner* WebSchedulerImpl::loadingTaskRunner() { |
| 127 return loading_web_task_runner_.get(); |
| 128 } |
| 129 |
| 130 blink::WebTaskRunner* WebSchedulerImpl::timerTaskRunner() { |
| 131 return timer_web_task_runner_.get(); |
| 132 } |
| 133 |
123 void WebSchedulerImpl::postTimerTaskAt( | 134 void WebSchedulerImpl::postTimerTaskAt( |
124 const blink::WebTraceLocation& web_location, | 135 const blink::WebTraceLocation& web_location, |
125 blink::WebThread::Task* task, | 136 blink::WebThread::Task* task, |
126 double monotonicTime) { | 137 double monotonicTime) { |
127 DCHECK(timer_task_runner_); | 138 DCHECK(timer_task_runner_); |
128 scoped_ptr<blink::WebThread::Task> scoped_task(task); | 139 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
129 tracked_objects::Location location(web_location.functionName(), | 140 tracked_objects::Location location(web_location.functionName(), |
130 web_location.fileName(), -1, nullptr); | 141 web_location.fileName(), -1, nullptr); |
131 timer_task_runner_->PostDelayedTaskAt( | 142 timer_task_runner_->PostDelayedTaskAt( |
132 location, | 143 location, |
133 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), | 144 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), |
134 base::TimeTicks() + base::TimeDelta::FromSecondsD(monotonicTime)); | 145 base::TimeTicks() + base::TimeDelta::FromSecondsD(monotonicTime)); |
135 } | 146 } |
136 | 147 |
| 148 void WebSchedulerImpl::postTimerTaskAt( |
| 149 const blink::WebTraceLocation& web_location, |
| 150 blink::WebTaskRunner::Task* task, |
| 151 double monotonicTime) { |
| 152 DCHECK(timer_task_runner_); |
| 153 tracked_objects::Location location(web_location.functionName(), |
| 154 web_location.fileName(), -1, nullptr); |
| 155 timer_task_runner_->PostDelayedTaskAt( |
| 156 location, base::Bind(&blink::WebTaskRunner::Task::run, base::Owned(task)), |
| 157 base::TimeTicks() + base::TimeDelta::FromSecondsD(monotonicTime)); |
| 158 } |
| 159 |
137 } // namespace scheduler | 160 } // namespace scheduler |
OLD | NEW |