Bug 863285 - Cache the result of Ci.nsIMemory.isLowMemoryPlatform(). r=Kartikaya

This commit is contained in:
Tetsuharu OHZEKI 2013-04-20 19:13:45 +09:00
parent a2345751b3
commit ee8bab92ec

View File

@ -212,6 +212,12 @@ var BrowserApp = {
return this.isTablet = sysInfo.get("tablet");
},
get isOnLowMemoryPlatform() {
let memory = Cc["@mozilla.org/xpcom/memory-service;1"].getService(Ci.nsIMemory);
delete this.isOnLowMemoryPlatform;
return this.isOnLowMemoryPlatform = memory.isLowMemoryPlatform();
},
deck: null,
startup: function startup() {
@ -3218,7 +3224,7 @@ Tab.prototype = {
// For low-memory devices, don't allow reader mode since it takes up a lot of memory.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=792603 for details.
if (Cc["@mozilla.org/xpcom/memory-service;1"].getService(Ci.nsIMemory).isLowMemoryPlatform())
if (BrowserApp.isOnLowMemoryPlatform)
return;
// Once document is fully loaded, parse it
@ -7206,7 +7212,7 @@ var Tabs = {
init: function() {
// on low-memory platforms, always allow tab expiration. on high-mem
// platforms, allow it to be turned on once we hit a low-mem situation
if (Cc["@mozilla.org/xpcom/memory-service;1"].getService(Ci.nsIMemory).isLowMemoryPlatform()) {
if (BrowserApp.isOnLowMemoryPlatform) {
this._enableTabExpiration = true;
} else {
Services.obs.addObserver(this, "memory-pressure", false);