| 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 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 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(scoped_ptr<blink::WebThread::IdleTask> task, |
| 33 scoped_ptr<blink::WebScheduler::IdleTask> task, | 33 base::TimeTicks deadline) { |
| 34 base::TimeTicks deadline) { | |
| 35 task->run((deadline - base::TimeTicks()).InSecondsF()); | 34 task->run((deadline - base::TimeTicks()).InSecondsF()); |
| 36 } | 35 } |
| 37 | 36 |
| 38 void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) { | 37 void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) { |
| 39 task->run(); | 38 task->run(); |
| 40 } | 39 } |
| 41 | 40 |
| 42 void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, | 41 void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, |
| 43 blink::WebScheduler::IdleTask* task) { | 42 blink::WebThread::IdleTask* task) { |
| 44 DCHECK(idle_task_runner_); | 43 DCHECK(idle_task_runner_); |
| 45 scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); | 44 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); |
| 46 tracked_objects::Location location(web_location.functionName(), | 45 tracked_objects::Location location(web_location.functionName(), |
| 47 web_location.fileName(), -1, nullptr); | 46 web_location.fileName(), -1, nullptr); |
| 48 idle_task_runner_->PostIdleTask( | 47 idle_task_runner_->PostIdleTask( |
| 49 location, | 48 location, |
| 50 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); | 49 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); |
| 51 } | 50 } |
| 52 | 51 |
| 53 void WebSchedulerImpl::postNonNestableIdleTask( | 52 void WebSchedulerImpl::postNonNestableIdleTask( |
| 54 const blink::WebTraceLocation& web_location, | 53 const blink::WebTraceLocation& web_location, |
| 55 blink::WebScheduler::IdleTask* task) { | 54 blink::WebThread::IdleTask* task) { |
| 56 DCHECK(idle_task_runner_); | 55 DCHECK(idle_task_runner_); |
| 57 scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); | 56 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); |
| 58 tracked_objects::Location location(web_location.functionName(), | 57 tracked_objects::Location location(web_location.functionName(), |
| 59 web_location.fileName(), -1, nullptr); | 58 web_location.fileName(), -1, nullptr); |
| 60 idle_task_runner_->PostNonNestableIdleTask( | 59 idle_task_runner_->PostNonNestableIdleTask( |
| 61 location, | 60 location, |
| 62 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); | 61 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); |
| 63 } | 62 } |
| 64 | 63 |
| 65 void WebSchedulerImpl::postIdleTaskAfterWakeup( | 64 void WebSchedulerImpl::postIdleTaskAfterWakeup( |
| 66 const blink::WebTraceLocation& web_location, | 65 const blink::WebTraceLocation& web_location, |
| 67 blink::WebScheduler::IdleTask* task) { | 66 blink::WebThread::IdleTask* task) { |
| 68 DCHECK(idle_task_runner_); | 67 DCHECK(idle_task_runner_); |
| 69 scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); | 68 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); |
| 70 tracked_objects::Location location(web_location.functionName(), | 69 tracked_objects::Location location(web_location.functionName(), |
| 71 web_location.fileName(), -1, nullptr); | 70 web_location.fileName(), -1, nullptr); |
| 72 idle_task_runner_->PostIdleTaskAfterWakeup( | 71 idle_task_runner_->PostIdleTaskAfterWakeup( |
| 73 location, | 72 location, |
| 74 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); | 73 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); |
| 75 } | 74 } |
| 76 | 75 |
| 77 void WebSchedulerImpl::postLoadingTask( | 76 void WebSchedulerImpl::postLoadingTask( |
| 78 const blink::WebTraceLocation& web_location, blink::WebThread::Task* task) { | 77 const blink::WebTraceLocation& web_location, blink::WebThread::Task* task) { |
| 79 DCHECK(loading_task_runner_); | 78 DCHECK(loading_task_runner_); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 scoped_ptr<blink::WebThread::Task> scoped_task(task); | 92 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| 94 tracked_objects::Location location(web_location.functionName(), | 93 tracked_objects::Location location(web_location.functionName(), |
| 95 web_location.fileName(), -1, nullptr); | 94 web_location.fileName(), -1, nullptr); |
| 96 timer_task_runner_->PostDelayedTask( | 95 timer_task_runner_->PostDelayedTask( |
| 97 location, | 96 location, |
| 98 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), | 97 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), |
| 99 base::TimeDelta::FromMilliseconds(delayMs)); | 98 base::TimeDelta::FromMilliseconds(delayMs)); |
| 100 } | 99 } |
| 101 | 100 |
| 102 } // namespace content | 101 } // namespace content |
| OLD | NEW |