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 "public/platform/WebTraceLocation.h" | 9 #include "public/platform/WebTraceLocation.h" |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #ifdef INSIDE_BLINK | 12 #ifdef INSIDE_BLINK |
13 #include "wtf/Functional.h" | 13 #include "wtf/Functional.h" |
14 #endif | 14 #endif |
15 | 15 |
| 16 namespace base { |
| 17 class SingleThreadTaskRunner; |
| 18 } |
| 19 |
16 namespace blink { | 20 namespace blink { |
17 | 21 |
| 22 using SingleThreadTaskRunner = base::SingleThreadTaskRunner; |
| 23 |
18 // The blink representation of a chromium SingleThreadTaskRunner. | 24 // The blink representation of a chromium SingleThreadTaskRunner. |
19 class BLINK_PLATFORM_EXPORT WebTaskRunner { | 25 class BLINK_PLATFORM_EXPORT WebTaskRunner { |
20 public: | 26 public: |
21 virtual ~WebTaskRunner() {} | 27 virtual ~WebTaskRunner() {} |
22 | 28 |
23 class BLINK_PLATFORM_EXPORT Task { | 29 class BLINK_PLATFORM_EXPORT Task { |
24 public: | 30 public: |
25 virtual ~Task() { } | 31 virtual ~Task() { } |
26 virtual void run() = 0; | 32 virtual void run() = 0; |
27 }; | 33 }; |
(...skipping 24 matching lines...) Expand all Loading... |
52 // whether or not the WebTaskRunner is associated with a virtual time domain
or a | 58 // whether or not the WebTaskRunner is associated with a virtual time domain
or a |
53 // real time domain. | 59 // real time domain. |
54 virtual double virtualTimeSeconds() const = 0; | 60 virtual double virtualTimeSeconds() const = 0; |
55 | 61 |
56 // Returns a microsecond resolution platform dependant time source. | 62 // Returns a microsecond resolution platform dependant time source. |
57 // This may represent either the real time, or a virtual time depending on | 63 // This may represent either the real time, or a virtual time depending on |
58 // whether or not the WebTaskRunner is associated with a virtual time domain
or a | 64 // whether or not the WebTaskRunner is associated with a virtual time domain
or a |
59 // real time domain. | 65 // real time domain. |
60 virtual double monotonicallyIncreasingVirtualTimeSeconds() const = 0; | 66 virtual double monotonicallyIncreasingVirtualTimeSeconds() const = 0; |
61 | 67 |
| 68 // Returns the underlying task runner object. |
| 69 virtual SingleThreadTaskRunner* taskRunner() = 0; |
| 70 |
62 #ifdef INSIDE_BLINK | 71 #ifdef INSIDE_BLINK |
63 // Helpers for posting bound functions as tasks. | 72 // Helpers for posting bound functions as tasks. |
64 | 73 |
65 // For cross-thread posting. Can be called from any thread. | 74 // For cross-thread posting. Can be called from any thread. |
66 void postTask(const WebTraceLocation&, std::unique_ptr<CrossThreadClosure>); | 75 void postTask(const WebTraceLocation&, std::unique_ptr<CrossThreadClosure>); |
67 void postDelayedTask(const WebTraceLocation&, std::unique_ptr<CrossThreadClo
sure>, long long delayMs); | 76 void postDelayedTask(const WebTraceLocation&, std::unique_ptr<CrossThreadClo
sure>, long long delayMs); |
68 | 77 |
69 // For same-thread posting. Must be called from the associated WebThread. | 78 // For same-thread posting. Must be called from the associated WebThread. |
70 void postTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>); | 79 void postTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>); |
71 void postDelayedTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>,
long long delayMs); | 80 void postDelayedTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>,
long long delayMs); |
72 #endif | 81 #endif |
73 }; | 82 }; |
74 | 83 |
75 } // namespace blink | 84 } // namespace blink |
76 | 85 |
77 #endif // WebTaskRunner_h | 86 #endif // WebTaskRunner_h |
OLD | NEW |