This repository has been archived by the owner on Oct 18, 2018. It is now read-only.
Updated to use memory.notify rather than memory.log for Firefox 16 and above. Fixes issue #134 #141
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1993336
Updated to use memory.notify rather than memory.log for Firefox 16 an…
davehunt ae2d12f
Reduced code duplication and improved comments.
davehunt 56aa1d0
Made GC preference public so it can be accessed from the tests.
davehunt aca803d
Moved the GC notification preference out of global scope.
davehunt 4fa5b11
Moved preference getter below constructor as suggested.
davehunt File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ const unload = require("api-utils/unload"); | |
const config = require("config"); | ||
|
||
|
||
var pref_gc_notifications; | ||
|
||
|
||
const reporter = EventEmitter.compose({ | ||
constructor: function Reporter() { | ||
// Report unhandled errors from listeners | ||
|
@@ -27,9 +30,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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should maintain those different paths multiple times in our code. Simply assign the right pref to an internal property like _pref_gc_notifications or similar. That way we don't need another if/else in _enable. |
||
pref_gc_notifications = config.preferences.memory_notify; | ||
} | ||
else { | ||
pref_gc_notifications = config.preferences.memory_log; | ||
} | ||
|
||
// Ensure GC/CC observer and console messages preference is enabled | ||
this._isEnabled = prefs.get(pref_gc_notifications); | ||
if (!this._isEnabled) | ||
this._enable(); | ||
|
||
|
@@ -67,15 +76,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(pref_gc_notifications)) { | ||
modifiedPrefs[pref_gc_notifications] = prefs.get(pref_gc_notifications); | ||
} | ||
|
||
prefs.set(logging_pref, true); | ||
prefs.set(pref_gc_notifications, true); | ||
prefs.set(config.preferences.modified_prefs, JSON.stringify(modifiedPrefs)); | ||
this._isEnabled = true; | ||
}, | ||
|
@@ -160,6 +167,8 @@ var doGlobalGC = function () { | |
} | ||
|
||
|
||
exports.pref_gc_notifications = pref_gc_notifications; | ||
|
||
exports.reporter = reporter; | ||
|
||
exports.doCC = doCC; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable should still be on the reporter object and not stay in the global scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed on IRC, I have attempted to move this out of global scope, but this causes the test to fail.