| 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" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 WebSchedulerImpl::WebSchedulerImpl(RendererScheduler* renderer_scheduler) | 14 WebSchedulerImpl::WebSchedulerImpl(RendererScheduler* renderer_scheduler) |
| 15 : renderer_scheduler_(renderer_scheduler), | 15 : renderer_scheduler_(renderer_scheduler), |
| 16 idle_task_runner_(renderer_scheduler_->IdleTaskRunner()), | 16 idle_task_runner_(renderer_scheduler_->IdleTaskRunner()), |
| 17 loading_task_runner_(renderer_scheduler_->LoadingTaskRunner()) { | 17 loading_task_runner_(renderer_scheduler_->LoadingTaskRunner()), |
| 18 timer_task_runner_(renderer_scheduler_->TimerTaskRunner()) { |
| 18 } | 19 } |
| 19 | 20 |
| 20 WebSchedulerImpl::~WebSchedulerImpl() { | 21 WebSchedulerImpl::~WebSchedulerImpl() { |
| 21 } | 22 } |
| 22 | 23 |
| 23 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { | 24 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { |
| 24 return renderer_scheduler_->ShouldYieldForHighPriorityWork(); | 25 return renderer_scheduler_->ShouldYieldForHighPriorityWork(); |
| 25 } | 26 } |
| 26 | 27 |
| 27 void WebSchedulerImpl::runIdleTask( | 28 void WebSchedulerImpl::runIdleTask( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 const blink::WebTraceLocation& web_location, blink::WebThread::Task* task) { | 62 const blink::WebTraceLocation& web_location, blink::WebThread::Task* task) { |
| 62 DCHECK(loading_task_runner_); | 63 DCHECK(loading_task_runner_); |
| 63 scoped_ptr<blink::WebThread::Task> scoped_task(task); | 64 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| 64 tracked_objects::Location location(web_location.functionName(), | 65 tracked_objects::Location location(web_location.functionName(), |
| 65 web_location.fileName(), -1, nullptr); | 66 web_location.fileName(), -1, nullptr); |
| 66 loading_task_runner_->PostTask( | 67 loading_task_runner_->PostTask( |
| 67 location, | 68 location, |
| 68 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task))); | 69 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task))); |
| 69 } | 70 } |
| 70 | 71 |
| 72 void WebSchedulerImpl::postTimerTask( |
| 73 const blink::WebTraceLocation& web_location, |
| 74 blink::WebThread::Task* task, |
| 75 long long delayMs) { |
| 76 DCHECK(timer_task_runner_); |
| 77 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| 78 tracked_objects::Location location(web_location.functionName(), |
| 79 web_location.fileName(), -1, nullptr); |
| 80 timer_task_runner_->PostDelayedTask( |
| 81 location, |
| 82 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), |
| 83 base::TimeDelta::FromMilliseconds(delayMs)); |
| 84 } |
| 85 |
| 71 void WebSchedulerImpl::shutdown() { | 86 void WebSchedulerImpl::shutdown() { |
| 72 idle_task_runner_ = nullptr; | 87 idle_task_runner_ = nullptr; |
| 73 loading_task_runner_ = nullptr; | 88 loading_task_runner_ = nullptr; |
| 74 return renderer_scheduler_->Shutdown(); | 89 return renderer_scheduler_->Shutdown(); |
| 75 } | 90 } |
| 76 | 91 |
| 77 } // namespace content | 92 } // namespace content |
| OLD | NEW |