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 | 9 |
10 #ifdef INSIDE_BLINK | 10 #ifdef INSIDE_BLINK |
(...skipping 19 matching lines...) Expand all Loading... |
30 // Takes ownership of |Task|. Can be called from any thread. | 30 // Takes ownership of |Task|. Can be called from any thread. |
31 virtual void postTask(const WebTraceLocation&, Task*) = 0; | 31 virtual void postTask(const WebTraceLocation&, Task*) = 0; |
32 | 32 |
33 // Schedule a task to be run after |delayMs| on the the associated WebThread
. | 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. | 34 // Takes ownership of |Task|. Can be called from any thread. |
35 virtual void postDelayedTask(const WebTraceLocation&, Task*, double delayMs)
= 0; | 35 virtual void postDelayedTask(const WebTraceLocation&, Task*, double delayMs)
= 0; |
36 | 36 |
37 // Returns a clone of the WebTaskRunner. | 37 // Returns a clone of the WebTaskRunner. |
38 virtual WebTaskRunner* clone() = 0; | 38 virtual WebTaskRunner* clone() = 0; |
39 | 39 |
40 // --- | |
41 | |
42 // Headless Chrome virtualises time for determinism and performance (fast fo
rwarding | |
43 // of timers). To make this work some parts of blink (e.g. Timers) need to u
se virtual | |
44 // time, however by default new code should use the normal non-virtual time
APIs. | |
45 | |
46 // Returns a double which is the number of seconds since epoch (Jan 1, 1970)
. | |
47 // This may represent either the real time, or a virtual time depending on | |
48 // whether or not the WebTaskRunner is associated with a virtual time domain
or a | |
49 // real time domain. | |
50 virtual double virtualTimeSeconds() const = 0; | |
51 | |
52 // Returns a microsecond resolution platform dependant time source. | |
53 // This may represent either the real time, or a virtual time depending on | |
54 // whether or not the WebTaskRunner is associated with a virtual time domain
or a | |
55 // real time domain. | |
56 virtual double monotonicallyIncreasingVirtualTimeSeconds() const = 0; | |
57 | |
58 #ifdef INSIDE_BLINK | 40 #ifdef INSIDE_BLINK |
59 // Helpers for posting bound functions as tasks. | 41 // Helpers for posting bound functions as tasks. |
60 typedef Function<void()> ClosureTask; | 42 typedef Function<void()> ClosureTask; |
61 | 43 |
62 void postTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>); | 44 void postTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>); |
63 // TODO(alexclarke): Remove this when possible. | 45 // TODO(alexclarke): Remove this when possible. |
64 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>, long
long delayMs); | 46 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>, long
long delayMs); |
65 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>, doubl
e delayMs); | 47 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>, doubl
e delayMs); |
66 | 48 |
67 PassOwnPtr<WebTaskRunner> adoptClone() | 49 PassOwnPtr<WebTaskRunner> adoptClone() |
68 { | 50 { |
69 return adoptPtr(clone()); | 51 return adoptPtr(clone()); |
70 } | 52 } |
71 #endif | 53 #endif |
72 }; | 54 }; |
73 | 55 |
74 } // namespace blink | 56 } // namespace blink |
75 | 57 |
76 #endif // WebTaskRunner_h | 58 #endif // WebTaskRunner_h |
OLD | NEW |