Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated to use memory.notify rather than memory.log for Firefox 16 an…

…d above (#141)
  • Loading branch information...
commit 6f8c6a3bd82d72e86b18e389355238ce4a9caea9 1 parent a14d112
@davehunt davehunt authored whimboo committed
View
3  extension/lib/config.js
@@ -19,7 +19,8 @@ const PREFERENCES = {
modified_prefs: 'extensions.' + self.id + '.modifiedPrefs',
// Application preferences
- memory_log: 'javascript.options.mem.log'
+ memory_log: 'javascript.options.mem.log',
+ memory_notify: 'javascript.options.mem.notify'
}
View
26 extension/lib/garbage-collector.js
@@ -14,6 +14,8 @@ const config = require("config");
Cu.import('resource://gre/modules/Services.jsm');
const reporter = EventEmitter.compose({
+ _pref_gc_notifications: null,
+
constructor: function Reporter() {
// Report unhandled errors from listeners
this.on("error", console.exception.bind(console));
@@ -21,9 +23,15 @@ const reporter = EventEmitter.compose({
// Make sure we clean-up correctly
unload.ensure(this, 'unload');
- // For now the logger preference has to be enabled to be able to
- // parse the GC / CC information from the console service messages
- this._isEnabled = prefs.get(config.preferences.memory_log);
+ if (config.application.branch >= 16) {
+ this._pref_gc_notifications = config.preferences.memory_notify;
+ }
+ else {
+ this._pref_gc_notifications = config.preferences.memory_log;
+ }
+
+ // Ensure GC/CC observer and console messages preference is enabled
+ this._isEnabled = prefs.get(this._pref_gc_notifications);
if (!this._isEnabled)
this._enable();
@@ -49,6 +57,10 @@ const reporter = EventEmitter.compose({
}
},
+ get pref_gc_notifications() {
+ return this._pref_gc_notifications;
+ },
+
unload: function Reporter_unload() {
this._removeAllListeners();
@@ -61,15 +73,13 @@ const reporter = EventEmitter.compose({
},
_enable: function Reporter__enable() {
- let logging_pref= config.preferences.memory_log;
-
var modifiedPrefs = JSON.parse(prefs.get(config.preferences.modified_prefs,
"{}"));
- if (!modifiedPrefs.hasOwnProperty(logging_pref)) {
- modifiedPrefs[logging_pref] = prefs.get(logging_pref);
+ if (!modifiedPrefs.hasOwnProperty(this._pref_gc_notifications)) {
+ modifiedPrefs[this._pref_gc_notifications] = prefs.get(this._pref_gc_notifications);
}
- prefs.set(logging_pref, true);
+ prefs.set(this._pref_gc_notifications, true);
prefs.set(config.preferences.modified_prefs, JSON.stringify(modifiedPrefs));
this._isEnabled = true;
},
View
7 extension/test/test-garbage-collector.js
@@ -2,9 +2,8 @@ const prefs = require("api-utils/preferences-service");
const config = require('memchaser/config');
-exports.test_javascript_mem_log_enabled = function (test) {
+exports.test_javascript_memory_pref_enabled = function (test) {
// We have to require the garbage collector to initialize the module
- require("memchaser/garbage-collector");
-
- test.assert(prefs.get(config.preferences.memory_log));
+ var gc = require("garbage-collector");
+ test.assert(prefs.get(gc.reporter.pref_gc_notifications));
}
Please sign in to comment.
Something went wrong with that request. Please try again.