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 #ifndef WebTaskRunner_h
6 #define WebTaskRunner_h
11 #include "wtf/Functional.h"
16 class WebTraceLocation
;
18 // The blink representation of a chromium SingleThreadTaskRunner.
19 class BLINK_PLATFORM_EXPORT WebTaskRunner
{
21 virtual ~WebTaskRunner() {}
23 class BLINK_PLATFORM_EXPORT Task
{
26 virtual void run() = 0;
29 // Schedule a task to be run on the the associated WebThread.
30 // Takes ownership of |Task|. Can be called from any thread.
31 virtual void postTask(const WebTraceLocation
&, Task
*) {}
33 // Schedule a task to be run after |delayMs| on the the associated WebThread.
34 // Takes ownership of |Task|. Can be called from any thread.
35 // TODO(alexclarke): Remove this when possible.
36 virtual void postDelayedTask(const WebTraceLocation
&, Task
*, long long delayMs
) {}
38 // Schedule a task to be run after |delayMs| on the the associated WebThread.
39 // Takes ownership of |Task|. Can be called from any thread.
40 virtual void postDelayedTask(const WebTraceLocation
&, Task
*, double delayMs
) {}
43 // Helpers for posting bound functions as tasks.
44 typedef Function
<void()> ClosureTask
;
46 void postTask(const WebTraceLocation
&, PassOwnPtr
<ClosureTask
>);
47 // TODO(alexclarke): Remove this when possible.
48 void postDelayedTask(const WebTraceLocation
&, PassOwnPtr
<ClosureTask
>, long long delayMs
);
49 void postDelayedTask(const WebTraceLocation
&, PassOwnPtr
<ClosureTask
>, double delayMs
);
55 #endif // WebTaskRunner_h