| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 TaskRunnerHelper_h | 5 #ifndef TaskRunnerHelper_h |
| 6 #define TaskRunnerHelper_h | 6 #define TaskRunnerHelper_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class Document; | 13 class Document; |
| 14 class ExecutionContext; | 14 class ExecutionContext; |
| 15 class LocalFrame; | 15 class LocalFrame; |
| 16 class ScriptState; | 16 class ScriptState; |
| 17 class WebTaskRunner; | 17 class WebTaskRunner; |
| 18 | 18 |
| 19 enum class TaskType { |
| 20 // Speced tasks and related internal tasks should be posted to one of |
| 21 // the following task runners. These task runners may be throttled. |
| 22 DOMManipulation, |
| 23 UserInteraction, |
| 24 Networking, |
| 25 HistoryTraversal, |
| 26 Embed, |
| 27 MediaElementEvent, |
| 28 CanvasBlobSerialization, |
| 29 Microtask, |
| 30 Timer, |
| 31 RemoteEvent, |
| 32 WebSocket, |
| 33 PostedMessage, |
| 34 UnshippedPortMessage, |
| 35 |
| 36 // Other internal tasks that cannot fit any of the above task runners |
| 37 // can be posted here, but the usage is not encouraged. The task runner |
| 38 // may be throttled. |
| 39 Internal, |
| 40 |
| 41 // Tasks that must not be throttled should be posted here, but the usage |
| 42 // should be very limited. |
| 43 Unthrottled, |
| 44 }; |
| 45 |
| 19 class CORE_EXPORT TaskRunnerHelper final { | 46 class CORE_EXPORT TaskRunnerHelper final { |
| 20 STATIC_ONLY(TaskRunnerHelper); | 47 STATIC_ONLY(TaskRunnerHelper); |
| 21 public: | 48 public: |
| 49 static WebTaskRunner* get(TaskType, LocalFrame*); |
| 50 static WebTaskRunner* get(TaskType, Document*); |
| 51 static WebTaskRunner* get(TaskType, ExecutionContext*); |
| 52 static WebTaskRunner* get(TaskType, ScriptState*); |
| 53 |
| 54 // TODO(haraken): Remove the following APIs. |
| 22 static WebTaskRunner* getUnthrottledTaskRunner(LocalFrame*); | 55 static WebTaskRunner* getUnthrottledTaskRunner(LocalFrame*); |
| 23 static WebTaskRunner* getTimerTaskRunner(LocalFrame*); | 56 static WebTaskRunner* getTimerTaskRunner(LocalFrame*); |
| 24 static WebTaskRunner* getLoadingTaskRunner(LocalFrame*); | 57 static WebTaskRunner* getLoadingTaskRunner(LocalFrame*); |
| 25 static WebTaskRunner* getUnthrottledTaskRunner(Document*); | 58 static WebTaskRunner* getUnthrottledTaskRunner(Document*); |
| 26 static WebTaskRunner* getTimerTaskRunner(Document*); | 59 static WebTaskRunner* getTimerTaskRunner(Document*); |
| 27 static WebTaskRunner* getLoadingTaskRunner(Document*); | 60 static WebTaskRunner* getLoadingTaskRunner(Document*); |
| 28 static WebTaskRunner* getUnthrottledTaskRunner(ExecutionContext*); | 61 static WebTaskRunner* getUnthrottledTaskRunner(ExecutionContext*); |
| 29 static WebTaskRunner* getUnthrottledTaskRunner(ScriptState*); | 62 static WebTaskRunner* getUnthrottledTaskRunner(ScriptState*); |
| 30 }; | 63 }; |
| 31 | 64 |
| 32 } // namespace blink | 65 } // namespace blink |
| 33 | 66 |
| 34 #endif | 67 #endif |
| OLD | NEW |