author | Gene Lian <clian@mozilla.com> |
Thu, 16 Aug 2012 10:46:40 +0800 | |
changeset 108487 | d51a3bf72b9c549903868a998783bf3ba3f69130 |
parent 108486 | 3e2cbfcaccd444308bf24a7f28e6f4f6284f4013 |
child 108488 | eb0deea718b3184c1056587a77612baa70721a4a |
push id | 1490 |
push user | akeybl@mozilla.com |
push date | Mon, 08 Oct 2012 18:29:50 +0000 |
treeherder | mozilla-beta@f335e7dacdc1 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | vivien |
bugs | 777226 |
milestone | 17.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
|
--- a/dom/alarm/AlarmService.jsm +++ b/dom/alarm/AlarmService.jsm @@ -300,22 +300,26 @@ let AlarmService = { 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; - - // only add the alarm that is valid - let nowTime = Date.now(); + + // Only restore the alarm that's not yet expired; otherwise, + // fire a system message for it and remove it from database. aAlarms.forEach(function addAlarm(aAlarm) { - if (this._getAlarmTime(aAlarm) > nowTime) + if (this._getAlarmTime(aAlarm) > Date.now()) { alarmQueue.push(aAlarm); + } else { + this._fireSystemMessage(aAlarm); + this._removeAlarmFromDb(aAlarm.id, null); + } }.bind(this)); // set the next alarm from queue if (alarmQueue.length) { alarmQueue.sort(this._sortAlarmByTimeStamps.bind(this)); this._currentAlarm = alarmQueue.shift(); } @@ -324,17 +328,17 @@ let AlarmService = { function getAllErrorCb(aErrorMsg) { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; } ); }, _getAlarmTime: function _getAlarmTime(aAlarm) { let alarmTime = (new Date(aAlarm.date)).getTime(); - + // 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.