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.
6 #include "public/platform/WebScheduler.h"
8 #include "platform/Task.h"
9 #include "public/platform/WebTraceLocation.h"
10 #include "wtf/Assertions.h"
11 #include "wtf/OwnPtr.h"
17 class IdleTaskRunner
: public WebThread::IdleTask
{
18 WTF_MAKE_NONCOPYABLE(IdleTaskRunner
);
21 explicit IdleTaskRunner(PassOwnPtr
<WebScheduler::IdleTask
> task
)
26 ~IdleTaskRunner() override
30 // WebThread::IdleTask implementation.
31 void run(double deadlineSeconds
) override
33 (*m_task
)(deadlineSeconds
);
37 OwnPtr
<WebScheduler::IdleTask
> m_task
;
42 void WebScheduler::postIdleTask(const WebTraceLocation
& location
, PassOwnPtr
<IdleTask
> idleTask
)
44 postIdleTask(location
, new IdleTaskRunner(idleTask
));
47 void WebScheduler::postNonNestableIdleTask(const WebTraceLocation
& location
, PassOwnPtr
<IdleTask
> idleTask
)
49 postNonNestableIdleTask(location
, new IdleTaskRunner(idleTask
));
52 void WebScheduler::postIdleTaskAfterWakeup(const WebTraceLocation
& location
, PassOwnPtr
<IdleTask
> idleTask
)
54 postIdleTaskAfterWakeup(location
, new IdleTaskRunner(idleTask
));