diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/display_lock/strict_yielding_display_lock_budget.h')
-rw-r--r-- | chromium/third_party/blink/renderer/core/display_lock/strict_yielding_display_lock_budget.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/display_lock/strict_yielding_display_lock_budget.h b/chromium/third_party/blink/renderer/core/display_lock/strict_yielding_display_lock_budget.h new file mode 100644 index 00000000000..da7512a4520 --- /dev/null +++ b/chromium/third_party/blink/renderer/core/display_lock/strict_yielding_display_lock_budget.h @@ -0,0 +1,42 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// 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_CORE_DISPLAY_LOCK_STRICT_YIELDING_DISPLAY_LOCK_BUDGET_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_DISPLAY_LOCK_STRICT_YIELDING_DISPLAY_LOCK_BUDGET_H_ + +#include "base/optional.h" +#include "third_party/blink/renderer/core/core_export.h" +#include "third_party/blink/renderer/core/display_lock/display_lock_budget.h" + +namespace blink { + +// This budget yields between lifecycle phases even if that phase is quick. In +// other words, it will only do one new lifecycle phase at a time, and block the +// future ones. Any lifecycle phases that have already been allowed by this +// budget in the past are not blocked. +class CORE_EXPORT StrictYieldingDisplayLockBudget final + : public DisplayLockBudget { + public: + StrictYieldingDisplayLockBudget(DisplayLockContext*); + ~StrictYieldingDisplayLockBudget() override = default; + + bool ShouldPerformPhase(Phase) const override; + void DidPerformPhase(Phase) override; + void WillStartLifecycleUpdate() override; + // Returns true if any of the lifecycles that have been previously blocked by + // this budget need updates. Note that this does not check lifecycle phases + // that have already completed by this budget even if they are now dirty + // again. This is done to prevent starvation (ie, it is possible for the + // budget to always schedule more work if something in rAF keeps dirtying + // layout, for example). + bool NeedsLifecycleUpdates() const override; + + protected: + base::Optional<Phase> last_completed_phase_; + bool completed_new_phase_this_cycle_; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_DISPLAY_LOCK_STRICT_YIELDING_DISPLAY_LOCK_BUDGET_H_ |