1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_TASK_TYPE_H_ 6 #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_TASK_TYPE_H_ 7 8 namespace blink { 9 10 // A list of task sources known to Blink according to the spec. 11 // This enum is used for a histogram and it should not be re-numbered. 12 // 13 // For the task type usage guideline, see https://bit.ly/2vMAsQ4 14 // 15 // When a new task type is created: 16 // * use kCount value as a new value, 17 // * update tools/metrics/histograms/enums.xml, 18 // * update TaskTypes.md 19 enum class TaskType : unsigned char { 20 /////////////////////////////////////// 21 // Speced tasks should use one of the following task types 22 /////////////////////////////////////// 23 24 // Speced tasks and related internal tasks should be posted to one of 25 // the following task runners. These task runners may be throttled. 26 27 // This value is used as a default value in cases where TaskType 28 // isn't supported yet. Don't use outside platform/scheduler code. 29 kDeprecatedNone = 0, 30 31 // https://html.spec.whatwg.org/multipage/webappapis.html#generic-task-sources 32 // 33 // This task source is used for features that react to DOM manipulations, such 34 // as things that happen in a non-blocking fashion when an element is inserted 35 // into the document. 36 kDOMManipulation = 1, 37 // This task source is used for features that react to user interaction, for 38 // example keyboard or mouse input. Events sent in response to user input 39 // (e.g. click events) must be fired using tasks queued with the user 40 // interaction task source. 41 kUserInteraction = 2, 42 // TODO(altimin) Fix the networking task source related namings once it is 43 // clear how 44 // all loading tasks are annotated. 45 // This task source is used for features that trigger in response to network 46 // activity. 47 kNetworking = 3, 48 // This is a part of Networking task source used to annotate tasks which are 49 // posted from the loading stack (i.e. WebURLLoader). 50 kNetworkingWithURLLoaderAnnotation = 50, 51 // This is a part of Networking task that should not be frozen when a page is 52 // frozen. 53 kNetworkingUnfreezable = 75, 54 // This task source is used for control messages between kNetworking tasks. 55 kNetworkingControl = 4, 56 // This task source is used to queue calls to history.back() and similar APIs. 57 kHistoryTraversal = 5, 58 59 // https://html.spec.whatwg.org/multipage/embedded-content.html#the-embed-element 60 // This task source is used for the embed element setup steps. 61 kEmbed = 6, 62 63 // https://html.spec.whatwg.org/multipage/embedded-content.html#media-elements 64 // This task source is used for all tasks queued in the [Media elements] 65 // section and subsections of the spec unless explicitly specified otherwise. 66 kMediaElementEvent = 7, 67 68 // https://html.spec.whatwg.org/multipage/scripting.html#the-canvas-element 69 // This task source is used to invoke the result callback of 70 // HTMLCanvasElement.toBlob(). 71 kCanvasBlobSerialization = 8, 72 73 // https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model 74 // This task source is used when an algorithm requires a microtask to be 75 // queued. 76 kMicrotask = 9, 77 78 // https://html.spec.whatwg.org/multipage/webappapis.html#timers 79 // For tasks queued by setTimeout() or setInterval(). 80 // 81 // Task nesting level is < 5 and timeout is zero. 82 kJavascriptTimerImmediate = 72, 83 // Task nesting level is < 5 and timeout is > 0. 84 kJavascriptTimerDelayedLowNesting = 73, 85 // Task nesting level is >= 5. 86 kJavascriptTimerDelayedHighNesting = 10, 87 // Note: The timeout is increased to be at least 4ms when the task nesting 88 // level is >= 5. Therefore, the timeout is necessarily > 0 for 89 // kJavascriptTimerDelayedHighNesting. 90 91 // https://html.spec.whatwg.org/multipage/comms.html#sse-processing-model 92 // This task source is used for any tasks that are queued by EventSource 93 // objects. 94 kRemoteEvent = 11, 95 96 // https://html.spec.whatwg.org/multipage/comms.html#feedback-from-the-protocol 97 // The task source for all tasks queued in the [WebSocket] section of the 98 // spec. 99 kWebSocket = 12, 100 101 // https://html.spec.whatwg.org/multipage/comms.html#web-messaging 102 // This task source is used for the tasks in cross-document messaging. 103 kPostedMessage = 13, 104 105 // https://html.spec.whatwg.org/multipage/comms.html#message-ports 106 kUnshippedPortMessage = 14, 107 108 // https://www.w3.org/TR/FileAPI/#blobreader-task-source 109 // This task source is used for all tasks queued in the FileAPI spec to read 110 // byte sequences associated with Blob and File objects. 111 kFileReading = 15, 112 113 // https://www.w3.org/TR/IndexedDB/#request-api 114 kDatabaseAccess = 16, 115 116 // https://w3c.github.io/presentation-api/#common-idioms 117 // This task source is used for all tasks in the Presentation API spec. 118 kPresentation = 17, 119 120 // https://www.w3.org/TR/2016/WD-generic-sensor-20160830/#sensor-task-source 121 // This task source is used for all tasks in the Sensor API spec. 122 kSensor = 18, 123 124 // https://w3c.github.io/performance-timeline/#performance-timeline 125 kPerformanceTimeline = 19, 126 127 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15 128 // This task source is used for all tasks in the WebGL spec. 129 kWebGL = 20, 130 131 // https://www.w3.org/TR/requestidlecallback/#start-an-event-loop-s-idle-period 132 kIdleTask = 21, 133 134 // Use MiscPlatformAPI for a task that is defined in the spec but is not yet 135 // associated with any specific task runner in the spec. MiscPlatformAPI is 136 // not encouraged for stable and matured APIs. The spec should define the task 137 // runner explicitly. 138 // The task runner may be throttled. 139 kMiscPlatformAPI = 22, 140 141 // Tasks used for DedicatedWorker's requestAnimationFrame. 142 kWorkerAnimation = 51, 143 144 // Obsolete. 145 // kExperimentalWebSchedulingUserInteraction = 53, 146 // kExperimentalWebSchedulingBestEffort = 54, 147 148 // https://drafts.csswg.org/css-font-loading/#task-source 149 kFontLoading = 56, 150 151 // https://w3c.github.io/manifest/#dfn-application-life-cycle-task-source 152 kApplicationLifeCycle = 57, 153 154 // https://wicg.github.io/background-fetch/#infrastructure 155 kBackgroundFetch = 58, 156 157 // https://www.w3.org/TR/permissions/ 158 kPermission = 59, 159 160 // https://w3c.github.io/ServiceWorker/#dfn-client-message-queue 161 kServiceWorkerClientMessage = 60, 162 163 // https://wicg.github.io/web-locks/#web-locks-tasks-source 164 kWebLocks = 66, 165 166 /////////////////////////////////////// 167 // Not-speced tasks should use one of the following task types 168 /////////////////////////////////////// 169 170 // The default task type. The task may be throttled or paused. 171 kInternalDefault = 23, 172 173 // Tasks used for all tasks associated with loading page content. 174 kInternalLoading = 24, 175 176 // Tasks for tests or mock objects. 177 kInternalTest = 26, 178 179 // Tasks that are posting back the result from the WebCrypto task runner to 180 // the Blink thread that initiated the call and holds the Promise. Tasks with 181 // this type are posted by: 182 // * //components/webcrypto 183 kInternalWebCrypto = 27, 184 185 // Tasks to execute media-related things like logging or playback. Tasks with 186 // this type are mainly posted by: 187 // * //content/renderer/media 188 // * //media 189 kInternalMedia = 29, 190 191 // Tasks to execute things for real-time media processing like recording. If a 192 // task touches MediaStreamTracks, associated sources/sinks, and Web Audio, 193 // this task type should be used. 194 // Tasks with this type are mainly posted by: 195 // * //content/renderer/media 196 // * //media 197 // * blink/renderer/modules/webaudio 198 // * blink/public/platform/audio 199 kInternalMediaRealTime = 30, 200 201 // Tasks related to user interaction like clicking or inputting texts. 202 kInternalUserInteraction = 32, 203 204 // Tasks related to the inspector. 205 kInternalInspector = 33, 206 207 // Obsolete. 208 // kInternalWorker = 36, 209 210 // Translation task that freezes when the frame is not visible. 211 kInternalTranslation = 55, 212 213 // Tasks used at IntersectionObserver. 214 kInternalIntersectionObserver = 44, 215 216 // Task used for ContentCapture. 217 kInternalContentCapture = 61, 218 219 // Navigation tasks and tasks which have to run in order with them, including 220 // legacy IPCs and channel associated interfaces. 221 // Note that the ordering between tasks related to different frames is not 222 // always guaranteed - tasks belonging to different frames can be reordered 223 // when one of the frames is frozen. 224 // Note: all AssociatedRemotes/AssociatedReceivers should use this task type. 225 kInternalNavigationAssociated = 63, 226 227 // Tasks which should run when the frame is frozen, but otherwise should run 228 // in order with other legacy IPC and channel-associated interfaces. 229 // Only tasks related to unfreezing itself should run here, the majority of 230 // the tasks 231 // should use kInternalNavigationAssociated instead. 232 kInternalNavigationAssociatedUnfreezable = 64, 233 234 // Task used to split a script loading task for cooperative scheduling 235 kInternalContinueScriptLoading = 65, 236 237 // Experimental tasks types used for main thread scheduling postTask API 238 // (https://github.com/WICG/main-thread-scheduling). 239 // These task types should not be passed directly to 240 // FrameScheduler::GetTaskRunner(); they are used indirectly by 241 // WebSchedulingTaskQueues. 242 kExperimentalWebScheduling = 67, 243 244 // Tasks used to control frame lifecycle - they should run even when the frame 245 // is frozen. 246 kInternalFrameLifecycleControl = 68, 247 248 // Tasks used for find-in-page. 249 kInternalFindInPage = 70, 250 251 // Tasks that come in on the HighPriorityLocalFrame interface. 252 kInternalHighPriorityLocalFrame = 71, 253 254 /////////////////////////////////////// 255 // The following task types are only for thread-local queues. 256 /////////////////////////////////////// 257 258 // The following task types are internal-use only, escpecially for annotations 259 // like UMA of per-thread task queues. Do not specify these task types when to 260 // get a task queue/runner. 261 262 kMainThreadTaskQueueV8 = 37, 263 kMainThreadTaskQueueCompositor = 38, 264 kMainThreadTaskQueueDefault = 39, 265 kMainThreadTaskQueueInput = 40, 266 kMainThreadTaskQueueIdle = 41, 267 // Removed: 268 // kMainThreadTaskQueueIPC = 42, 269 kMainThreadTaskQueueControl = 43, 270 // Removed: 271 // kMainThreadTaskQueueCleanup = 52, 272 kMainThreadTaskQueueMemoryPurge = 62, 273 kMainThreadTaskQueueNonWaking = 69, 274 kMainThreadTaskQueueIPCTracking = 74, 275 kCompositorThreadTaskQueueDefault = 45, 276 kCompositorThreadTaskQueueInput = 49, 277 kWorkerThreadTaskQueueDefault = 46, 278 kWorkerThreadTaskQueueV8 = 47, 279 kWorkerThreadTaskQueueCompositor = 48, 280 281 kCount = 76, 282 }; 283 284 } // namespace blink 285 286 #endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_TASK_TYPE_H_ 287