// Copyright 2015 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_TASK_QUEUE_THROTTLER_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_TASK_QUEUE_THROTTLER_H_ #include <optional> #include "base/memory/raw_ptr.h" #include "base/task/sequence_manager/task_queue.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/scheduler/common/tracing_helper.h" #include "third_party/blink/renderer/platform/wtf/hash_set.h" #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" namespace base { class LazyNow; namespace trace_event { class TracedValue; } } // namespace base namespace blink { namespace scheduler { class BudgetPool; // kNewTasksOnly prevents new tasks from running (old tasks can run normally), // kAllTasks block queue completely. // kAllTasks-type block always blocks the queue completely. // kNewTasksOnly-type block does nothing when queue is already blocked by // kAllTasks, and overrides previous kNewTasksOnly block if any, which may // unblock some tasks. enum class QueueBlockType { … }; // The job of the TaskQueueThrottler is to control when tasks posted on a // throttled queue get to run. // // This is done by inserting a fence in the queue when it cannot run and // removing or updating the fence when the next allowed wake up time is reached. // // TaskQueueThrottler assumes that it's the only system inserting fences in // its associated TaskQueue. // // There may be more than one system that wishes to throttle a queue (e.g. // renderer suspension vs tab level suspension) so the TaskQueueThrottler keeps // a count of the number of systems that wish the queue to be throttled. See // IncreaseThrottleRefCount & DecreaseThrottleRefCount. // // This class is main-thread only. class PLATFORM_EXPORT TaskQueueThrottler final : public base::sequence_manager::TaskQueue::Throttler { … }; } // namespace scheduler } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_THROTTLING_TASK_QUEUE_THROTTLER_H_