Bug 1024362 - Correct the Alarm API's coding style. r=henry
authorGene Lian <clian@mozilla.com>
Thu, 12 Jun 2014 16:33:56 +0800
changeset 190241 cf8ea02849c8dd7a3ce9e60a3bcc3bf70248d731
parent 190240 470c347ae1dee18fea3a9a6923e601cb1387ead4
child 190242 459d1c1055bf136398d2a67ad15031f290e84d17
push id27003
push userkwierso@gmail.com
push dateTue, 24 Jun 2014 01:56:11 +0000
treeherdermozilla-central@e86b84998b18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershenry
bugs1024362
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1024362 - Correct the Alarm API's coding style. r=henry
dom/alarm/AlarmDB.jsm
dom/alarm/AlarmService.jsm
dom/alarm/AlarmsManager.js
--- a/dom/alarm/AlarmDB.jsm
+++ b/dom/alarm/AlarmDB.jsm
@@ -31,55 +31,52 @@ AlarmDB.prototype = {
   __proto__: IndexedDBHelper.prototype,
 
   init: function init() {
     debug("init()");
 
     this.initDBHelper(ALARMDB_NAME, ALARMDB_VERSION, [ALARMSTORE_NAME]);
   },
 
-  upgradeSchema: function upgradeSchema(aTransaction, aDb, aOldVersion, aNewVersion) {
+  upgradeSchema: function upgradeSchema(aTransaction, aDb,
+                                        aOldVersion, aNewVersion) {
     debug("upgradeSchema()");
 
-    let objectStore = aDb.createObjectStore(ALARMSTORE_NAME, { keyPath: "id", autoIncrement: true });
+    let objStore =
+      aDb.createObjectStore(ALARMSTORE_NAME,
+                            { keyPath: "id", autoIncrement: true });
 
-    objectStore.createIndex("date",           "date",           { unique: false });
-    objectStore.createIndex("ignoreTimezone", "ignoreTimezone", { unique: false });
-    objectStore.createIndex("timezoneOffset", "timezoneOffset", { unique: false });
-    objectStore.createIndex("data",           "data",           { unique: false });
-    objectStore.createIndex("pageURL",        "pageURL",        { unique: false });
-    objectStore.createIndex("manifestURL",    "manifestURL",    { unique: false });
+    objStore.createIndex("date",           "date",           { unique: false });
+    objStore.createIndex("ignoreTimezone", "ignoreTimezone", { unique: false });
+    objStore.createIndex("timezoneOffset", "timezoneOffset", { unique: false });
+    objStore.createIndex("data",           "data",           { unique: false });
+    objStore.createIndex("pageURL",        "pageURL",        { unique: false });
+    objStore.createIndex("manifestURL",    "manifestURL",    { unique: false });
 
     debug("Created object stores and indexes");
   },
 
   /**
    * @param aAlarm
    *        The record to be added.
    * @param aSuccessCb
    *        Callback function to invoke with result ID.
    * @param aErrorCb [optional]
    *        Callback function to invoke when there was an error.
    */
   add: function add(aAlarm, aSuccessCb, aErrorCb) {
     debug("add()");
 
-    this.newTxn(
-      "readwrite",
-      ALARMSTORE_NAME,
-      function txnCb(aTxn, aStore) {
-        debug("Going to add " + JSON.stringify(aAlarm));
-        aStore.put(aAlarm).onsuccess = function setTxnResult(aEvent) {
-          aTxn.result = aEvent.target.result;
-          debug("Request successful. New record ID: " + aTxn.result);
-        };
-      },
-      aSuccessCb,
-      aErrorCb
-    );
+    this.newTxn("readwrite", ALARMSTORE_NAME, function txnCb(aTxn, aStore) {
+      debug("Going to add " + JSON.stringify(aAlarm));
+      aStore.put(aAlarm).onsuccess = function setTxnResult(aEvent) {
+        aTxn.result = aEvent.target.result;
+        debug("Request successful. New record ID: " + aTxn.result);
+      };
+    }, aSuccessCb, aErrorCb);
   },
 
   /**
    * @param aId
    *        The ID of record to be removed.
    * @param aManifestURL
    *        The manifest URL of the app that alarm belongs to.
    *        If null, directly remove the ID record; otherwise,
@@ -87,69 +84,57 @@ AlarmDB.prototype = {
    * @param aSuccessCb
    *        Callback function to invoke with result.
    * @param aErrorCb [optional]
    *        Callback function to invoke when there was an error.
    */
   remove: function remove(aId, aManifestURL, aSuccessCb, aErrorCb) {
     debug("remove()");
 
-    this.newTxn(
-      "readwrite",
-      ALARMSTORE_NAME,
-      function txnCb(aTxn, aStore) {
-        debug("Going to remove " + aId);
+    this.newTxn("readwrite", ALARMSTORE_NAME, function txnCb(aTxn, aStore) {
+      debug("Going to remove " + aId);
 
-        // Look up the existing record and compare the manifestURL
-        // to see if the alarm to be removed belongs to this app.
-        aStore.get(aId).onsuccess = function doRemove(aEvent) {
-          let alarm = aEvent.target.result;
+      // Look up the existing record and compare the manifestURL
+      // to see if the alarm to be removed belongs to this app.
+      aStore.get(aId).onsuccess = function doRemove(aEvent) {
+        let alarm = aEvent.target.result;
 
-          if (!alarm) {
-            debug("Alarm doesn't exist. No need to remove it.");
-            return;
-          }
+        if (!alarm) {
+          debug("Alarm doesn't exist. No need to remove it.");
+          return;
+        }
 
-          if (aManifestURL && aManifestURL != alarm.manifestURL) {
-            debug("Cannot remove the alarm added by other apps.");
-            return;
-          }
+        if (aManifestURL && aManifestURL != alarm.manifestURL) {
+          debug("Cannot remove the alarm added by other apps.");
+          return;
+        }
 
-          aStore.delete(aId);
-        };
-      },
-      aSuccessCb,
-      aErrorCb
-    );
+        aStore.delete(aId);
+      };
+    }, aSuccessCb, aErrorCb);
   },
 
   /**
    * @param aManifestURL
    *        The manifest URL of the app that alarms belong to.
    *        If null, directly return all alarms; otherwise,
    *        only return the alarms that belong to this app.
    * @param aSuccessCb
    *        Callback function to invoke with result array.
    * @param aErrorCb [optional]
    *        Callback function to invoke when there was an error.
    */
   getAll: function getAll(aManifestURL, aSuccessCb, aErrorCb) {
     debug("getAll()");
 
-    this.newTxn(
-      "readonly",
-      ALARMSTORE_NAME,
-      function txnCb(aTxn, aStore) {
-        if (!aTxn.result) {
-          aTxn.result = [];
-        }
+    this.newTxn("readonly", ALARMSTORE_NAME, function txnCb(aTxn, aStore) {
+      if (!aTxn.result) {
+        aTxn.result = [];
+      }
 
-        let index = aStore.index("manifestURL");
-        index.mozGetAll(aManifestURL).onsuccess = function setTxnResult(aEvent) {
-          aTxn.result = aEvent.target.result;
-          debug("Request successful. Record count: " + aTxn.result.length);
-        };
-      },
-      aSuccessCb,
-      aErrorCb
-    );
+      let index = aStore.index("manifestURL");
+      index.mozGetAll(aManifestURL).onsuccess = function setTxnResult(aEvent) {
+        aTxn.result = aEvent.target.result;
+        debug("Request successful. Record count: " + aTxn.result.length);
+      };
+    }, aSuccessCb, aErrorCb);
   }
 };
--- a/dom/alarm/AlarmService.jsm
+++ b/dom/alarm/AlarmService.jsm
@@ -24,45 +24,47 @@ XPCOMUtils.defineLazyGetter(this, "appsS
   return Cc["@mozilla.org/AppsService;1"].getService(Ci.nsIAppsService);
 });
 
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
                                    "@mozilla.org/parentprocessmessagemanager;1",
                                    "nsIMessageListenerManager");
 
 XPCOMUtils.defineLazyGetter(this, "messenger", function() {
-  return Cc["@mozilla.org/system-message-internal;1"].getService(Ci.nsISystemMessagesInternal);
+  return Cc["@mozilla.org/system-message-internal;1"]
+           .getService(Ci.nsISystemMessagesInternal);
 });
 
 XPCOMUtils.defineLazyGetter(this, "powerManagerService", function() {
-  return Cc["@mozilla.org/power/powermanagerservice;1"].getService(Ci.nsIPowerManagerService);
+  return Cc["@mozilla.org/power/powermanagerservice;1"]
+           .getService(Ci.nsIPowerManagerService);
 });
 
 /**
  * AlarmService provides an API to schedule alarms using the device's RTC.
  *
  * AlarmService is primarily used by the mozAlarms API (navigator.mozAlarms)
  * which uses IPC to communicate with the service.
  *
  * AlarmService can also be used by Gecko code by importing the module and then
  * using AlarmService.add() and AlarmService.remove(). Only Gecko code running
  * in the parent process should do this.
  */
 
 this.AlarmService = {
   init: function init() {
     debug("init()");
+
     Services.obs.addObserver(this, "profile-change-teardown", false);
     Services.obs.addObserver(this, "webapps-clear-data",false);
 
     this._currentTimezoneOffset = (new Date()).getTimezoneOffset();
 
-    let alarmHalService =
-      this._alarmHalService = Cc["@mozilla.org/alarmHalService;1"]
-                              .getService(Ci.nsIAlarmHalService);
+    let alarmHalService = this._alarmHalService =
+      Cc["@mozilla.org/alarmHalService;1"].getService(Ci.nsIAlarmHalService);
 
     alarmHalService.setAlarmFiredCb(this._onAlarmFired.bind(this));
     alarmHalService.setTimezoneChangedCb(this._onTimezoneChanged.bind(this));
 
     // Add the messages to be listened to.
     this._messages = ["AlarmsManager:GetAll",
                       "AlarmsManager:Add",
                       "AlarmsManager:Remove"];
@@ -104,54 +106,52 @@ this.AlarmService = {
 
     // To prevent the hacked child process from sending commands to parent
     // to schedule alarms, we need to check its permission and manifest URL.
     if (this._messages.indexOf(aMessage.name) != -1) {
       if (!aMessage.target.assertPermission("alarms")) {
         debug("Got message from a child process with no 'alarms' permission.");
         return null;
       }
+
       if (!aMessage.target.assertContainApp(json.manifestURL)) {
         debug("Got message from a child process containing illegal manifest URL.");
         return null;
       }
     }
 
     let mm = aMessage.target.QueryInterface(Ci.nsIMessageSender);
+
     switch (aMessage.name) {
       case "AlarmsManager:GetAll":
-        this._db.getAll(
-          json.manifestURL,
+        this._db.getAll(json.manifestURL,
           function getAllSuccessCb(aAlarms) {
             debug("Callback after getting alarms from database: " +
                   JSON.stringify(aAlarms));
+
             this._sendAsyncMessage(mm, "GetAll", true, json.requestId, aAlarms);
           }.bind(this),
           function getAllErrorCb(aErrorMsg) {
             this._sendAsyncMessage(mm, "GetAll", false, json.requestId, aErrorMsg);
-          }.bind(this)
-        );
+          }.bind(this));
         break;
 
       case "AlarmsManager:Add":
         // Prepare a record for the new alarm to be added.
-        let newAlarm = {
-          date: json.date,
-          ignoreTimezone: json.ignoreTimezone,
-          data: json.data,
-          pageURL: json.pageURL,
-          manifestURL: json.manifestURL
-        };
+        let newAlarm = { date: json.date,
+                         ignoreTimezone: json.ignoreTimezone,
+                         data: json.data,
+                         pageURL: json.pageURL,
+                         manifestURL: json.manifestURL };
 
         this.add(newAlarm, null,
           // Receives the alarm ID as the last argument.
           this._sendAsyncMessage.bind(this, mm, "Add", true, json.requestId),
           // Receives the error message as the last argument.
-          this._sendAsyncMessage.bind(this, mm, "Add", false, json.requestId)
-        );
+          this._sendAsyncMessage.bind(this, mm, "Add", false, json.requestId));
         break;
 
       case "AlarmsManager:Remove":
         this.remove(json.id, json.manifestURL);
         break;
 
       default:
         throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
@@ -164,18 +164,17 @@ this.AlarmService = {
     debug("_sendAsyncMessage()");
 
     if (!aMessageManager) {
       debug("Invalid message manager: null");
       throw Components.results.NS_ERROR_FAILURE;
     }
 
     let json = null;
-    switch (aMessageName)
-    {
+    switch (aMessageName) {
       case "Add":
         json = aSuccess ?
           { requestId: aRequestId, id: aData } :
           { requestId: aRequestId, errorMsg: aData };
         break;
 
       case "GetAll":
         json = aSuccess ?
@@ -184,66 +183,63 @@ this.AlarmService = {
         break;
 
       default:
         throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
         break;
     }
 
     aMessageManager.sendAsyncMessage("AlarmsManager:" + aMessageName +
-                                     ":Return:" + (aSuccess ? "OK" : "KO"), json);
+                                       ":Return:" + (aSuccess ? "OK" : "KO"),
+                                     json);
   },
 
   _removeAlarmFromDb: function _removeAlarmFromDb(aId, aManifestURL,
                                                   aRemoveSuccessCb) {
     debug("_removeAlarmFromDb()");
 
     // If the aRemoveSuccessCb is undefined or null, set a dummy callback for
     // it which is needed for _db.remove().
     if (!aRemoveSuccessCb) {
       aRemoveSuccessCb = function removeSuccessCb() {
         debug("Remove alarm from DB successfully.");
       };
     }
 
-    this._db.remove(
-      aId,
-      aManifestURL,
-      aRemoveSuccessCb,
-      function removeErrorCb(aErrorMsg) {
-        throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-      }
-    );
+    this._db.remove(aId, aManifestURL, aRemoveSuccessCb,
+                    function removeErrorCb(aErrorMsg) {
+                      throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
+                    });
   },
 
   /**
    * Create a copy of the alarm that does not expose internal fields to
    * receivers and sticks to the public |respectTimezone| API rather than the
    * boolean |ignoreTimezone| field.
    */
   _publicAlarm: function _publicAlarm(aAlarm) {
-    let alarm = {
-      "id":              aAlarm.id,
-      "date":            aAlarm.date,
-      "respectTimezone": aAlarm.ignoreTimezone ?
-                           "ignoreTimezone" : "honorTimezone",
-      "data":            aAlarm.data
-    };
+    let alarm = { "id": aAlarm.id,
+                  "date": aAlarm.date,
+                  "respectTimezone": aAlarm.ignoreTimezone ?
+                                       "ignoreTimezone" : "honorTimezone",
+                  "data": aAlarm.data };
 
     return alarm;
   },
 
   _fireSystemMessage: function _fireSystemMessage(aAlarm) {
     debug("Fire system message: " + JSON.stringify(aAlarm));
 
     let manifestURI = Services.io.newURI(aAlarm.manifestURL, null, null);
     let pageURI = Services.io.newURI(aAlarm.pageURL, null, null);
 
-    messenger.sendMessage("alarm", this._publicAlarm(aAlarm),
-                          pageURI, manifestURI);
+    messenger.sendMessage("alarm",
+                          this._publicAlarm(aAlarm),
+                          pageURI,
+                          manifestURI);
   },
 
   _notifyAlarmObserver: function _notifyAlarmObserver(aAlarm) {
     debug("_notifyAlarmObserver()");
 
     if (aAlarm.manifestURL) {
       this._fireSystemMessage(aAlarm);
     } else if (typeof aAlarm.alarmFiredCb === "function") {
@@ -271,31 +267,31 @@ this.AlarmService = {
       if (nextAlarmTime <= Date.now()) {
         this._removeAlarmFromDb(nextAlarm.id, null);
         this._notifyAlarmObserver(nextAlarm);
       } else {
         this._currentAlarm = nextAlarm;
         break;
       }
     }
+
     this._debugCurrentAlarm();
   },
 
   _onTimezoneChanged: function _onTimezoneChanged(aTimezoneOffset) {
     debug("_onTimezoneChanged()");
 
     this._currentTimezoneOffset = aTimezoneOffset;
     this._restoreAlarmsFromDb();
   },
 
   _restoreAlarmsFromDb: function _restoreAlarmsFromDb() {
     debug("_restoreAlarmsFromDb()");
 
-    this._db.getAll(
-      null,
+    this._db.getAll(null,
       function getAllSuccessCb(aAlarms) {
         debug("Callback after getting alarms from database: " +
               JSON.stringify(aAlarms));
 
         // Clear any alarms set or queued in the cache.
         let alarmQueue = this._alarmQueue;
         alarmQueue.length = 0;
         this._currentAlarm = null;
@@ -306,28 +302,27 @@ this.AlarmService = {
           if (this._getAlarmTime(aAlarm) > Date.now()) {
             alarmQueue.push(aAlarm);
           } else {
             this._removeAlarmFromDb(aAlarm.id, null);
             this._notifyAlarmObserver(aAlarm);
           }
         }.bind(this));
 
-        // Set the next alarm from queue.
+        // Set the next alarm from the queue.
         if (alarmQueue.length) {
           alarmQueue.sort(this._sortAlarmByTimeStamps.bind(this));
           this._currentAlarm = alarmQueue.shift();
         }
 
         this._debugCurrentAlarm();
       }.bind(this),
       function getAllErrorCb(aErrorMsg) {
         throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-      }
-    );
+      });
   },
 
   _getAlarmTime: function _getAlarmTime(aAlarm) {
     // Avoid casting a Date object to a Date again to
     // preserve milliseconds. See bug 810973.
     let alarmTime;
     if (aAlarm.date instanceof Date) {
       alarmTime = aAlarm.date.getTime();
@@ -336,17 +331,18 @@ this.AlarmService = {
     }
 
     // For an alarm specified with "ignoreTimezone", it must be fired respect
     // to the user's timezone.  Supposing an alarm was set at 7:00pm at Tokyo,
     // it must be gone off at 7:00pm respect to Paris' local time when the user
     // is located at Paris.  We can adjust the alarm UTC time by calculating
     // the difference of the orginal timezone and the current timezone.
     if (aAlarm.ignoreTimezone) {
-       alarmTime += (this._currentTimezoneOffset - aAlarm.timezoneOffset) * 60000;
+      alarmTime +=
+        (this._currentTimezoneOffset - aAlarm.timezoneOffset) * 60000;
     }
     return alarmTime;
   },
 
   _sortAlarmByTimeStamps: function _sortAlarmByTimeStamps(aAlarm1, aAlarm2) {
     return this._getAlarmTime(aAlarm1) - this._getAlarmTime(aAlarm2);
   },
 
@@ -397,18 +393,17 @@ this.AlarmService = {
 
     if (!aNewAlarm.date) {
       aErrorCb("alarm.date is null");
       return;
     }
 
     aNewAlarm['timezoneOffset'] = this._currentTimezoneOffset;
 
-    this._db.add(
-      aNewAlarm,
+    this._db.add(aNewAlarm,
       function addSuccessCb(aNewId) {
         debug("Callback after adding alarm in database.");
 
         aNewAlarm['id'] = aNewId;
 
         // Now that the alarm has been added to the database, we can tack on
         // the non-serializable callback to the in-memory object.
         aNewAlarm['alarmFiredCb'] = aAlarmFiredCb;
@@ -417,17 +412,17 @@ this.AlarmService = {
         if (this._currentAlarm == null) {
           this._currentAlarm = aNewAlarm;
           this._debugCurrentAlarm();
           aSuccessCb(aNewId);
           return;
         }
 
         // If the new alarm is earlier than the current alarm, swap them and
-        // push the previous alarm back to queue.
+        // push the previous alarm back to the queue.
         let alarmQueue = this._alarmQueue;
         let aNewAlarmTime = this._getAlarmTime(aNewAlarm);
         let currentAlarmTime = this._getAlarmTime(this._currentAlarm);
         if (aNewAlarmTime < currentAlarmTime) {
           alarmQueue.unshift(this._currentAlarm);
           this._currentAlarm = aNewAlarm;
           this._debugCurrentAlarm();
           aSuccessCb(aNewId);
@@ -437,34 +432,32 @@ this.AlarmService = {
         // Push the new alarm in the queue.
         alarmQueue.push(aNewAlarm);
         alarmQueue.sort(this._sortAlarmByTimeStamps.bind(this));
         this._debugCurrentAlarm();
         aSuccessCb(aNewId);
       }.bind(this),
       function addErrorCb(aErrorMsg) {
         aErrorCb(aErrorMsg);
-      }.bind(this)
-    );
+      }.bind(this));
   },
 
   /*
    * Remove the alarm associated with an ID.
    *
    * @param number aAlarmId
    *        The ID of the alarm to be removed.
    * @param string aManifestURL
    *        Manifest URL for application which added the alarm. (Optional)
    * @returns void
    */
   remove: function(aAlarmId, aManifestURL) {
     debug("remove(" + aAlarmId + ", " + aManifestURL + ")");
-    this._removeAlarmFromDb(
-      aAlarmId,
-      aManifestURL,
+
+    this._removeAlarmFromDb(aAlarmId, aManifestURL,
       function removeSuccessCb() {
         debug("Callback after removing alarm from database.");
 
         // If there are no alarms set, nothing to do.
         if (!this._currentAlarm) {
           debug("No alarms set.");
           return;
         }
@@ -483,35 +476,37 @@ this.AlarmService = {
               break;
             }
           }
           this._debugCurrentAlarm();
           return;
         }
 
         // The alarm to be removed is the current alarm reset the next alarm
-        // from queue if any.
+        // from the queue if any.
         if (alarmQueue.length) {
           this._currentAlarm = alarmQueue.shift();
           this._debugCurrentAlarm();
           return;
         }
 
         // No alarm waiting to be set in the queue.
         this._currentAlarm = null;
         this._debugCurrentAlarm();
-      }.bind(this)
-    );
+      }.bind(this));
   },
 
   observe: function(aSubject, aTopic, aData) {
+    debug("observe(): " + aTopic);
+
     switch (aTopic) {
       case "profile-change-teardown":
         this.uninit();
         break;
+
       case "webapps-clear-data":
         let params =
           aSubject.QueryInterface(Ci.mozIApplicationClearPrivateDataParams);
         if (!params) {
           debug("Error! Fail to remove alarms for an uninstalled app.");
           return;
         }
 
@@ -521,33 +516,32 @@ this.AlarmService = {
         }
 
         let manifestURL = appsService.getManifestURLByLocalId(params.appId);
         if (!manifestURL) {
           debug("Error! Fail to remove alarms for an uninstalled app.");
           return;
         }
 
-        this._db.getAll(
-          manifestURL,
+        this._db.getAll(manifestURL,
           function getAllSuccessCb(aAlarms) {
             aAlarms.forEach(function removeAlarm(aAlarm) {
               this.remove(aAlarm.id, manifestURL);
             }, this);
           }.bind(this),
           function getAllErrorCb(aErrorMsg) {
             throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-          }
-        );
+          });
         break;
     }
   },
 
   uninit: function uninit() {
     debug("uninit()");
+
     Services.obs.removeObserver(this, "profile-change-teardown");
     Services.obs.removeObserver(this, "webapps-clear-data");
 
     this._messages.forEach(function(aMsgName) {
       ppmm.removeMessageListener(aMsgName, this);
     }.bind(this));
     ppmm = null;
 
--- a/dom/alarm/AlarmsManager.js
+++ b/dom/alarm/AlarmsManager.js
@@ -13,23 +13,21 @@ function debug(aStr) {
 }
 
 const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
 
-function AlarmsManager()
-{
+function AlarmsManager() {
   debug("Constructor");
 }
 
 AlarmsManager.prototype = {
-
   __proto__: DOMRequestIpcHelper.prototype,
 
   contractID : "@mozilla.org/alarmsManager;1",
 
   classID : Components.ID("{fea1e884-9b05-11e1-9b64-87a7016c3860}"),
 
   QueryInterface : XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer,
                                           Ci.nsISupportsWeakReference,
@@ -43,60 +41,56 @@ AlarmsManager.prototype = {
       throw Components.results.NS_ERROR_FAILURE;
     }
 
     if (!aDate) {
       throw Components.results.NS_ERROR_INVALID_ARG;
     }
 
     let isIgnoreTimezone = true;
+
     switch (aRespectTimezone) {
       case "honorTimezone":
         isIgnoreTimezone = false;
         break;
 
       case "ignoreTimezone":
         isIgnoreTimezone = true;
         break;
 
       default:
         throw Components.results.NS_ERROR_INVALID_ARG;
         break;
     }
 
     let request = this.createRequest();
-    this._cpmm.sendAsyncMessage(
-      "AlarmsManager:Add",
-      { requestId: this.getRequestId(request),
-        date: aDate,
-        ignoreTimezone: isIgnoreTimezone,
-        data: aData,
-        pageURL: this._pageURL,
-        manifestURL: this._manifestURL }
-    );
+    this._cpmm.sendAsyncMessage("AlarmsManager:Add",
+                                { requestId: this.getRequestId(request),
+                                  date: aDate,
+                                  ignoreTimezone: isIgnoreTimezone,
+                                  data: aData,
+                                  pageURL: this._pageURL,
+                                  manifestURL: this._manifestURL });
     return request;
   },
 
   remove: function remove(aId) {
     debug("remove()");
 
-    this._cpmm.sendAsyncMessage(
-      "AlarmsManager:Remove",
-      { id: aId, manifestURL: this._manifestURL }
-    );
+    this._cpmm.sendAsyncMessage("AlarmsManager:Remove",
+                                { id: aId, manifestURL: this._manifestURL });
   },
 
   getAll: function getAll() {
     debug("getAll()");
 
     let request = this.createRequest();
-    this._cpmm.sendAsyncMessage(
-      "AlarmsManager:GetAll",
-      { requestId: this.getRequestId(request), manifestURL: this._manifestURL }
-    );
+    this._cpmm.sendAsyncMessage("AlarmsManager:GetAll",
+                                { requestId: this.getRequestId(request),
+                                  manifestURL: this._manifestURL });
     return request;
   },
 
   receiveMessage: function receiveMessage(aMessage) {
     debug("receiveMessage(): " + aMessage.name);
 
     let json = aMessage.json;
     let request = this.getRequest(json.requestId);
@@ -110,39 +104,41 @@ AlarmsManager.prototype = {
       case "AlarmsManager:Add:Return:OK":
         Services.DOMRequest.fireSuccess(request, json.id);
         break;
 
       case "AlarmsManager:GetAll:Return:OK":
         // We don't need to expose everything to the web content.
         let alarms = [];
         json.alarms.forEach(function trimAlarmInfo(aAlarm) {
-          let alarm = { "id":              aAlarm.id,
-                        "date":            aAlarm.date,
+          let alarm = { "id": aAlarm.id,
+                        "date": aAlarm.date,
                         "respectTimezone": aAlarm.ignoreTimezone ?
                                              "ignoreTimezone" : "honorTimezone",
-                        "data":            aAlarm.data };
+                        "data": aAlarm.data };
           alarms.push(alarm);
         });
+
         Services.DOMRequest.fireSuccess(request,
                                         Cu.cloneInto(alarms, this._window));
         break;
 
       case "AlarmsManager:Add:Return:KO":
         Services.DOMRequest.fireError(request, json.errorMsg);
         break;
 
       case "AlarmsManager:GetAll:Return:KO":
         Services.DOMRequest.fireError(request, json.errorMsg);
         break;
 
       default:
         debug("Wrong message: " + aMessage.name);
         break;
     }
+
     this.removeRequest(json.requestId);
    },
 
   // nsIDOMGlobalPropertyInitializer implementation
   init: function init(aWindow) {
     debug("init()");
 
     this._cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]