Bug 1967608 - Make all prefs accessed by worker thread atomic, r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D250349
This commit is contained in:
aiunusov@mozilla.com
2025-05-21 11:20:46 +00:00
parent 3579d10b05
commit 0afe028ab6
3 changed files with 10 additions and 11 deletions

View File

@@ -322,7 +322,7 @@ TimeDuration TimeoutManager::CalculateDelay(Timeout* aTimeout) const {
TimeDuration result = aTimeout->mInterval; TimeDuration result = aTimeout->mInterval;
if (aTimeout->mNestingLevel >= if (aTimeout->mNestingLevel >=
StaticPrefs::dom_clamp_timeout_nesting_level_AtStartup()) { StaticPrefs::dom_clamp_timeout_nesting_level()) {
uint32_t minTimeoutValue = StaticPrefs::dom_min_timeout_value(); uint32_t minTimeoutValue = StaticPrefs::dom_min_timeout_value();
result = TimeDuration::Max(result, result = TimeDuration::Max(result,
TimeDuration::FromMilliseconds(minTimeoutValue)); TimeDuration::FromMilliseconds(minTimeoutValue));
@@ -529,7 +529,7 @@ nsresult TimeoutManager::SetTimeout(TimeoutHandler* aHandler, int32_t interval,
const uint32_t nestingLevel{mIsWindow ? GetNestingLevelForWindow() const uint32_t nestingLevel{mIsWindow ? GetNestingLevelForWindow()
: GetNestingLevelForWorker()}; : GetNestingLevelForWorker()};
timeout->mNestingLevel = timeout->mNestingLevel =
nestingLevel < StaticPrefs::dom_clamp_timeout_nesting_level_AtStartup() nestingLevel < StaticPrefs::dom_clamp_timeout_nesting_level()
? nestingLevel + 1 ? nestingLevel + 1
: nestingLevel; : nestingLevel;
} }
@@ -1039,7 +1039,7 @@ bool TimeoutManager::RescheduleTimeout(Timeout* aTimeout,
// Automatically increase the nesting level when a setInterval() // Automatically increase the nesting level when a setInterval()
// is rescheduled just as if it was using a chained setTimeout(). // is rescheduled just as if it was using a chained setTimeout().
if (aTimeout->mNestingLevel < if (aTimeout->mNestingLevel <
StaticPrefs::dom_clamp_timeout_nesting_level_AtStartup()) { StaticPrefs::dom_clamp_timeout_nesting_level()) {
aTimeout->mNestingLevel += 1; aTimeout->mNestingLevel += 1;
} }

View File

@@ -1094,18 +1094,17 @@ struct WorkerPrivate::TimeoutInfo {
} }
void AccumulateNestingLevel(const uint32_t& aBaseLevel) { void AccumulateNestingLevel(const uint32_t& aBaseLevel) {
if (aBaseLevel < StaticPrefs::dom_clamp_timeout_nesting_level_AtStartup()) { if (aBaseLevel < StaticPrefs::dom_clamp_timeout_nesting_level()) {
mNestingLevel = aBaseLevel + 1; mNestingLevel = aBaseLevel + 1;
return; return;
} }
mNestingLevel = StaticPrefs::dom_clamp_timeout_nesting_level_AtStartup(); mNestingLevel = StaticPrefs::dom_clamp_timeout_nesting_level();
} }
void CalculateTargetTime() { void CalculateTargetTime() {
auto target = mInterval; auto target = mInterval;
// Don't clamp timeout for chrome workers // Don't clamp timeout for chrome workers
if (mNestingLevel >= if (mNestingLevel >= StaticPrefs::dom_clamp_timeout_nesting_level() &&
StaticPrefs::dom_clamp_timeout_nesting_level_AtStartup() &&
!mOnChromeWorker) { !mOnChromeWorker) {
target = TimeDuration::Max( target = TimeDuration::Max(
mInterval, mInterval,

View File

@@ -2528,9 +2528,9 @@
# HTML specification says the level should be 5 # HTML specification says the level should be 5
# https://html.spec.whatwg.org/#timer-initialisation-steps # https://html.spec.whatwg.org/#timer-initialisation-steps
- name: dom.clamp.timeout.nesting.level - name: dom.clamp.timeout.nesting.level
type: uint32_t type: RelaxedAtomicUint32
value: 5 value: 5
mirror: once mirror: always
# Skip the security checks for document.cookie. # Skip the security checks for document.cookie.
- name: dom.cookie.testing.enabled - name: dom.cookie.testing.enabled
@@ -3537,13 +3537,13 @@
# Timeout clamp in ms for background windows. # Timeout clamp in ms for background windows.
- name: dom.min_background_timeout_value - name: dom.min_background_timeout_value
type: int32_t type: RelaxedAtomicInt32
value: 1000 value: 1000
mirror: always mirror: always
# Timeout clamp in ms for background windows when throttling isn't enabled. # Timeout clamp in ms for background windows when throttling isn't enabled.
- name: dom.min_background_timeout_value_without_budget_throttling - name: dom.min_background_timeout_value_without_budget_throttling
type: int32_t type: RelaxedAtomicInt32
value: 1000 value: 1000
mirror: always mirror: always