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
3 // found in the LICENSE file.
5 #include "content/renderer/scheduler/web_scheduler_impl.h"
8 #include "content/renderer/scheduler/renderer_scheduler.h"
9 #include "third_party/WebKit/public/platform/WebTraceLocation.h"
13 WebSchedulerImpl::WebSchedulerImpl(RendererScheduler
* renderer_scheduler
)
14 : renderer_scheduler_(renderer_scheduler
),
15 idle_task_runner_(renderer_scheduler_
->IdleTaskRunner()) {
18 WebSchedulerImpl::~WebSchedulerImpl() {
21 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() {
22 return renderer_scheduler_
->ShouldYieldForHighPriorityWork();
25 void WebSchedulerImpl::runIdleTask(
26 scoped_ptr
<blink::WebScheduler::IdleTask
> task
,
27 base::TimeTicks deadline
) {
28 task
->run((deadline
- base::TimeTicks()).InSecondsF());
31 void WebSchedulerImpl::runTask(scoped_ptr
<blink::WebThread::Task
> task
) {
35 void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation
& web_location
,
36 blink::WebScheduler::IdleTask
* task
) {
37 scoped_ptr
<blink::WebScheduler::IdleTask
> scoped_task(task
);
38 tracked_objects::Location
location(web_location
.functionName(),
39 web_location
.fileName(), -1, nullptr);
40 idle_task_runner_
->PostIdleTask(
42 base::Bind(&WebSchedulerImpl::runIdleTask
, base::Passed(&scoped_task
)));
45 void WebSchedulerImpl::postLoadingTask(
46 const blink::WebTraceLocation
& web_location
, blink::WebThread::Task
* task
) {
47 scoped_ptr
<blink::WebThread::Task
> scoped_task(task
);
48 tracked_objects::Location
location(web_location
.functionName(),
49 web_location
.fileName(), -1, nullptr);
50 renderer_scheduler_
->LoadingTaskRunner()->PostTask(
52 base::Bind(&WebSchedulerImpl::runTask
, base::Passed(&scoped_task
)));
55 void WebSchedulerImpl::shutdown() {
56 return renderer_scheduler_
->Shutdown();
59 } // namespace content