[Pkg-mozext-commits] [requestpolicy] 104/280: convert observer-manager.js to a module
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:30:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit e64d8abc9e95b2a07e888395cd72e873e890ed06
Author: Martin Kimmerle <dev at 256k.de>
Date: Sun Jan 4 14:48:02 2015 +0100
convert observer-manager.js to a module
---
.../{observer-manager.js => observer-manager.jsm} | 53 +++++++++-------------
src/content/settings/common.js | 8 +---
2 files changed, 23 insertions(+), 38 deletions(-)
diff --git a/src/content/lib/observer-manager.js b/src/content/lib/observer-manager.jsm
similarity index 66%
rename from src/content/lib/observer-manager.js
rename to src/content/lib/observer-manager.jsm
index cb45888..cef0a1c 100644
--- a/src/content/lib/observer-manager.js
+++ b/src/content/lib/observer-manager.jsm
@@ -21,47 +21,40 @@
* ***** END LICENSE BLOCK *****
*/
-// TODO: convert this file into a module, as we now have `ProcessEnvironment`
-// which handles startup and shutdown and can be imported from anywhere.
+const Ci = Components.interfaces;
+const Cc = Components.classes;
+const Cu = Components.utils;
+
+let EXPORTED_SYMBOLS = ["ObserverManager"];
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("chrome://requestpolicy/content/lib/script-loader.jsm");
+
+let {ProcessEnvironment} = ScriptLoader.importModule("process-environment");
+
+// Load the Logger at startup-time, not at load-time!
+// ( On load-time Looger might be null. )
+let Logger;
+ProcessEnvironment.enqueueStartupFunction(function() {
+ Logger = ScriptLoader.importModule("logger").Logger;
+});
+
/**
* The ObserverManager provides an interface to `nsIObserverService` which takes
* care of unregistering the observed topics.
- * There are two ways how to get an instance of this manager.
- * (a) if the topics should be observed only as long as a DOM Window lives,
- * then this *.js file should be loaded **directly** into that window.
- * (b) if the topics should be observed as long as RP is activated, then the
- * **module** `observer-manager.jsm` has to be used instead.
- *
- * Note that when this file is loaded directly (case (a)), the ObserverManager
- * is created only once, i.e. if it is not existant yet!
*/
-var ObserverManager = ObserverManager || (function() {
+let ObserverManager = (function() {
let self = {};
-
- const Ci = Components.interfaces;
- const Cc = Components.classes;
- const Cu = Components.utils;
-
- let ScriptLoader;
- {
- let mod = {};
- Cu.import("chrome://requestpolicy/content/lib/script-loader.jsm", mod);
- ScriptLoader = mod.ScriptLoader;
- }
- let Logger;
- let {ProcessEnvironment} = ScriptLoader.importModule("process-environment");
-
-
/**
* This Object registers itself to `nsIObserverService` on behalf of some other
- * object. The `observe` function called by `nsIObserverService` is handed over
- * by the *real* observer.
+ * object.
*/
function SingleTopicObserver(aTopic, aFunctionToCall) {
// save the parameters
this.topic = aTopic;
+ // As the `observe` function, take directly the parameter.
this.observe = aFunctionToCall;
// currently this obserer is not rgistered yet
@@ -110,10 +103,6 @@ var ObserverManager = ObserverManager || (function() {
- ProcessEnvironment.enqueueStartupFunction(function() {
- // Load the Logger now, not earlier. Otherwise it could be null.
- Logger = ScriptLoader.importModule("logger").Logger;
- });
/**
* The function will unregister all registered observers.
diff --git a/src/content/settings/common.js b/src/content/settings/common.js
index 9ae4404..b4bb872 100644
--- a/src/content/settings/common.js
+++ b/src/content/settings/common.js
@@ -14,11 +14,10 @@ ScriptLoader.importModules([
"logger",
"subscription",
"policy-manager",
- "requestpolicy-service"
+ "requestpolicy-service",
+ "observer-manager"
], this);
-Logger.dump(" p!! ");
-
const COMMON_STRINGS = [
'preferences',
@@ -221,9 +220,6 @@ common.localize = function(stringNames) {
};
-Services.scriptloader.loadSubScript(
- "chrome://requestpolicy/content/lib/observer-manager.js", this);
-
$(function() {
common.localize(COMMON_STRINGS);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list