Bug 714841 - With 30 lightweight themes installed, Add-ons Manager appearance pane is slow to load. r=dtownsend

This commit is contained in:
Blair McBride 2012-02-15 15:07:30 +13:00
Родитель b739574682
Коммит 31fb50a746
1 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -92,6 +92,8 @@ __defineSetter__("_maxUsedThemes", function(aVal) {
return this._maxUsedThemes = aVal; return this._maxUsedThemes = aVal;
}); });
var _usedThemes = null;
// Holds the ID of the theme being enabled or disabled while sending out the // Holds the ID of the theme being enabled or disabled while sending out the
// events so cached AddonWrapper instances can return correct values for // events so cached AddonWrapper instances can return correct values for
// permissions and pendingOperations // permissions and pendingOperations
@ -100,12 +102,16 @@ var _themeIDBeingDisbled = null;
var LightweightThemeManager = { var LightweightThemeManager = {
get usedThemes () { get usedThemes () {
if (_usedThemes)
return _usedThemes;
try { try {
return JSON.parse(_prefs.getComplexValue("usedThemes", _usedThemes = JSON.parse(_prefs.getComplexValue("usedThemes",
Ci.nsISupportsString).data); Ci.nsISupportsString).data);
} catch (e) { } catch (e) {
return []; _usedThemes = [];
} }
return _usedThemes;
}, },
get currentTheme () { get currentTheme () {
@ -408,7 +414,8 @@ var LightweightThemeManager = {
return; return;
} }
aCallback([new AddonWrapper(a) for each (a in this.usedThemes)]); let themes = this.usedThemes;
aCallback([new AddonWrapper(a) for each (a in themes)]);
}, },
}; };
@ -746,6 +753,10 @@ function _prefObserver(aSubject, aTopic, aData) {
// Update the theme list to remove any themes over the number we keep // Update the theme list to remove any themes over the number we keep
_updateUsedThemes(LightweightThemeManager.usedThemes); _updateUsedThemes(LightweightThemeManager.usedThemes);
break; break;
case "usedThemes":
// Clear the cache - it will be repopulated next time it's used.
_usedThemes = null;
break;
} }
} }