OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WebTaskRunner_h | 5 #ifndef WebTaskRunner_h |
6 #define WebTaskRunner_h | 6 #define WebTaskRunner_h |
7 | 7 |
8 #include "WebCommon.h" | 8 #include "WebCommon.h" |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "public/platform/WebTraceLocation.h" | 10 #include "public/platform/WebTraceLocation.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 // Returns a clone of the WebTaskRunner. | 52 // Returns a clone of the WebTaskRunner. |
53 virtual std::unique_ptr<WebTaskRunner> clone() = 0; | 53 virtual std::unique_ptr<WebTaskRunner> clone() = 0; |
54 | 54 |
55 // Returns true if the current thread is a thread on which a task may be run. | 55 // Returns true if the current thread is a thread on which a task may be run. |
56 // Can be called from any thread. | 56 // Can be called from any thread. |
57 virtual bool runsTasksOnCurrentThread() = 0; | 57 virtual bool runsTasksOnCurrentThread() = 0; |
58 | 58 |
59 // --- | 59 // --- |
60 | 60 |
61 // Headless Chrome virtualises time for determinism and performance (fast forw
arding | 61 // Headless Chrome virtualises time for determinism and performance (fast |
62 // of timers). To make this work some parts of blink (e.g. Timers) need to use
virtual | 62 // forwarding of timers). To make this work some parts of blink (e.g. Timers) |
63 // time, however by default new code should use the normal non-virtual time AP
Is. | 63 // need to use virtual time, however by default new code should use the normal |
| 64 // non-virtual time APIs. |
64 | 65 |
65 // Returns a double which is the number of seconds since epoch (Jan 1, 1970). | 66 // Returns a double which is the number of seconds since epoch (Jan 1, 1970). |
66 // This may represent either the real time, or a virtual time depending on | 67 // This may represent either the real time, or a virtual time depending on |
67 // whether or not the WebTaskRunner is associated with a virtual time domain o
r a | 68 // whether or not the WebTaskRunner is associated with a virtual time domain |
68 // real time domain. | 69 // or a real time domain. |
69 virtual double virtualTimeSeconds() const = 0; | 70 virtual double virtualTimeSeconds() const = 0; |
70 | 71 |
71 // Returns a microsecond resolution platform dependant time source. | 72 // Returns a microsecond resolution platform dependant time source. |
72 // This may represent either the real time, or a virtual time depending on | 73 // This may represent either the real time, or a virtual time depending on |
73 // whether or not the WebTaskRunner is associated with a virtual time domain o
r a | 74 // whether or not the WebTaskRunner is associated with a virtual time domain |
74 // real time domain. | 75 // or a real time domain. |
75 virtual double monotonicallyIncreasingVirtualTimeSeconds() const = 0; | 76 virtual double monotonicallyIncreasingVirtualTimeSeconds() const = 0; |
76 | 77 |
77 // Returns the underlying task runner object. | 78 // Returns the underlying task runner object. |
78 virtual SingleThreadTaskRunner* toSingleThreadTaskRunner() = 0; | 79 virtual SingleThreadTaskRunner* toSingleThreadTaskRunner() = 0; |
79 | 80 |
80 #ifdef INSIDE_BLINK | 81 #ifdef INSIDE_BLINK |
81 // Helpers for posting bound functions as tasks. | 82 // Helpers for posting bound functions as tasks. |
82 | 83 |
83 // For cross-thread posting. Can be called from any thread. | 84 // For cross-thread posting. Can be called from any thread. |
84 void postTask(const WebTraceLocation&, std::unique_ptr<CrossThreadClosure>); | 85 void postTask(const WebTraceLocation&, std::unique_ptr<CrossThreadClosure>); |
85 void postDelayedTask(const WebTraceLocation&, | 86 void postDelayedTask(const WebTraceLocation&, |
86 std::unique_ptr<CrossThreadClosure>, | 87 std::unique_ptr<CrossThreadClosure>, |
87 long long delayMs); | 88 long long delayMs); |
88 | 89 |
89 // For same-thread posting. Must be called from the associated WebThread. | 90 // For same-thread posting. Must be called from the associated WebThread. |
90 void postTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>); | 91 void postTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>); |
91 void postDelayedTask(const WebTraceLocation&, | 92 void postDelayedTask(const WebTraceLocation&, |
92 std::unique_ptr<WTF::Closure>, | 93 std::unique_ptr<WTF::Closure>, |
93 long long delayMs); | 94 long long delayMs); |
94 #endif | 95 #endif |
95 }; | 96 }; |
96 | 97 |
97 } // namespace blink | 98 } // namespace blink |
98 | 99 |
99 #endif // WebTaskRunner_h | 100 #endif // WebTaskRunner_h |
OLD | NEW |