Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / exported / WebSchedulerProxy.cpp
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
15 namespace blink {
16 namespace {
17
18 void runTask(PassOwnPtr<WebThread::Task> task)
19 {
20     task->run();
21 }
22
23 } // namespace
24
25 WebSchedulerProxy WebSchedulerProxy::create()
26 {
27     return WebSchedulerProxy();
28 }
29
30 WebSchedulerProxy::WebSchedulerProxy()
31     : m_scheduler(Scheduler::shared())
32 {
33     ASSERT(m_scheduler);
34 }
35
36 WebSchedulerProxy::~WebSchedulerProxy()
37 {
38 }
39
40 void 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
46 void 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
52 void 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
58 void WebSchedulerProxy::didReceiveInputEvent()
59 {
60     m_scheduler->didReceiveInputEvent();
61 }
62
63 } // namespace blink