| 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 #include "wtf/HashTraits.h" | 10 #include "wtf/HashTraits.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 Timer, | 31 Timer, |
| 32 RemoteEvent, | 32 RemoteEvent, |
| 33 WebSocket, | 33 WebSocket, |
| 34 PostedMessage, | 34 PostedMessage, |
| 35 UnshippedPortMessage, | 35 UnshippedPortMessage, |
| 36 FileReading, | 36 FileReading, |
| 37 DatabaseAccess, | 37 DatabaseAccess, |
| 38 Presentation, | 38 Presentation, |
| 39 Sensor, | 39 Sensor, |
| 40 | 40 |
| 41 // Use MiscPlatformAPI for a task that is defined in the spec but is not yet |
| 42 // associated with any specific task runner in the spec. MiscPlatformAPI is |
| 43 // not encouraged for stable and matured APIs. The spec should define the task |
| 44 // runner explicitly. |
| 45 // The task runner may be throttled. |
| 46 MiscPlatformAPI, |
| 47 |
| 41 // Other internal tasks that cannot fit any of the above task runners | 48 // Other internal tasks that cannot fit any of the above task runners |
| 42 // can be posted here, but the usage is not encouraged. The task runner | 49 // can be posted here, but the usage is not encouraged. The task runner |
| 43 // may be throttled. | 50 // may be throttled. |
| 44 // | 51 // |
| 45 // UnspecedLoading type should be used for all tasks associated with | 52 // UnspecedLoading type should be used for all tasks associated with |
| 46 // loading page content, UnspecedTimer should be used for all other purposes. | 53 // loading page content, UnspecedTimer should be used for all other purposes. |
| 47 UnspecedTimer, | 54 UnspecedTimer, |
| 48 UnspecedLoading, | 55 UnspecedLoading, |
| 49 | 56 |
| 50 // Tasks that must not be throttled should be posted here, but the usage | 57 // Tasks that must not be throttled should be posted here, but the usage |
| (...skipping 10 matching lines...) Expand all Loading... |
| 61 static const bool emptyValueIsZero = false; | 68 static const bool emptyValueIsZero = false; |
| 62 static TaskType emptyValue() { return static_cast<TaskType>(-1); } | 69 static TaskType emptyValue() { return static_cast<TaskType>(-1); } |
| 63 static void constructDeletedValue(TaskType& slot, bool) { | 70 static void constructDeletedValue(TaskType& slot, bool) { |
| 64 slot = static_cast<TaskType>(-2); | 71 slot = static_cast<TaskType>(-2); |
| 65 } | 72 } |
| 66 static bool isDeletedValue(TaskType value) { | 73 static bool isDeletedValue(TaskType value) { |
| 67 return value == static_cast<TaskType>(-2); | 74 return value == static_cast<TaskType>(-2); |
| 68 } | 75 } |
| 69 }; | 76 }; |
| 70 | 77 |
| 78 // A set of helper functions to get a WebTaskRunner for TaskType and a context |
| 79 // object. The posted tasks are guaranteed to run in a sequence if they have the |
| 80 // same TaskType and the context objects belong to the same frame. |
| 71 class CORE_EXPORT TaskRunnerHelper final { | 81 class CORE_EXPORT TaskRunnerHelper final { |
| 72 STATIC_ONLY(TaskRunnerHelper); | 82 STATIC_ONLY(TaskRunnerHelper); |
| 73 | 83 |
| 74 public: | 84 public: |
| 75 static WebTaskRunner* get(TaskType, LocalFrame*); | 85 static WebTaskRunner* get(TaskType, LocalFrame*); |
| 76 static WebTaskRunner* get(TaskType, Document*); | 86 static WebTaskRunner* get(TaskType, Document*); |
| 77 static WebTaskRunner* get(TaskType, ExecutionContext*); | 87 static WebTaskRunner* get(TaskType, ExecutionContext*); |
| 78 static WebTaskRunner* get(TaskType, ScriptState*); | 88 static WebTaskRunner* get(TaskType, ScriptState*); |
| 79 }; | 89 }; |
| 80 | 90 |
| 81 } // namespace blink | 91 } // namespace blink |
| 82 | 92 |
| 83 #endif | 93 #endif |
| OLD | NEW |