blob: e958cf6f23bd736c8a1f48978588cb9fcb093d76 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2018 The Chromium Authors
Leszek Swirski2987cc82018-11-05 15:19:282// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BASE_TASK_TASK_FEATURES_H_
6#define BASE_TASK_TASK_FEATURES_H_
7
8#include "base/base_export.h"
Anthony Vallee-Dubois9dbbbda32022-08-26 01:25:319#include "base/feature_list.h"
Etienne Pierre-Dorayd6b575b22018-11-21 19:32:2910#include "base/metrics/field_trial_params.h"
Aditya Keerthia41eda52019-04-01 15:03:2511#include "build/build_config.h"
Leszek Swirski2987cc82018-11-05 15:19:2812
13namespace base {
14
Zhibo Wangf8950ab62022-12-09 05:33:4215// Under this feature, a utility_thread_group will be created for
16// running USER_VISIBLE tasks.
17BASE_EXPORT BASE_DECLARE_FEATURE(kUseUtilityThreadGroup);
18
Etienne Pierre-doraya8792732022-02-05 02:27:2519// Under this feature, a non-zero leeway is added to delayed tasks. Along with
20// DelayPolicy, this affects the time at which a delayed task runs.
Daniel Cheng0fff5c232022-09-21 17:43:3421BASE_EXPORT BASE_DECLARE_FEATURE(kAddTaskLeewayFeature);
Etienne Pierre-dorayd5cdda492023-07-05 18:20:1422#if BUILDFLAG(IS_WIN)
23constexpr TimeDelta kDefaultLeeway = Milliseconds(16);
24#else
Jiahe Zhang07cf33132022-08-09 09:42:4925constexpr TimeDelta kDefaultLeeway = Milliseconds(8);
Etienne Pierre-dorayd5cdda492023-07-05 18:20:1426#endif // #if !BUILDFLAG(IS_WIN)
Takashi Toyoshimacff0ce62025-01-17 14:32:1227BASE_EXPORT BASE_DECLARE_FEATURE_PARAM(TimeDelta, kTaskLeewayParam);
Etienne Pierre-doraya8792732022-02-05 02:27:2528
Etienne Pierre-doray77474c902023-09-27 20:23:0929// We consider that delayed tasks above |kMaxPreciseDelay| never need
30// DelayPolicy::kPrecise. The default value is slightly above 30Hz timer.
31constexpr TimeDelta kDefaultMaxPreciseDelay = Milliseconds(36);
Takashi Toyoshimacff0ce62025-01-17 14:32:1232BASE_EXPORT BASE_DECLARE_FEATURE_PARAM(TimeDelta, kMaxPreciseDelay);
Etienne Pierre-doray77474c902023-09-27 20:23:0933
Jiahe Zhang07cf33132022-08-09 09:42:4934// Under this feature, wake ups are aligned at a 8ms boundary when allowed per
Etienne Pierre-doray048472eb2022-02-07 16:24:4835// DelayPolicy.
Daniel Cheng0fff5c232022-09-21 17:43:3436BASE_EXPORT BASE_DECLARE_FEATURE(kAlignWakeUps);
Etienne Pierre-doray048472eb2022-02-07 16:24:4837
Etienne Pierre-doray1f2b04e2023-09-05 20:23:5638// Under this feature, slack is added on mac message pumps that support it when
39// allowed per DelayPolicy.
40BASE_EXPORT BASE_DECLARE_FEATURE(kTimerSlackMac);
41
Sean Maherbff1adc2024-04-10 20:33:4342// Under this feature, the Windows UI pump uses a WaitableEvent to wake itself
43// up when not in a native nested loop. It also uses different control flow,
44// calling Win32 MessagePump functions less often.
45BASE_EXPORT BASE_DECLARE_FEATURE(kUIPumpImprovementsWin);
46
Sean Maheracb46d72024-05-16 17:22:1547// Under this feature, the Android pump will call ALooper_PollOnce() rather than
48// unconditionally yielding to native to determine whether there exists native
49// work to be done before sleep.
50BASE_EXPORT BASE_DECLARE_FEATURE(kPumpFastToSleepAndroid);
51
Alex Attar9fcc01e2022-05-20 14:01:2752// Feature to run tasks by batches before pumping out messages.
Daniel Cheng0fff5c232022-09-21 17:43:3453BASE_EXPORT BASE_DECLARE_FEATURE(kRunTasksByBatches);
Alex Attar9fcc01e2022-05-20 14:01:2754
Leszek Swirski2987cc82018-11-05 15:19:28