Bug 1182358 - RequestSyncService.jsm should use AlarmService instead nsITimer, r=nsm
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 14 Aug 2015 17:47:42 +0100
changeset 257888 5f2d07e6f367a169233df2fc91f864ddbfcb28ae
parent 257864 e4d93d205e27f83c9319a73970b25ce00fe14044
child 257889 4c245c476379f1964db88a3647e0793ffa5de0c5
push id29233
push userkwierso@gmail.com
push dateFri, 14 Aug 2015 23:32:11 +0000
treeherdermozilla-central@45bea43ad812 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnsm
bugs1182358
milestone43.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 1182358 - RequestSyncService.jsm should use AlarmService instead nsITimer, r=nsm
dom/requestsync/RequestSyncService.jsm
dom/requestsync/tests/mochitest.ini
--- a/dom/requestsync/RequestSyncService.jsm
+++ b/dom/requestsync/RequestSyncService.jsm
@@ -42,16 +42,19 @@ XPCOMUtils.defineLazyServiceGetter(this,
 XPCOMUtils.defineLazyServiceGetter(this, "systemMessenger",
                                    "@mozilla.org/system-message-internal;1",
                                    "nsISystemMessagesInternal");
 
 XPCOMUtils.defineLazyServiceGetter(this, "secMan",
                                    "@mozilla.org/scriptsecuritymanager;1",
                                    "nsIScriptSecurityManager");
 
+XPCOMUtils.defineLazyModuleGetter(this, "AlarmService",
+                                  "resource://gre/modules/AlarmService.jsm");
+
 this.RequestSyncService = {
   __proto__: IndexedDBHelper.prototype,
 
   children: [],
 
   _messages: [ "RequestSync:Register",
                "RequestSync:Unregister",
                "RequestSync:Registrations",
@@ -858,36 +861,35 @@ this.RequestSyncService = {
         }
 
         self.scheduleTimer(aObj);
       }
     });
   },
 
   createTimer: function(aObj) {
-    this._timers[aObj.dbKey] = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-
     let interval = aObj.data.minInterval;
     if (aObj.data.overwrittenMinInterval > 0) {
       interval = aObj.data.overwrittenMinInterval;
     }
 
-    let self = this;
-    this._timers[aObj.dbKey].initWithCallback(function() { self.timeout(aObj); },
-                                              interval * 1000,
-                                              Ci.nsITimer.TYPE_ONE_SHOT);
+    AlarmService.add(
+      { date: new Date(Date.now() + interval * 1000),
+        ignoreTimezone: false },
+      () => this.timeout(aObj),
+      aTimerId => this._timers[aObj.dbKey] = aTimerId);
   },
 
   hasTimer: function(aObj) {
     return (aObj.dbKey in this._timers);
   },
 
   removeTimer: function(aObj) {
     if (aObj.dbKey in this._timers) {
-      this._timers[aObj.dbKey].cancel();
+      AlarmService.remove(this._timers[aObj.dbKey]);
       delete this._timers[aObj.dbKey];
     }
   },
 
   storePendingRequest: function(aObj, aTarget, aRequestID) {
     if (!(aObj.dbKey in this._pendingRequests)) {
       this._pendingRequests[aObj.dbKey] = [];
     }
--- a/dom/requestsync/tests/mochitest.ini
+++ b/dom/requestsync/tests/mochitest.ini
@@ -4,18 +4,23 @@ support-files =
   file_app.template.webapp
   file_app.sjs
   file_basic_app.html
   common_app.js
   common_basic.js
   system_message_chrome_script.js
 
 [test_webidl.html]
+skip-if = os == "android" || toolkit == "gonk"
 [test_minInterval.html]
+skip-if = os == "android" || toolkit == "gonk"
 [test_basic.html]
+skip-if = os == "android" || toolkit == "gonk"
 [test_basic_app.html]
-skip-if = buildapp == 'b2g'
+skip-if = os == "android" || buildapp == 'b2g'
 [test_wakeUp.html]
-skip-if = !(buildapp == 'b2g' && toolkit == 'gonk')
+run-if = buildapp == 'b2g' && toolkit == 'gonk'
 [test_runNow.html]
 run-if = buildapp == 'b2g' && toolkit == 'gonk'
 [test_promise.html]
+skip-if = os == "android" || toolkit == "gonk"
 [test_bug1151082.html]
+skip-if = os == "android" || toolkit == "gonk"