| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/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/renderer/scheduler/renderer_scheduler.h" |
| 10 #include "third_party/WebKit/public/platform/WebTraceLocation.h" | 10 #include "third_party/WebKit/public/platform/WebTraceLocation.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { | 24 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { |
| 25 return renderer_scheduler_->ShouldYieldForHighPriorityWork(); | 25 return renderer_scheduler_->ShouldYieldForHighPriorityWork(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool WebSchedulerImpl::canExceedIdleDeadlineIfRequired() { | 28 bool WebSchedulerImpl::canExceedIdleDeadlineIfRequired() { |
| 29 return renderer_scheduler_->CanExceedIdleDeadlineIfRequired(); | 29 return renderer_scheduler_->CanExceedIdleDeadlineIfRequired(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void WebSchedulerImpl::runIdleTask( | 32 void WebSchedulerImpl::runIdleTask( |
| 33 scoped_ptr<blink::WebScheduler::IdleTask> task, | 33 scoped_ptr<blink::WebThread::IdleTask> task, |
| 34 base::TimeTicks deadline) { | 34 base::TimeTicks deadline) { |
| 35 task->run((deadline - base::TimeTicks()).InSecondsF()); | 35 task->run((deadline - base::TimeTicks()).InSecondsF()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) { | 38 void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) { |
| 39 task->run(); | 39 task->run(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, | 42 void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, |
| 43 blink::WebScheduler::IdleTask* task) { | 43 blink::WebThread::IdleTask* task) { |
| 44 DCHECK(idle_task_runner_); | 44 DCHECK(idle_task_runner_); |
| 45 scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); | 45 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); |
| 46 tracked_objects::Location location(web_location.functionName(), | 46 tracked_objects::Location location(web_location.functionName(), |
| 47 web_location.fileName(), -1, nullptr); | 47 web_location.fileName(), -1, nullptr); |
| 48 idle_task_runner_->PostIdleTask( | 48 idle_task_runner_->PostIdleTask( |
| 49 location, | 49 location, |
| 50 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); | 50 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void WebSchedulerImpl::postNonNestableIdleTask( | 53 void WebSchedulerImpl::postNonNestableIdleTask( |
| 54 const blink::WebTraceLocation& web_location, | 54 const blink::WebTraceLocation& web_location, |
| 55 blink::WebScheduler::IdleTask* task) { | 55 blink::WebThread::IdleTask* task) { |
| 56 DCHECK(idle_task_runner_); | 56 DCHECK(idle_task_runner_); |
| 57 scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); | 57 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); |
| 58 tracked_objects::Location location(web_location.functionName(), | 58 tracked_objects::Location location(web_location.functionName(), |
| 59 web_location.fileName(), -1, nullptr); | 59 web_location.fileName(), -1, nullptr); |
| 60 idle_task_runner_->PostNonNestableIdleTask( | 60 idle_task_runner_->PostNonNestableIdleTask( |
| 61 location, | 61 location, |
| 62 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); | 62 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void WebSchedulerImpl::postIdleTaskAfterWakeup( | 65 void WebSchedulerImpl::postIdleTaskAfterWakeup( |
| 66 const blink::WebTraceLocation& web_location, | 66 const blink::WebTraceLocation& web_location, |
| 67 blink::WebScheduler::IdleTask* task) { | 67 blink::WebThread::IdleTask* task) { |
| 68 DCHECK(idle_task_runner_); | 68 DCHECK(idle_task_runner_); |
| 69 scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); | 69 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); |
| 70 tracked_objects::Location location(web_location.functionName(), | 70 tracked_objects::Location location(web_location.functionName(), |
| 71 web_location.fileName(), -1, nullptr); | 71 web_location.fileName(), -1, nullptr); |
| 72 idle_task_runner_->PostIdleTaskAfterWakeup( | 72 idle_task_runner_->PostIdleTaskAfterWakeup( |
| 73 location, | 73 location, |
| 74 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); | 74 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void WebSchedulerImpl::postLoadingTask( | 77 void WebSchedulerImpl::postLoadingTask( |
| 78 const blink::WebTraceLocation& web_location, blink::WebThread::Task* task) { | 78 const blink::WebTraceLocation& web_location, blink::WebThread::Task* task) { |
| 79 DCHECK(loading_task_runner_); | 79 DCHECK(loading_task_runner_); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 scoped_ptr<blink::WebThread::Task> scoped_task(task); | 93 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| 94 tracked_objects::Location location(web_location.functionName(), | 94 tracked_objects::Location location(web_location.functionName(), |
| 95 web_location.fileName(), -1, nullptr); | 95 web_location.fileName(), -1, nullptr); |
| 96 timer_task_runner_->PostDelayedTask( | 96 timer_task_runner_->PostDelayedTask( |
| 97 location, | 97 location, |
| 98 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), | 98 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), |
| 99 base::TimeDelta::FromMilliseconds(delayMs)); | 99 base::TimeDelta::FromMilliseconds(delayMs)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace content | 102 } // namespace content |
| OLD | NEW |