summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-06-26 14:43:25 -0400
committerMatt A. Tobin <email@mattatobin.com>2018-06-26 14:43:25 -0400
commit431fe926e002cfcf8996bc17201ee885a3860c8b (patch)
tree84809b585c2547ff056d3f1c332031f9d13f5409 /toolkit/mozapps/extensions
parent2ec54f1e95870e95e278b66b621b30a584041d72 (diff)
downloadUXP-431fe926e002cfcf8996bc17201ee885a3860c8b.tar
UXP-431fe926e002cfcf8996bc17201ee885a3860c8b.tar.gz
UXP-431fe926e002cfcf8996bc17201ee885a3860c8b.tar.lz
UXP-431fe926e002cfcf8996bc17201ee885a3860c8b.tar.xz
UXP-431fe926e002cfcf8996bc17201ee885a3860c8b.zip
[AllAM] De-duplicate ChromeManifestParser.jsm and DeferedSave.jsm
Diffstat (limited to 'toolkit/mozapps/extensions')
-rw-r--r--toolkit/mozapps/extensions/ChromeManifestParser.jsm28
-rw-r--r--toolkit/mozapps/extensions/DeferredSave.jsm37
2 files changed, 32 insertions, 33 deletions
diff --git a/toolkit/mozapps/extensions/ChromeManifestParser.jsm b/toolkit/mozapps/extensions/ChromeManifestParser.jsm
index 9a77c5429..63f1db785 100644
--- a/toolkit/mozapps/extensions/ChromeManifestParser.jsm
+++ b/toolkit/mozapps/extensions/ChromeManifestParser.jsm
@@ -45,7 +45,7 @@ this.ChromeManifestParser = {
* @return Array of objects describing each manifest instruction, in the form:
* { type: instruction-type, baseURI: string-uri, args: [arguments] }
**/
- parseSync: function CMP_parseSync(aURI) {
+ parseSync: function(aURI) {
function parseLine(aLine) {
let line = aLine.trim();
if (line.length == 0 || line.charAt(0) == '#')
@@ -80,14 +80,14 @@ this.ChromeManifestParser = {
lines.forEach(parseLine.bind(this));
return data;
},
-
- _readFromJar: function CMP_readFromJar(aURI) {
+
+ _readFromJar: function(aURI) {
let data = "";
let entries = [];
let readers = [];
-
+
try {
- // Deconstrict URI, which can be nested jar: URIs.
+ // Deconstrict URI, which can be nested jar: URIs.
let uri = aURI.clone();
while (uri instanceof Ci.nsIJARURI) {
entries.push(uri.JAREntry);
@@ -99,7 +99,7 @@ this.ChromeManifestParser = {
createInstance(Ci.nsIZipReader);
reader.open(uri.QueryInterface(Ci.nsIFileURL).file);
readers.push(reader);
-
+
// Open the nested jars.
for (let i = entries.length - 1; i > 0; i--) {
let innerReader = Cc["@mozilla.org/libjar/zip-reader;1"].
@@ -108,7 +108,7 @@ this.ChromeManifestParser = {
readers.push(innerReader);
reader = innerReader;
}
-
+
// First entry is the actual file we want to read.
let zis = reader.getInputStream(entries[0]);
data = NetUtil.readInputStreamToString(zis, zis.available());
@@ -120,15 +120,15 @@ this.ChromeManifestParser = {
flushJarCache(readers[i].file);
}
}
-
+
return data;
},
-
- _readFromFile: function CMP_readFromFile(aURI) {
+
+ _readFromFile: function(aURI) {
let file = aURI.QueryInterface(Ci.nsIFileURL).file;
if (!file.exists() || !file.isFile())
return "";
-
+
let data = "";
let fis = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
@@ -151,9 +151,7 @@ this.ChromeManifestParser = {
* Instruction type to filter by.
* @return True if any matching instructions were found in the manifest.
*/
- hasType: function CMP_hasType(aManifest, aType) {
- return aManifest.some(function hasType_matchEntryType(aEntry) {
- return aEntry.type == aType;
- });
+ hasType: function(aManifest, aType) {
+ return aManifest.some(entry => entry.type == aType);
}
};
diff --git a/toolkit/mozapps/extensions/DeferredSave.jsm b/toolkit/mozapps/extensions/DeferredSave.jsm
index 7587ce83b..89f82b265 100644
--- a/toolkit/mozapps/extensions/DeferredSave.jsm
+++ b/toolkit/mozapps/extensions/DeferredSave.jsm
@@ -9,6 +9,7 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
Cu.import("resource://gre/modules/osfile.jsm");
+/* globals OS*/
Cu.import("resource://gre/modules/Promise.jsm");
// Make it possible to mock out timers for testing
@@ -20,26 +21,26 @@ this.EXPORTED_SYMBOLS = ["DeferredSave"];
const DEFAULT_SAVE_DELAY_MS = 50;
Cu.import("resource://gre/modules/Log.jsm");
-//Configure a logger at the parent 'DeferredSave' level to format
-//messages for all the modules under DeferredSave.*
+// Configure a logger at the parent 'DeferredSave' level to format
+// messages for all the modules under DeferredSave.*
const DEFERREDSAVE_PARENT_LOGGER_ID = "DeferredSave";
var parentLogger = Log.repository.getLogger(DEFERREDSAVE_PARENT_LOGGER_ID);
parentLogger.level = Log.Level.Warn;
var formatter = new Log.BasicFormatter();
-//Set parent logger (and its children) to append to
-//the Javascript section of the Browser Console
+// Set parent logger (and its children) to append to
+// the Javascript section of the Browser Console
parentLogger.addAppender(new Log.ConsoleAppender(formatter));
-//Set parent logger (and its children) to
-//also append to standard out
+// Set parent logger (and its children) to
+// also append to standard out
parentLogger.addAppender(new Log.DumpAppender(formatter));
-//Provide the ability to enable/disable logging
-//messages at runtime.
-//If the "extensions.logging.enabled" preference is
-//missing or 'false', messages at the WARNING and higher
-//severity should be logged to the JS console and standard error.
-//If "extensions.logging.enabled" is set to 'true', messages
-//at DEBUG and higher should go to JS console and standard error.
+// Provide the ability to enable/disable logging
+// messages at runtime.
+// If the "extensions.logging.enabled" preference is
+// missing or 'false', messages at the WARNING and higher
+// severity should be logged to the JS console and standard error.
+// If "extensions.logging.enabled" is set to 'true', messages
+// at DEBUG and higher should go to JS console and standard error.
Cu.import("resource://gre/modules/Services.jsm");
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
@@ -51,13 +52,13 @@ const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
* parent 'addons' level logger accordingly.
*/
var PrefObserver = {
- init: function PrefObserver_init() {
+ init: function() {
Services.prefs.addObserver(PREF_LOGGING_ENABLED, this, false);
Services.obs.addObserver(this, "xpcom-shutdown", false);
this.observe(null, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, PREF_LOGGING_ENABLED);
},
- observe: function PrefObserver_observe(aSubject, aTopic, aData) {
+ observe: function(aSubject, aTopic, aData) {
if (aTopic == "xpcom-shutdown") {
Services.prefs.removeObserver(PREF_LOGGING_ENABLED, this);
Services.obs.removeObserver(this, "xpcom-shutdown");
@@ -103,7 +104,7 @@ PrefObserver.init();
* that marks the data as needing to be saved, and when the DeferredSave
* begins writing the data to disk. Default 50 milliseconds.
*/
-this.DeferredSave = function (aPath, aDataProvider, aDelay) {
+this.DeferredSave = function(aPath, aDataProvider, aDelay) {
// Create a new logger (child of 'DeferredSave' logger)
// for use by this particular instance of DeferredSave object
let leafName = OS.Path.basename(aPath);
@@ -207,7 +208,7 @@ this.DeferredSave.prototype = {
try {
toSave = this._dataProvider();
}
- catch(e) {
+ catch (e) {
this.logger.error("Deferred save dataProvider failed", e);
writing.then(null, error => {})
.then(count => {
@@ -216,7 +217,7 @@ this.DeferredSave.prototype = {
return;
}
- writing.then(null, error => {return 0;})
+ writing.then(null, error => { return 0; })
.then(count => {
this.logger.debug("Starting write");
this.totalSaves++;