Issue #2453 - Simplify CalculateTargetTime() code and fix typo.

We should always be on a worker thread so the MainThread call isn't
needed.
Also: DOMMinTimoutValue -> DOMMinTimeoutValue
This commit is contained in:
Moonchild 2024-01-15 20:58:30 +01:00 committed by roytam1
commit aa2e80e571
2 changed files with 7 additions and 12 deletions

View file

@ -1999,18 +1999,13 @@ struct WorkerPrivate::TimeoutInfo
auto target = mInterval;
int32_t minTimeoutValue;
if (NS_IsMainThread()) {
// We can get the pref value directly.
minTimeoutValue = Preferences::GetInt("dom.min_timeout_value");
// We're on a worker thread; go through WorkerPrivate for the pref.
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (workerPrivate) {
minTimeoutValue = workerPrivate->DOMMinTimeoutValue();
} else {
// We're on a worker thread; go through WorkerPrivate.
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (workerPrivate) {
minTimeoutValue = workerPrivate->DOMMinTimoutValue();
} else {
// fall back to default 4 ms
minTimeoutValue = 4;
}
// fall back to default 4 ms
minTimeoutValue = 4;
}
// Clamp timeout for workers, except chrome workers