[Pkg-mozext-commits] [requestpolicy] 113/280: [refact] some startup-related issues
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:30:08 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 4defb12dec5870e1d08234b7c97e72d6d3d0ecd5
Author: Martin Kimmerle <dev at 256k.de>
Date: Tue Jan 6 01:49:21 2015 +0100
[refact] some startup-related issues
e.g. rpService.init() has been eliminated -- instead: startup fn
---
src/content/lib/content-policy.jsm | 4 +-
src/content/lib/process-environment.jsm | 3 +-
src/content/main/requestpolicy-service.jsm | 73 +++++++++---------------------
3 files changed, 25 insertions(+), 55 deletions(-)
diff --git a/src/content/lib/content-policy.jsm b/src/content/lib/content-policy.jsm
index 7c3efac..aec0c92 100644
--- a/src/content/lib/content-policy.jsm
+++ b/src/content/lib/content-policy.jsm
@@ -56,7 +56,7 @@ let PolicyImplementation = (function() {
/**
* Registers the content policy on startup.
*/
- self.init = function() {
+ ProcessEnvironment.enqueueStartupFunction(function() {
Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(self.classID, self.classDescription,
self.contractID, self);
@@ -74,7 +74,7 @@ let PolicyImplementation = (function() {
Cc['@mozilla.org/uriloader/external-helper-app-service;1']
.getService(Ci.nsIMIMEService);
}
- };
+ });
ProcessEnvironment.pushShutdownFunction(function() {
diff --git a/src/content/lib/process-environment.jsm b/src/content/lib/process-environment.jsm
index 5c9eb60..6cb4c35 100644
--- a/src/content/lib/process-environment.jsm
+++ b/src/content/lib/process-environment.jsm
@@ -25,7 +25,7 @@ const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
-let EXPORTED_SYMBOLS = ["ProcessEnvironment"];
+let EXPORTED_SYMBOLS = ["ProcessEnvironment", "Environment"];
Cu.import("resource://gre/modules/Services.jsm");
@@ -123,6 +123,7 @@ if (ProcessEnvironment.isMainProcess) {
ScriptLoader.importModule("lib/logger", globalScope);
ScriptLoader.importModules([
"main/requestpolicy-service",
+ "lib/content-policy",
"main/window-manager",
"main/about-uri"
], globalScope);
diff --git a/src/content/main/requestpolicy-service.jsm b/src/content/main/requestpolicy-service.jsm
index 47b426d..6a18252 100644
--- a/src/content/main/requestpolicy-service.jsm
+++ b/src/content/main/requestpolicy-service.jsm
@@ -40,7 +40,6 @@ ScriptLoader.importModules([
"lib/request-processor",
"lib/subscription",
"lib/utils",
- "lib/content-policy",
"lib/utils/constants",
"lib/process-environment"
], this);
@@ -54,8 +53,6 @@ let rpService = (function() {
// Internal Data
// /////////////////////////////////////////////////////////////////////////
- let rpServiceInitialized = false;
-
let conflictingExtensions = [];
let compatibilityRules = [];
let topLevelDocTranslationRules = {};
@@ -93,28 +90,6 @@ let rpService = (function() {
Services.prefs.savePrefFile(null);
}
- function init() {
- if (rpServiceInitialized) {
- return;
- }
- rpServiceInitialized = true;
-
- try {
- PolicyImplementation.init();
- register();
-
- // TODO:
- //initializePrivateBrowsing();
-
- // Note that we don't load user preferences at this point because the user
- // preferences may not be ready. If we tried right now, we may get the
- // default preferences.
- } catch(e) {
- // in case the libraries could not be loaded, the Logger is not available
- Logger.severeError("exception from init(): " + e, e);
- }
- }
-
function initializeExtensionCompatibility() {
if (compatibilityRules.length != 0) {
@@ -381,22 +356,6 @@ let rpService = (function() {
subscriptions.update(updateCompleted, serials, defaultPolicy);
}
- function register() {
- ProcessEnvironment.obMan.observe({
- "http-on-modify-request": self.observe,
- "sessionstore-windows-restored": self.observe,
- "private-browsing": self.observe,
- SUBSCRIPTION_UPDATED_TOPIC: self.observe,
- SUBSCRIPTION_ADDED_TOPIC: self.observe,
- SUBSCRIPTION_REMOVED_TOPIC: self.observe
- });
- AddonManager.addAddonListener(addonListener);
- }
-
- function unregister() {
- AddonManager.removeAddonListener(addonListener);
- }
-
// TODO: fix this
function initializePrivateBrowsing() {
try {
@@ -437,9 +396,8 @@ let rpService = (function() {
// startup and shutdown functions
// /////////////////////////////////////////////////////////////////////////
+ // prepare back-end
ProcessEnvironment.enqueueStartupFunction(function() {
- init();
-
loadConfigAndRules();
// Detect other installed extensions and the current application and do
// what is needed to allow their requests.
@@ -447,21 +405,32 @@ let rpService = (function() {
initializeApplicationCompatibility();
});
+ // start observers / listeners
+ ProcessEnvironment.enqueueStartupFunction(function() {
+ ProcessEnvironment.obMan.observe({
+ "http-on-modify-request": self.observe,
+ "sessionstore-windows-restored": self.observe,
+ "private-browsing": self.observe,
+ SUBSCRIPTION_UPDATED_TOPIC: self.observe,
+ SUBSCRIPTION_ADDED_TOPIC: self.observe,
+ SUBSCRIPTION_REMOVED_TOPIC: self.observe
+ });
+ AddonManager.addAddonListener(addonListener);
+ });
+
+ // stop observers / listeners
+ ProcessEnvironment.pushShutdownFunction(function() {
+ AddonManager.removeAddonListener(addonListener);
+ });
+
ProcessEnvironment.pushShutdownFunction(function(data, reason) {
if (reason == C.ADDON_DISABLE || reason == C.ADDON_UNINSTALL) {
+ // TODO: Handle uninstallation in bootstrap.js, not here, RP might be
+ // disabled when being uninstalled.
handleUninstallOrDisable();
}
- unregister();
- PolicyImplementation.shutdown(data, reason);
- rpServiceInitialized = false;
});
- // TODO: Handle uninstallation in bootstrap.js, not here, RP might be disabled
- // when being uninstalled.
- //ProcessEnvironment.registerUninstallFunction(function(data, reason) {
- // handleUninstallOrDisable();
- //});
-
--
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