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 "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "public/platform/WebCommon.h" | 9 #include "public/platform/WebCommon.h" |
10 #include "public/platform/WebTraceLocation.h" | 10 #include "public/platform/WebTraceLocation.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 explicit TaskHandle(RefPtr<Runner>); | 54 explicit TaskHandle(RefPtr<Runner>); |
55 RefPtr<Runner> m_runner; | 55 RefPtr<Runner> m_runner; |
56 }; | 56 }; |
57 | 57 |
58 // The blink representation of a chromium SingleThreadTaskRunner. | 58 // The blink representation of a chromium SingleThreadTaskRunner. |
59 class BLINK_PLATFORM_EXPORT WebTaskRunner { | 59 class BLINK_PLATFORM_EXPORT WebTaskRunner { |
60 public: | 60 public: |
61 virtual ~WebTaskRunner() {} | 61 virtual ~WebTaskRunner() {} |
62 | 62 |
63 class BLINK_PLATFORM_EXPORT Task { | |
64 public: | |
65 virtual ~Task() {} | |
66 virtual void run() = 0; | |
67 }; | |
68 | |
69 // Schedule a task to be run on the the associated WebThread. | |
70 // Takes ownership of |Task|. Can be called from any thread. | |
71 virtual void postTask(const WebTraceLocation&, Task*) = 0; | |
72 | |
73 // Schedule a task to be run after |delayMs| on the the associated WebThread. | |
74 // Takes ownership of |Task|. Can be called from any thread. | |
75 virtual void postDelayedTask(const WebTraceLocation&, | |
76 Task*, | |
77 double delayMs) = 0; | |
78 | |
79 // Schedule a task to be run after |delayMs| on the the associated WebThread. | 63 // Schedule a task to be run after |delayMs| on the the associated WebThread. |
80 // Can be called from any thread. | 64 // Can be called from any thread. |
81 virtual void postDelayedTask(const WebTraceLocation&, | 65 virtual void postDelayedTask(const WebTraceLocation&, |
82 const base::Closure&, | 66 const base::Closure&, |
83 double delayMs) = 0; | 67 double delayMs) = 0; |
84 | 68 |
85 // Returns a clone of the WebTaskRunner. | 69 // Returns a clone of the WebTaskRunner. |
86 virtual std::unique_ptr<WebTaskRunner> clone() = 0; | 70 virtual std::unique_ptr<WebTaskRunner> clone() = 0; |
87 | 71 |
88 // Returns true if the current thread is a thread on which a task may be run. | 72 // Returns true if the current thread is a thread on which a task may be run. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 postCancellableTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>); | 115 postCancellableTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>); |
132 WARN_UNUSED_RESULT TaskHandle | 116 WARN_UNUSED_RESULT TaskHandle |
133 postDelayedCancellableTask(const WebTraceLocation&, | 117 postDelayedCancellableTask(const WebTraceLocation&, |
134 std::unique_ptr<WTF::Closure>, | 118 std::unique_ptr<WTF::Closure>, |
135 long long delayMs); | 119 long long delayMs); |
136 }; | 120 }; |
137 | 121 |
138 } // namespace blink | 122 } // namespace blink |
139 | 123 |
140 #endif // WebTaskRunner_h | 124 #endif // WebTaskRunner_h |
OLD | NEW |