OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include "WebCommon.h" | 28 #include "WebCommon.h" |
29 #include <stdint.h> | 29 #include <stdint.h> |
30 | 30 |
31 #ifdef INSIDE_BLINK | 31 #ifdef INSIDE_BLINK |
32 #include "wtf/Functional.h" | 32 #include "wtf/Functional.h" |
33 #endif | 33 #endif |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 class WebScheduler; | 36 class WebScheduler; |
| 37 class WebTaskRunner; |
37 class WebTraceLocation; | 38 class WebTraceLocation; |
38 | 39 |
39 // Always an integer value. | 40 // Always an integer value. |
40 typedef uintptr_t PlatformThreadId; | 41 typedef uintptr_t PlatformThreadId; |
41 | 42 |
42 // Provides an interface to an embedder-defined thread implementation. | 43 // Provides an interface to an embedder-defined thread implementation. |
43 // | 44 // |
44 // Deleting the thread blocks until all pending, non-delayed tasks have been | 45 // Deleting the thread blocks until all pending, non-delayed tasks have been |
45 // run. | 46 // run. |
46 class BLINK_PLATFORM_EXPORT WebThread { | 47 class BLINK_PLATFORM_EXPORT WebThread { |
(...skipping 15 matching lines...) Expand all Loading... |
62 class BLINK_PLATFORM_EXPORT TaskObserver { | 63 class BLINK_PLATFORM_EXPORT TaskObserver { |
63 public: | 64 public: |
64 virtual ~TaskObserver() { } | 65 virtual ~TaskObserver() { } |
65 virtual void willProcessTask() = 0; | 66 virtual void willProcessTask() = 0; |
66 virtual void didProcessTask() = 0; | 67 virtual void didProcessTask() = 0; |
67 }; | 68 }; |
68 | 69 |
69 // postTask() and postDelayedTask() take ownership of the passed Task | 70 // postTask() and postDelayedTask() take ownership of the passed Task |
70 // object. It is safe to invoke postTask() and postDelayedTask() from any | 71 // object. It is safe to invoke postTask() and postDelayedTask() from any |
71 // thread. | 72 // thread. |
| 73 // TODO(alexclarke): Remove postTask & postDelayedTask. |
72 virtual void postTask(const WebTraceLocation&, Task*) = 0; | 74 virtual void postTask(const WebTraceLocation&, Task*) = 0; |
73 virtual void postDelayedTask(const WebTraceLocation&, Task*, long long delay
Ms) = 0; | 75 virtual void postDelayedTask(const WebTraceLocation&, Task*, long long delay
Ms) = 0; |
74 | 76 |
| 77 // Returns a WebTaskRunner bound to the underlying scheduler's default task
queue. |
| 78 virtual WebTaskRunner* taskRunner() { return nullptr; } |
| 79 |
75 virtual bool isCurrentThread() const = 0; | 80 virtual bool isCurrentThread() const = 0; |
76 virtual PlatformThreadId threadId() const { return 0; } | 81 virtual PlatformThreadId threadId() const { return 0; } |
77 | 82 |
78 virtual void addTaskObserver(TaskObserver*) { } | 83 virtual void addTaskObserver(TaskObserver*) { } |
79 virtual void removeTaskObserver(TaskObserver*) { } | 84 virtual void removeTaskObserver(TaskObserver*) { } |
80 | 85 |
81 // Returns the scheduler associated with the thread. | 86 // Returns the scheduler associated with the thread. |
82 virtual WebScheduler* scheduler() const = 0; | 87 virtual WebScheduler* scheduler() const = 0; |
83 | 88 |
84 virtual ~WebThread() { } | 89 virtual ~WebThread() { } |
85 | 90 |
86 #ifdef INSIDE_BLINK | 91 #ifdef INSIDE_BLINK |
87 // Helpers for posting bound functions as tasks. | 92 // Helpers for posting bound functions as tasks. |
88 void postTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>); | 93 void postTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>); |
89 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>,
long long delayMs); | 94 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>,
long long delayMs); |
90 #endif | 95 #endif |
91 }; | 96 }; |
92 | 97 |
93 } // namespace blink | 98 } // namespace blink |
94 | 99 |
95 #endif | 100 #endif |
OLD | NEW |