зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1583651 - Send all pre/postActions through handleEvent r=mconley
This way we ensure that the reentrancy guard always stays in effect. It should just be a little easier to reason about everything if it's all channeled through the same place. Differential Revision: https://phabricator.services.mozilla.com/D47349 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ecb14a1f95
Коммит
ac9c79f25f
|
@ -535,7 +535,7 @@ class AsyncTabSwitcher {
|
||||||
this.log("Loading tab " + this.tinfo(this.loadingTab));
|
this.log("Loading tab " + this.tinfo(this.loadingTab));
|
||||||
|
|
||||||
this.loadTimer = this.setTimer(
|
this.loadTimer = this.setTimer(
|
||||||
() => this.onLoadTimeout(),
|
() => this.handleEvent({ type: "loadTimeout" }),
|
||||||
this.TAB_SWITCH_TIMEOUT
|
this.TAB_SWITCH_TIMEOUT
|
||||||
);
|
);
|
||||||
this.setTabState(this.requestedTab, this.STATE_LOADING);
|
this.setTabState(this.requestedTab, this.STATE_LOADING);
|
||||||
|
@ -710,13 +710,8 @@ class AsyncTabSwitcher {
|
||||||
|
|
||||||
// Fires when we're ready to unload unused tabs.
|
// Fires when we're ready to unload unused tabs.
|
||||||
onUnloadTimeout() {
|
onUnloadTimeout() {
|
||||||
this.logState("onUnloadTimeout");
|
|
||||||
this.preActions();
|
|
||||||
this.unloadTimer = null;
|
this.unloadTimer = null;
|
||||||
|
|
||||||
this.unloadNonRequiredTabs();
|
this.unloadNonRequiredTabs();
|
||||||
|
|
||||||
this.postActions("onUnloadTimeout");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deactivateCachedBackgroundTabs() {
|
deactivateCachedBackgroundTabs() {
|
||||||
|
@ -768,7 +763,7 @@ class AsyncTabSwitcher {
|
||||||
if (numPending) {
|
if (numPending) {
|
||||||
// Keep the timer going since there may be more tabs to unload.
|
// Keep the timer going since there may be more tabs to unload.
|
||||||
this.unloadTimer = this.setTimer(
|
this.unloadTimer = this.setTimer(
|
||||||
() => this.onUnloadTimeout(),
|
() => this.handleEvent({ type: "unloadTimeout" }),
|
||||||
this.UNLOAD_DELAY
|
this.UNLOAD_DELAY
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -776,10 +771,7 @@ class AsyncTabSwitcher {
|
||||||
|
|
||||||
// Fires when an ongoing load has taken too long.
|
// Fires when an ongoing load has taken too long.
|
||||||
onLoadTimeout() {
|
onLoadTimeout() {
|
||||||
this.logState("onLoadTimeout");
|
|
||||||
this.preActions();
|
|
||||||
this.maybeClearLoadTimer("onLoadTimeout");
|
this.maybeClearLoadTimer("onLoadTimeout");
|
||||||
this.postActions("onLoadTimeout");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fires when the layers become available for a tab.
|
// Fires when the layers become available for a tab.
|
||||||
|
@ -875,17 +867,16 @@ class AsyncTabSwitcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noteTabRemoved(tab) {
|
||||||
|
if (this.lastVisibleTab == tab) {
|
||||||
|
this.handleEvent({ type: "tabRemoved", tab });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Called when a tab has been removed, and the browser node is
|
// Called when a tab has been removed, and the browser node is
|
||||||
// about to be removed from the DOM.
|
// about to be removed from the DOM.
|
||||||
onTabRemoved(tab) {
|
onTabRemoved(tab) {
|
||||||
if (this.lastVisibleTab == tab) {
|
|
||||||
// The browser that was being presented to the user is
|
|
||||||
// going to be removed during this tick of the event loop.
|
|
||||||
// This will cause us to show a tab spinner instead.
|
|
||||||
this.preActions();
|
|
||||||
this.lastVisibleTab = null;
|
this.lastVisibleTab = null;
|
||||||
this.postActions("onTabRemoved");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSizeModeOrOcclusionStateChange() {
|
onSizeModeOrOcclusionStateChange() {
|
||||||
|
@ -1112,17 +1103,17 @@ class AsyncTabSwitcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
queueUnload(unloadTimeout) {
|
queueUnload(unloadTimeout) {
|
||||||
this.preActions();
|
this.handleEvent({ type: "queueUnload", unloadTimeout });
|
||||||
|
}
|
||||||
|
|
||||||
|
onQueueUnload(unloadTimeout) {
|
||||||
if (this.unloadTimer) {
|
if (this.unloadTimer) {
|
||||||
this.clearTimer(this.unloadTimer);
|
this.clearTimer(this.unloadTimer);
|
||||||
}
|
}
|
||||||
this.unloadTimer = this.setTimer(
|
this.unloadTimer = this.setTimer(
|
||||||
() => this.onUnloadTimeout(),
|
() => this.handleEvent({ type: "unloadTimeout" }),
|
||||||
unloadTimeout
|
unloadTimeout
|
||||||
);
|
);
|
||||||
|
|
||||||
this.postActions("queueUnload");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEvent(event, delayed = false) {
|
handleEvent(event, delayed = false) {
|
||||||
|
@ -1140,6 +1131,18 @@ class AsyncTabSwitcher {
|
||||||
this.preActions();
|
this.preActions();
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
|
case "queueUnload":
|
||||||
|
this.onQueueUnload(event.unloadTimeout);
|
||||||
|
break;
|
||||||
|
case "unloadTimeout":
|
||||||
|
this.onUnloadTimeout();
|
||||||
|
break;
|
||||||
|
case "loadTimeout":
|
||||||
|
this.onLoadTimeout();
|
||||||
|
break;
|
||||||
|
case "tabRemoved":
|
||||||
|
this.onTabRemoved(event.tab);
|
||||||
|
break;
|
||||||
case "MozLayerTreeReady":
|
case "MozLayerTreeReady":
|
||||||
this.onLayersReady(event.originalTarget);
|
this.onLayersReady(event.originalTarget);
|
||||||
break;
|
break;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче