[Pkg-mozext-commits] [firetray] 330/399: make firetray.Utils.timer() API more readable

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:24:08 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch dfsg-clean
in repository firetray.

commit 5dce03778d7335a6e398c5809eb994f7ef306a1e
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Thu Dec 13 19:14:45 2012 +0100

    make firetray.Utils.timer() API more readable
---
 src/modules/FiretrayHandler.jsm |   49 +++++++++++++++++++++------------------
 src/modules/commons.js          |    2 +-
 2 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index 463ab41..a2e4a40 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -192,16 +192,16 @@ firetray.Handler = {
     case "before-first-paint":
       log.debug("before-first-paint: "+subject.baseURI);
       firetray.Utils.removeObservers(firetray.Handler, [ "before-first-paint" ]);
-      firetray.Utils.timer(function() {
-
-        if (firetray.Utils.prefService.getBoolPref('start_hidden')) {
-          log.debug("start_hidden");
-          firetray.Handler.hideAllWindows();
-        }
-
-        firetray.Handler.appStarted = true;
-        log.debug("*** appStarted ***");
-      }, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
+      firetray.Utils.timer(FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS,
+        Ci.nsITimer.TYPE_ONE_SHOT, function() {
+          if (firetray.Utils.prefService.getBoolPref('start_hidden')) {
+            log.debug("start_hidden");
+            firetray.Handler.hideAllWindows();
+          }
+
+          firetray.Handler.appStarted = true;
+          log.debug("*** appStarted ***");
+        });
       break;
 
     case "xpcom-will-shutdown":
@@ -327,10 +327,11 @@ firetray.Handler = {
 
       // FIXME: obviously we need to wait to avoid seg fault on jsapi.cpp:827
       // 827         if (t->data.requestDepth) {
-      firetray.Utils.timer(function() {
-        for(var key in firetray.Handler.windows) break;
-        firetray.Handler.windows[key].chromeWin.open(home);
-      }, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
+      firetray.Utils.timer(FIRETRAY_DELAY_NOWAIT_MILLISECONDS,
+        Ci.nsITimer.TYPE_ONE_SHOT, function() {
+          for(var key in firetray.Handler.windows) break;
+          firetray.Handler.windows[key].chromeWin.open(home);
+        });
     } catch (x) { log.error(x); }
   },
 
@@ -345,11 +346,12 @@ firetray.Handler = {
 
   quitApplication: function() {
     try {
-      firetray.Utils.timer(function() {
-        let appStartup = Cc['@mozilla.org/toolkit/app-startup;1']
-          .getService(Ci.nsIAppStartup);
-        appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
-      }, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
+      firetray.Utils.timer(FIRETRAY_DELAY_NOWAIT_MILLISECONDS,
+        Ci.nsITimer.TYPE_ONE_SHOT, function() {
+          let appStartup = Cc['@mozilla.org/toolkit/app-startup;1']
+                .getService(Ci.nsIAppStartup);
+          appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
+        });
     } catch (x) { log.error(x); }
   },
 
@@ -465,10 +467,11 @@ firetray.VersionChangeHandler = {
     }
 
     if (tabmail) {
-      firetray.Utils.timer(function() {
-        log.debug("openMailTab");
-        tabmail.openTab("contentTab", {contentPage: url});
-      }, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
+      firetray.Utils.timer(FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS,
+        Ci.nsITimer.TYPE_ONE_SHOT, function() {
+          log.debug("openMailTab");
+          tabmail.openTab("contentTab", {contentPage: url});
+        });
     }
   },
 
diff --git a/src/modules/commons.js b/src/modules/commons.js
index 7de2854..bd2ddc0 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -225,7 +225,7 @@ firetray.Utils = {
     return list;
   },
 
-  timer: function(callback, delay, timerType) {
+  timer: function(delay, timerType, callback) {
     var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
     timer.initWithCallback({ notify: callback },
       delay, timerType);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git



More information about the Pkg-mozext-commits mailing list