Commit fe436b6b authored by Felipe Gomes's avatar Felipe Gomes
Browse files

Bug 827976 - Use requestIdleCallback from Timer.jsm instead of from the hidden window. r=mconley

Differential Revision: https://phabricator.services.mozilla.com/D21085

--HG--
extra : moz-landing-system : lando
parent 81059534
...@@ -176,8 +176,6 @@ var SessionSaverInternal = { ...@@ -176,8 +176,6 @@ var SessionSaverInternal = {
// Schedule a state save. // Schedule a state save.
this._wasIdle = this._isIdle; this._wasIdle = this._isIdle;
this._timeoutID = setTimeout(() => { this._timeoutID = setTimeout(() => {
let hiddenDOMWindow = Services.appShell.hiddenDOMWindow;
// Execute _saveStateAsync when we have enough idle time. Otherwise, // Execute _saveStateAsync when we have enough idle time. Otherwise,
// another idle request is made to schedule _saveStateAsync again. // another idle request is made to schedule _saveStateAsync again.
let saveStateAsyncWhenIdle = (deadline) => { let saveStateAsyncWhenIdle = (deadline) => {
...@@ -185,13 +183,13 @@ var SessionSaverInternal = { ...@@ -185,13 +183,13 @@ var SessionSaverInternal = {
// _saveStateAsync is around 5.9ms (median). Therefore, // _saveStateAsync is around 5.9ms (median). Therefore,
// we'll not execute the function when the idle time is less than 5ms. // we'll not execute the function when the idle time is less than 5ms.
if (deadline.timeRemaining() < 5) { if (deadline.timeRemaining() < 5) {
this._idleCallbackID = hiddenDOMWindow.requestIdleCallback(saveStateAsyncWhenIdle); this._idleCallbackID = requestIdleCallback(saveStateAsyncWhenIdle);
return; return;
} }
this._saveStateAsync(); this._saveStateAsync();
}; };
this._idleCallbackID = hiddenDOMWindow.requestIdleCallback(saveStateAsyncWhenIdle); this._idleCallbackID = requestIdleCallback(saveStateAsyncWhenIdle);
}, delay); }, delay);
}, },
...@@ -209,7 +207,7 @@ var SessionSaverInternal = { ...@@ -209,7 +207,7 @@ var SessionSaverInternal = {
cancel() { cancel() {
clearTimeout(this._timeoutID); clearTimeout(this._timeoutID);
this._timeoutID = null; this._timeoutID = null;
Services.appShell.hiddenDOMWindow.cancelIdleCallback(this._idleCallbackID); cancelIdleCallback(this._idleCallbackID);
this._idleCallbackID = null; this._idleCallbackID = null;
}, },
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment