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.
4
5#include "config.h"
6
7#include "public/platform/WebSchedulerProxy.h"
8
9#include "platform/TraceLocation.h"
10#include "platform/scheduler/Scheduler.h"
11#include "public/platform/WebTraceLocation.h"
12#include "wtf/Assertions.h"
13#include "wtf/PassOwnPtr.h"
14
15namespace blink {
16namespace {
17
18void runTask(PassOwnPtr<WebThread::Task> task)
19{
20    task->run();
21}
22
23} // namespace
24
25WebSchedulerProxy WebSchedulerProxy::create()
26{
27    return WebSchedulerProxy();
28}
29
30WebSchedulerProxy::WebSchedulerProxy()
31    : m_scheduler(Scheduler::shared())
32{
33    ASSERT(m_scheduler);
34}
35
36WebSchedulerProxy::~WebSchedulerProxy()
37{
38}
39
40void WebSchedulerProxy::postInputTask(const WebTraceLocation& webLocation, WebThread::Task* task)
41{
42    TraceLocation location(webLocation.functionName(), webLocation.fileName());
43    m_scheduler->postInputTask(location, bind(&runTask, adoptPtr(task)));
44}
45
46void WebSchedulerProxy::postCompositorTask(const WebTraceLocation& webLocation, WebThread::Task* task)
47{
48    TraceLocation location(webLocation.functionName(), webLocation.fileName());
49    m_scheduler->postCompositorTask(location, bind(&runTask, adoptPtr(task)));
50}
51
52void WebSchedulerProxy::postIpcTask(const WebTraceLocation& webLocation, WebThread::Task* task)
53{
54    TraceLocation location(webLocation.functionName(), webLocation.fileName());
55    m_scheduler->postIpcTask(location, bind(&runTask, adoptPtr(task)));
56}
57
58void WebSchedulerProxy::didReceiveInputEvent()
59{
60    m_scheduler->didReceiveInputEvent();
61}
62
63} // namespace blink
64