| 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/worker_scheduler.h" | 9 #include "components/scheduler/child/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 scheduler { | 12 namespace scheduler { |
| 13 | 13 |
| 14 WebSchedulerImpl::WebSchedulerImpl( | 14 WebSchedulerImpl::WebSchedulerImpl( |
| 15 ChildScheduler* child_scheduler, | 15 ChildScheduler* child_scheduler, |
| 16 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner, | 16 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner, |
| 17 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, | 17 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, |
| 18 scoped_refptr<base::SingleThreadTaskRunner> timer_task_runner) | 18 scoped_refptr<base::SingleThreadTaskRunner> timer_task_runner, |
| 19 scoped_refptr<base::SingleThreadTaskRunner> shutdown_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 shutdown_task_runner_(shutdown_task_runner) { |
| 23 } | 25 } |
| 24 | 26 |
| 25 WebSchedulerImpl::~WebSchedulerImpl() { | 27 WebSchedulerImpl::~WebSchedulerImpl() { |
| 26 } | 28 } |
| 27 | 29 |
| 28 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { | 30 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { |
| 29 return child_scheduler_->ShouldYieldForHighPriorityWork(); | 31 return child_scheduler_->ShouldYieldForHighPriorityWork(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 bool WebSchedulerImpl::canExceedIdleDeadlineIfRequired() { | 34 bool WebSchedulerImpl::canExceedIdleDeadlineIfRequired() { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 scoped_ptr<blink::WebThread::Task> scoped_task(task); | 99 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| 98 tracked_objects::Location location(web_location.functionName(), | 100 tracked_objects::Location location(web_location.functionName(), |
| 99 web_location.fileName(), -1, nullptr); | 101 web_location.fileName(), -1, nullptr); |
| 100 // Timer tasks should not run in a nested messageloop. | 102 // Timer tasks should not run in a nested messageloop. |
| 101 timer_task_runner_->PostNonNestableDelayedTask( | 103 timer_task_runner_->PostNonNestableDelayedTask( |
| 102 location, | 104 location, |
| 103 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), | 105 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), |
| 104 base::TimeDelta::FromMilliseconds(delayMs)); | 106 base::TimeDelta::FromMilliseconds(delayMs)); |
| 105 } | 107 } |
| 106 | 108 |
| 109 void WebSchedulerImpl::postShutdownTask( |
| 110 const blink::WebTraceLocation& web_location, |
| 111 blink::WebThread::Task* task, |
| 112 long long delayMs) { |
| 113 DCHECK(shutdown_task_runner_); |
| 114 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| 115 tracked_objects::Location location(web_location.functionName(), |
| 116 web_location.fileName(), -1, nullptr); |
| 117 shutdown_task_runner_->PostDelayedTask( |
| 118 location, |
| 119 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), |
| 120 base::TimeDelta::FromMilliseconds(delayMs)); |
| 121 } |
| 122 |
| 123 void WebSchedulerImpl::preShutdown() { |
| 124 child_scheduler_->PreShutdown(); |
| 125 } |
| 126 |
| 107 } // namespace scheduler | 127 } // namespace scheduler |
| OLD | NEW |