Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 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 "content/renderer/scheduler/web_scheduler_impl.h" | 5 #include "content/child/scheduler/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 "content/renderer/scheduler/renderer_scheduler.h" | 9 #include "content/child/scheduler/worker_scheduler.h" |
| 10 #include "third_party/WebKit/public/platform/WebTraceLocation.h" | 10 #include "third_party/WebKit/public/platform/WebTraceLocation.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 WebSchedulerImpl::WebSchedulerImpl(RendererScheduler* renderer_scheduler) | 14 WebSchedulerImpl::WebSchedulerImpl( |
| 15 : renderer_scheduler_(renderer_scheduler), | 15 ChildScheduler* child_scheduler, |
| 16 idle_task_runner_(renderer_scheduler_->IdleTaskRunner()), | 16 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner, |
| 17 loading_task_runner_(renderer_scheduler_->LoadingTaskRunner()), | 17 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, |
| 18 timer_task_runner_(renderer_scheduler_->TimerTaskRunner()) { | 18 scoped_refptr<base::SingleThreadTaskRunner> timer_task_runner) |
| 19 : child_scheduler_(child_scheduler), | |
| 20 idle_task_runner_(idle_task_runner), | |
| 21 loading_task_runner_(loading_task_runner), | |
| 22 timer_task_runner_(timer_task_runner) { | |
| 19 } | 23 } |
| 20 | 24 |
| 21 WebSchedulerImpl::~WebSchedulerImpl() { | 25 WebSchedulerImpl::~WebSchedulerImpl() { |
| 22 } | 26 } |
| 23 | 27 |
| 24 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { | 28 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { |
| 25 return renderer_scheduler_->ShouldYieldForHighPriorityWork(); | 29 return child_scheduler_->ShouldYieldForHighPriorityWork(); |
| 26 } | 30 } |
| 27 | 31 |
| 28 bool WebSchedulerImpl::canExceedIdleDeadlineIfRequired() { | 32 bool WebSchedulerImpl::canExceedIdleDeadlineIfRequired() { |
| 29 return renderer_scheduler_->CanExceedIdleDeadlineIfRequired(); | 33 return child_scheduler_->CanExceedIdleDeadlineIfRequired(); |
| 30 } | 34 } |
| 31 | 35 |
| 32 void WebSchedulerImpl::runIdleTask(scoped_ptr<blink::WebThread::IdleTask> task, | 36 void WebSchedulerImpl::runIdleTask(scoped_ptr<blink::WebThread::IdleTask> task, |
| 33 base::TimeTicks deadline) { | 37 base::TimeTicks deadline) { |
| 34 task->run((deadline - base::TimeTicks()).InSecondsF()); | 38 task->run((deadline - base::TimeTicks()).InSecondsF()); |
| 35 } | 39 } |
| 36 | 40 |
| 37 void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) { | 41 void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) { |
| 38 task->run(); | 42 task->run(); |
| 39 } | 43 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 67 DCHECK(idle_task_runner_); | 71 DCHECK(idle_task_runner_); |
| 68 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); | 72 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); |
| 69 tracked_objects::Location location(web_location.functionName(), | 73 tracked_objects::Location location(web_location.functionName(), |
| 70 web_location.fileName(), -1, nullptr); | 74 web_location.fileName(), -1, nullptr); |
| 71 idle_task_runner_->PostIdleTaskAfterWakeup( | 75 idle_task_runner_->PostIdleTaskAfterWakeup( |
| 72 location, | 76 location, |
| 73 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); | 77 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); |
| 74 } | 78 } |
| 75 | 79 |
| 76 void WebSchedulerImpl::postLoadingTask( | 80 void WebSchedulerImpl::postLoadingTask( |
| 77 const blink::WebTraceLocation& web_location, blink::WebThread::Task* task) { | 81 const blink::WebTraceLocation& web_location, |
| 82 blink::WebThread::Task* task) { | |
| 78 DCHECK(loading_task_runner_); | 83 DCHECK(loading_task_runner_); |
| 79 scoped_ptr<blink::WebThread::Task> scoped_task(task); | 84 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| 80 tracked_objects::Location location(web_location.functionName(), | 85 tracked_objects::Location location(web_location.functionName(), |
| 81 web_location.fileName(), -1, nullptr); | 86 web_location.fileName(), -1, nullptr); |
| 82 loading_task_runner_->PostTask( | 87 loading_task_runner_->PostTask( |
| 83 location, | 88 location, |
| 84 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task))); | 89 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task))); |
| 85 } | 90 } |
| 86 | 91 |
| 87 void WebSchedulerImpl::postTimerTask( | 92 void WebSchedulerImpl::postTimerTask( |
| 88 const blink::WebTraceLocation& web_location, | 93 const blink::WebTraceLocation& web_location, |
| 89 blink::WebThread::Task* task, | 94 blink::WebThread::Task* task, |
| 90 long long delayMs) { | 95 long long delayMs) { |
| 91 DCHECK(timer_task_runner_); | 96 DCHECK(timer_task_runner_); |
| 92 scoped_ptr<blink::WebThread::Task> scoped_task(task); | 97 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| 93 tracked_objects::Location location(web_location.functionName(), | 98 tracked_objects::Location location(web_location.functionName(), |
| 94 web_location.fileName(), -1, nullptr); | 99 web_location.fileName(), -1, nullptr); |
| 95 timer_task_runner_->PostDelayedTask( | 100 timer_task_runner_->PostDelayedTask( |
| 96 location, | 101 location, |
| 97 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), | 102 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), |
| 98 base::TimeDelta::FromMilliseconds(delayMs)); | 103 base::TimeDelta::FromMilliseconds(delayMs)); |
| 99 } | 104 } |
| 100 | |
|
Sami
2015/04/16 13:59:50
Intentional?
alex clarke (OOO till 29th)
2015/04/16 14:03:05
Done.
| |
| 101 } // namespace content | 105 } // namespace content |
| OLD | NEW |