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
3 // found in the LICENSE file.
5 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h"
7 #include "components/scheduler/child/task_queue.h"
8 #include "components/scheduler/child/web_task_runner_impl.h"
9 #include "components/scheduler/renderer/renderer_scheduler.h"
10 #include "components/scheduler/renderer/renderer_web_scheduler_impl.h"
11 #include "third_party/WebKit/public/platform/WebTraceLocation.h"
15 WebThreadImplForRendererScheduler::WebThreadImplForRendererScheduler(
16 RendererScheduler
* scheduler
)
17 : web_scheduler_(new RendererWebSchedulerImpl(scheduler
)),
18 task_runner_(scheduler
->DefaultTaskRunner()),
19 idle_task_runner_(scheduler
->IdleTaskRunner()),
20 scheduler_(scheduler
),
21 thread_id_(base::PlatformThread::CurrentId()),
22 web_task_runner_(new WebTaskRunnerImpl(scheduler
->DefaultTaskRunner())) {}
24 WebThreadImplForRendererScheduler::~WebThreadImplForRendererScheduler() {
27 blink::PlatformThreadId
WebThreadImplForRendererScheduler::threadId() const {
31 blink::WebScheduler
* WebThreadImplForRendererScheduler::scheduler() const {
32 return web_scheduler_
.get();
35 base::SingleThreadTaskRunner
* WebThreadImplForRendererScheduler::TaskRunner()
37 return task_runner_
.get();
40 SingleThreadIdleTaskRunner
* WebThreadImplForRendererScheduler::IdleTaskRunner()
42 return idle_task_runner_
.get();
45 blink::WebTaskRunner
* WebThreadImplForRendererScheduler::taskRunner() {
46 return web_task_runner_
.get();
49 void WebThreadImplForRendererScheduler::AddTaskObserverInternal(
50 base::MessageLoop::TaskObserver
* observer
) {
51 scheduler_
->AddTaskObserver(observer
);
54 void WebThreadImplForRendererScheduler::RemoveTaskObserverInternal(
55 base::MessageLoop::TaskObserver
* observer
) {
56 scheduler_
->RemoveTaskObserver(observer
);
59 } // namespace scheduler