зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1353897 - Only destroy preference front if used. r=ochameau
The toolbox can get a preference front for toggling various prefs on the server. The toolbox destruction code path was written in such a way that it would request a preference front during toolbox destroy, only to immediately destroy the front right after. This is extra painful, since we send a `listTabs` request and other fun things as part of this. With this change, we cache the preference front when it is first used, and we only attempt to destroy it if it was previously used. MozReview-Commit-ID: 9repQSXjdRj --HG-- extra : rebase_source : 574faf83072f355c250673726c19f7da90cb33c5
This commit is contained in:
Родитель
e470b697ec
Коммит
1a54932a26
|
@ -1803,35 +1803,36 @@ Toolbox.prototype = {
|
|||
},
|
||||
|
||||
// Returns an instance of the preference actor
|
||||
get _preferenceFront() {
|
||||
get preferenceFront() {
|
||||
if (this._preferenceFront) {
|
||||
return Promise.resolve(this._preferenceFront);
|
||||
}
|
||||
return this.isOpen.then(() => {
|
||||
return this.target.root.then(rootForm => {
|
||||
return getPreferenceFront(this.target.client, rootForm);
|
||||
let front = getPreferenceFront(this.target.client, rootForm);
|
||||
this._preferenceFront = front;
|
||||
return front;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
_toggleNoAutohide: Task.async(function* () {
|
||||
let front = yield this._preferenceFront;
|
||||
let toggledValue = !(yield this._isDisableAutohideEnabled(front));
|
||||
let front = yield this.preferenceFront;
|
||||
let toggledValue = !(yield this._isDisableAutohideEnabled());
|
||||
|
||||
front.setBoolPref(DISABLE_AUTOHIDE_PREF, toggledValue);
|
||||
|
||||
this.autohideButton.isChecked = toggledValue;
|
||||
}),
|
||||
|
||||
_isDisableAutohideEnabled: Task.async(function* (prefFront) {
|
||||
_isDisableAutohideEnabled: Task.async(function* () {
|
||||
// Ensure that the tools are open, and the button is visible.
|
||||
yield this.isOpen;
|
||||
if (!this.autohideButton.isVisible) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If no prefFront was provided, then get one.
|
||||
if (!prefFront) {
|
||||
prefFront = yield this._preferenceFront;
|
||||
}
|
||||
|
||||
let prefFront = yield this.preferenceFront;
|
||||
return yield prefFront.getBoolPref(DISABLE_AUTOHIDE_PREF);
|
||||
}),
|
||||
|
||||
|
@ -2515,8 +2516,11 @@ Toolbox.prototype = {
|
|||
* Destroy the preferences actor when the toolbox is unloaded.
|
||||
*/
|
||||
destroyPreference: Task.async(function* () {
|
||||
let front = yield this._preferenceFront;
|
||||
front.destroy();
|
||||
if (!this._preferenceFront) {
|
||||
return;
|
||||
}
|
||||
this._preferenceFront.destroy();
|
||||
this._preferenceFront = null;
|
||||
}),
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче