| 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 10 matching lines...) Expand all Loading... |
| 21 virtual ~WebTaskRunner() {} | 21 virtual ~WebTaskRunner() {} |
| 22 | 22 |
| 23 class BLINK_PLATFORM_EXPORT Task { | 23 class BLINK_PLATFORM_EXPORT Task { |
| 24 public: | 24 public: |
| 25 virtual ~Task() { } | 25 virtual ~Task() { } |
| 26 virtual void run() = 0; | 26 virtual void run() = 0; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 // Schedule a task to be run on the the associated WebThread. | 29 // Schedule a task to be run on the the associated WebThread. |
| 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*) {} |
| 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)
{} |
| 36 | |
| 37 // Returns a clone of the WebTaskRunner. | |
| 38 virtual WebTaskRunner* clone() = 0; | |
| 39 | 36 |
| 40 #ifdef INSIDE_BLINK | 37 #ifdef INSIDE_BLINK |
| 41 // Helpers for posting bound functions as tasks. | 38 // Helpers for posting bound functions as tasks. |
| 42 typedef Function<void()> ClosureTask; | 39 typedef Function<void()> ClosureTask; |
| 43 | 40 |
| 44 void postTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>); | 41 void postTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>); |
| 45 // TODO(alexclarke): Remove this when possible. | 42 // TODO(alexclarke): Remove this when possible. |
| 46 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>, long
long delayMs); | 43 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>, long
long delayMs); |
| 47 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>, doubl
e delayMs); | 44 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ClosureTask>, doubl
e delayMs); |
| 48 #endif | 45 #endif |
| 49 }; | 46 }; |
| 50 | 47 |
| 51 } // namespace blink | 48 } // namespace blink |
| 52 | 49 |
| 53 #endif // WebTaskRunner_h | 50 #endif // WebTaskRunner_h |
| OLD | NEW |