// Copyright 2016 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_AUTO_ADVANCING_VIRTUAL_TIME_DOMAIN_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_AUTO_ADVANCING_VIRTUAL_TIME_DOMAIN_H_ #include "base/memory/raw_ptr.h" #include "base/task/sequence_manager/time_domain.h" #include "base/task/task_observer.h" #include "base/time/tick_clock.h" #include "base/time/time.h" #include "base/time/time_override.h" #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/scheduler/common/process_time_override_coordinator.h" namespace blink { namespace scheduler { class SchedulerHelper; // A time domain that runs tasks sequentially in time order but doesn't sleep // between delayed tasks. Because AutoAdvancingVirtualTimeDomain may override // Time/TimeTicks in a multi-threaded context, it must outlive any thread that // may call Time::Now() or TimeTicks::Now(). In practice, this means // AutoAdvancingVirtualTimeDomain can never be destroyed in production and acts // as a one-way switch. In tests, it should only be destroyed after all threads // have been joined. // // KEY: A-E are delayed tasks // | A B C D E (Execution with RealTimeDomain) // |-----------------------------> time // // |ABCDE (Execution with AutoAdvancingVirtualTimeDomain) // |-----------------------------> time class PLATFORM_EXPORT AutoAdvancingVirtualTimeDomain : public base::sequence_manager::TimeDomain, public base::TaskObserver { … }; } // namespace scheduler } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_AUTO_ADVANCING_VIRTUAL_TIME_DOMAIN_H_