зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1316871 - Throttle background setTimeouts. r=bkelly
MozReview-Commit-ID: 2bN3NZfdCzv
This commit is contained in:
Родитель
15190c112d
Коммит
40d5595f1e
|
@ -319,8 +319,7 @@ nsGlobalWindow::DOMMinTimeoutValue() const {
|
|||
int32_t value = std::max(mBackPressureDelayMS, 0);
|
||||
// Don't use the background timeout value when there are audio contexts
|
||||
// present, so that baackground audio can keep running smoothly. (bug 1181073)
|
||||
bool isBackground = mAudioContexts.IsEmpty() &&
|
||||
(!mOuterWindow || mOuterWindow->IsBackground());
|
||||
bool isBackground = mAudioContexts.IsEmpty() && IsBackgroundInternal();
|
||||
return
|
||||
std::max(isBackground ? gMinBackgroundTimeoutValue : gMinTimeoutValue, value);
|
||||
}
|
||||
|
@ -654,6 +653,11 @@ void nsGlobalWindow::UnthrottleIdleCallbackRequests()
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsGlobalWindow::IsBackgroundInternal() const
|
||||
{
|
||||
return !mOuterWindow || mOuterWindow->IsBackground();
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -12741,7 +12745,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsITimeoutHandler* aHandler,
|
|||
uint32_t nestingLevel = sNestingLevel + 1;
|
||||
uint32_t realInterval = interval;
|
||||
if (aIsInterval || nestingLevel >= DOM_CLAMP_TIMEOUT_NESTING_LEVEL ||
|
||||
mBackPressureDelayMS > 0) {
|
||||
mBackPressureDelayMS > 0 || IsBackgroundInternal()) {
|
||||
// Don't allow timeouts less than DOMMinTimeoutValue() from
|
||||
// now...
|
||||
realInterval = std::max(realInterval, uint32_t(DOMMinTimeoutValue()));
|
||||
|
|
|
@ -1724,6 +1724,8 @@ private:
|
|||
mozilla::dom::TabGroup* TabGroupInner();
|
||||
mozilla::dom::TabGroup* TabGroupOuter();
|
||||
|
||||
bool IsBackgroundInternal() const;
|
||||
|
||||
public:
|
||||
// Dispatch a runnable related to the global.
|
||||
virtual nsresult Dispatch(const char* aName,
|
||||
|
|
Загрузка…
Ссылка в новой задаче