extensionSystem: Get rid of _enabled boolean optimization

At the moment a session mode either allows extensions or it doesn't.
If it allows extensions, then the entire available list of
configured extensions get enabled as soon as the session mode is
entered.

Since enabling or disabling extensions is an all or nothing situation,
the code tracks whether extensions are already enabled when entering
the session mode, and if so, avoids iterating through the extension list
needlessly. It does this using a boolean named _enabled.

In the future, the extensions themselves will be given some say on
whether or not they should be enabled in a given session mode. This
means, the configured extension list may contain extensions that
shouldn't be enabled for a given session mode, and the _enabled boolean
will no longer be appropriated.

This commit drops the _enabled boolean optimization.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1967>
This commit is contained in:
Ray Strode 2021-08-10 13:25:57 -04:00 committed by Marge Bot
parent 7bde02c1cf
commit 7e5ee2c282

View File

@ -22,7 +22,6 @@ const UPDATE_CHECK_TIMEOUT = 24 * 60 * 60; // 1 day in seconds
var ExtensionManager = class {
constructor() {
this._initialized = false;
this._enabled = false;
this._updateNotified = false;
this._extensions = new Map();
@ -589,9 +588,6 @@ var ExtensionManager = class {
}
_enableAllExtensions() {
if (this._enabled)
return;
if (!this._initialized) {
this._loadExtensions();
this._initialized = true;
@ -600,20 +596,14 @@ var ExtensionManager = class {
this._callExtensionEnable(uuid);
});
}
this._enabled = true;
}
_disableAllExtensions() {
if (!this._enabled)
return;
if (this._initialized) {
this._extensionOrder.slice().reverse().forEach(uuid => {
this._callExtensionDisable(uuid);
});
}
this._enabled = false;
}
_sessionUpdated() {