Backout 1dba66cfad9a, ed768b821da1, 23fd9a8d0c9a, 1e90805d96aa, 07425f0e921e (bug 749551) for M3 failures

This commit is contained in:
Ed Morley 2012-07-03 11:23:54 +01:00
parent 35475bfcaa
commit 7a600d2b9c
29 changed files with 2 additions and 1261 deletions

View File

@ -378,9 +378,6 @@ pref("dom.sms.enabled", true);
// Temporary permission hack for WebContacts
pref("dom.mozContacts.enabled", true);
// WebAlarms
pref("dom.mozAlarms.enabled", true);
// WebSettings
pref("dom.mozSettings.enabled", true);

View File

@ -14,7 +14,6 @@ Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/ContactService.jsm');
Cu.import('resource://gre/modules/SettingsChangeNotifier.jsm');
Cu.import('resource://gre/modules/Webapps.jsm');
Cu.import('resource://gre/modules/AlarmService.jsm');
XPCOMUtils.defineLazyServiceGetter(Services, 'env',
'@mozilla.org/process/environment;1',
@ -52,7 +51,7 @@ function addPermissions(urls) {
'indexedDB', 'indexedDB-unlimited', 'webapps-manage', 'offline-app', 'pin-app',
'websettings-read', 'websettings-readwrite',
'content-camera', 'webcontacts-manage', 'wifi-manage', 'desktop-notification',
'geolocation', 'device-storage', 'alarms'
'geolocation', 'device-storage'
];
urls.forEach(function(url) {
url = url.trim();

View File

@ -161,7 +161,6 @@
#endif
@BINPATH@/components/dom_canvas.xpt
@BINPATH@/components/dom_contacts.xpt
@BINPATH@/components/dom_alarm.xpt
@BINPATH@/components/dom_core.xpt
@BINPATH@/components/dom_css.xpt
@BINPATH@/components/dom_devicestorage.xpt
@ -318,8 +317,6 @@
@BINPATH@/components/BrowserElementParent.js
@BINPATH@/components/ContactManager.js
@BINPATH@/components/ContactManager.manifest
@BINPATH@/components/AlarmsManager.js
@BINPATH@/components/AlarmsManager.manifest
@BINPATH@/components/FeedProcessor.manifest
@BINPATH@/components/FeedProcessor.js
@BINPATH@/components/BrowserFeeds.manifest

View File

@ -172,7 +172,6 @@
#endif
@BINPATH@/components/dom_canvas.xpt
@BINPATH@/components/dom_contacts.xpt
@BINPATH@/components/dom_alarm.xpt
@BINPATH@/components/dom_core.xpt
@BINPATH@/components/dom_css.xpt
@BINPATH@/components/dom_devicestorage.xpt
@ -472,8 +471,6 @@
@BINPATH@/components/ContactManager.js
@BINPATH@/components/ContactManager.manifest
@BINPATH@/components/AlarmsManager.js
@BINPATH@/components/AlarmsManager.manifest
#ifdef ENABLE_MARIONETTE
@BINPATH@/chrome/marionette@JAREXT@
@BINPATH@/chrome/marionette.manifest

View File

@ -50,7 +50,6 @@ DIRS += \
battery \
browser-element \
contacts \
alarm \
devicestorage \
file \
media \

View File

@ -1,124 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const EXPORTED_SYMBOLS = ["AlarmDB"];
/* static functions */
const DEBUG = false;
function debug(aStr) {
if (DEBUG)
dump("AlarmDB: " + aStr + "\n");
}
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
const ALARMDB_NAME = "alarms";
const ALARMDB_VERSION = 1;
const ALARMSTORE_NAME = "alarms";
function AlarmDB(aGlobal) {
debug("AlarmDB()");
this._global = aGlobal;
}
AlarmDB.prototype = {
__proto__: IndexedDBHelper.prototype,
init: function init(aGlobal) {
debug("init()");
this.initDBHelper(ALARMDB_NAME, ALARMDB_VERSION, ALARMSTORE_NAME, aGlobal);
},
upgradeSchema: function upgradeSchema(aTransaction, aDb, aOldVersion, aNewVersion) {
debug("upgradeSchema()");
let objectStore = 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 });
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",
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 aSuccessCb
* Callback function to invoke with result.
* @param aErrorCb [optional]
* Callback function to invoke when there was an error.
*/
remove: function remove(aId, aSuccessCb, aErrorCb) {
debug("remove()");
this.newTxn(
"readwrite",
function txnCb(aTxn, aStore) {
debug("Going to remove " + aId);
aStore.delete(aId);
},
aSuccessCb,
aErrorCb
);
},
/**
* @param aSuccessCb
* Callback function to invoke with result array.
* @param aErrorCb [optional]
* Callback function to invoke when there was an error.
*/
getAll: function getAll(aSuccessCb, aErrorCb) {
debug("getAll()");
this.newTxn(
"readonly",
function txnCb(aTxn, aStore) {
if (!aTxn.result)
aTxn.result = {};
aStore.getAll().onsuccess = function setTxnResult(aEvent) {
aTxn.result = aEvent.target.result;
debug("Request successful. Record count: " + aTxn.result.length);
};
},
aSuccessCb,
aErrorCb
);
}
};

View File

@ -1,98 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AlarmHalService.h"
namespace mozilla {
namespace dom {
namespace alarm {
using namespace hal;
NS_IMPL_ISUPPORTS1(AlarmHalService, nsIAlarmHalService)
void
AlarmHalService::Init()
{
mAlarmEnabled = RegisterTheOneAlarmObserver(this);
}
/* virtual */ AlarmHalService::~AlarmHalService()
{
if (mAlarmEnabled) {
UnregisterTheOneAlarmObserver();
}
}
/* static */ nsRefPtr<AlarmHalService> AlarmHalService::sSingleton;
/* static */ already_AddRefed<nsIAlarmHalService>
AlarmHalService::GetInstance()
{
if (!sSingleton) {
sSingleton = new AlarmHalService();
sSingleton->Init();
ClearOnShutdown(&sSingleton);
}
nsCOMPtr<nsIAlarmHalService> service(do_QueryInterface(sSingleton));
return service.forget();
}
NS_IMETHODIMP
AlarmHalService::SetAlarm(PRInt32 aSeconds, PRInt32 aNanoseconds, bool* aStatus)
{
if (!mAlarmEnabled) {
return NS_ERROR_FAILURE;
}
bool status = hal::SetAlarm(aSeconds, aNanoseconds);
if (status) {
*aStatus = status;
return NS_OK;
} else {
return NS_ERROR_FAILURE;
}
}
NS_IMETHODIMP
AlarmHalService::SetAlarmFiredCb(nsIAlarmFiredCb* aAlarmFiredCb)
{
mAlarmFiredCb = aAlarmFiredCb;
return NS_OK;
}
NS_IMETHODIMP
AlarmHalService::SetTimezoneChangedCb(nsITimezoneChangedCb* aTimeZoneChangedCb)
{
mTimezoneChangedCb = aTimeZoneChangedCb;
return NS_OK;
}
void
AlarmHalService::Notify(const mozilla::void_t& aVoid)
{
if (mAlarmFiredCb) {
mAlarmFiredCb->OnAlarmFired();
}
}
PRInt32
AlarmHalService::GetTimezoneOffset(bool aIgnoreDST)
{
PRExplodedTime prTime;
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &prTime);
PRInt32 offset = prTime.tm_params.tp_gmt_offset;
if (!aIgnoreDST) {
offset += prTime.tm_params.tp_dst_offset;
}
return -(offset / 60);
}
} // alarm
} // dom
} // mozilla

View File

@ -1,56 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_alarm_AlarmHalService_h
#define mozilla_dom_alarm_AlarmHalService_h
#include "base/basictypes.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Hal.h"
#include "mozilla/Services.h"
#include "nsIAlarmHalService.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "prtime.h"
namespace mozilla {
namespace dom {
namespace alarm {
class AlarmHalService : public nsIAlarmHalService,
mozilla::hal::AlarmObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIALARMHALSERVICE
void Init();
virtual ~AlarmHalService();
static nsRefPtr<AlarmHalService> sSingleton;
static already_AddRefed<nsIAlarmHalService> GetInstance();
// Implementing hal::AlarmObserver
void Notify(const mozilla::void_t& aVoid);
private:
bool mAlarmEnabled;
nsCOMPtr<nsIAlarmFiredCb> mAlarmFiredCb;
// TODO The mTimezoneChangedCb would be called
// when a timezone-changed event is detected
// at run-time. To do so, we can register a
// timezone-changed observer, see bug 714358.
// We need to adjust the alarm time respect to
// the correct timezone where user is located.
nsCOMPtr<nsITimezoneChangedCb> mTimezoneChangedCb;
PRInt32 GetTimezoneOffset(bool aIgnoreDST);
};
} // namespace alarm
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_alarm_AlarmHalService_h

View File

@ -1,299 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* static functions */
const DEBUG = false;
function debug(aStr) {
if (DEBUG)
dump("AlarmService: " + aStr + "\n");
}
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/AlarmDB.jsm");
let EXPORTED_SYMBOLS = ["AlarmService"];
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
let myGlobal = this;
let AlarmService = {
init: function init() {
debug("init()");
this._currentTimezoneOffset = (new Date()).getTimezoneOffset();
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
const messages = ["AlarmsManager:GetAll", "AlarmsManager:Add", "AlarmsManager:Remove"];
messages.forEach(function addMessage(msgName) {
ppmm.addMessageListener(msgName, this);
}.bind(this));
// set the indexeddb database
let idbManager = Components.classes["@mozilla.org/dom/indexeddb/manager;1"].getService(Ci.nsIIndexedDatabaseManager);
idbManager.initWindowless(myGlobal);
this._db = new AlarmDB(myGlobal);
this._db.init(myGlobal);
// variable to save alarms waiting to be set
this._alarmQueue = [];
this._restoreAlarmsFromDb();
},
// getter/setter to access the current alarm set in system
_alarm: null,
get _currentAlarm() {
return this._alarm;
},
set _currentAlarm(aAlarm) {
this._alarm = aAlarm;
if (!aAlarm)
return;
if (!this._alarmHalService.setAlarm(this._getAlarmTime(aAlarm) / 1000, 0))
throw Components.results.NS_ERROR_FAILURE;
},
receiveMessage: function receiveMessage(aMessage) {
debug("receiveMessage(): " + aMessage.name);
let json = aMessage.json;
switch (aMessage.name) {
case "AlarmsManager:GetAll":
this._db.getAll(
function getAllSuccessCb(aAlarms) {
debug("Callback after getting alarms from database: " + JSON.stringify(aAlarms));
ppmm.sendAsyncMessage(
"AlarmsManager:GetAll:Return:OK",
{ requestID: json.requestID, alarms: aAlarms }
);
}.bind(this),
function getAllErrorCb(aErrorMsg) {
ppmm.sendAsyncMessage(
"AlarmsManager:GetAll:Return:KO",
{ requestID: json.requestID, errorMsg: aErrorMsg }
);
}.bind(this)
);
break;
case "AlarmsManager:Add":
// prepare a record for the new alarm to be added
let newAlarm = {
date: json.date,
ignoreTimezone: json.ignoreTimezone,
timezoneOffset: this._currentTimezoneOffset,
data: json.data
};
this._db.add(
newAlarm,
function addSuccessCb(aNewId) {
debug("Callback after adding alarm in database.");
newAlarm['id'] = aNewId;
let newAlarmTime = this._getAlarmTime(newAlarm);
if (newAlarmTime <= Date.now()) {
debug("Adding a alarm that has past time. Don't set it in system.");
this._debugCurrentAlarm();
return;
}
// if there is no alarm being set in system, set the new alarm
if (this._currentAlarm == null) {
this._currentAlarm = newAlarm;
this._debugCurrentAlarm();
return;
}
// if the new alarm is earlier than the current alarm
// swap them and push the previous alarm back to queue
let alarmQueue = this._alarmQueue;
let currentAlarmTime = this._getAlarmTime(this._currentAlarm);
if (newAlarmTime < currentAlarmTime) {
alarmQueue.unshift(this._currentAlarm);
this._currentAlarm = newAlarm;
this._debugCurrentAlarm();
return;
}
//push the new alarm in the queue
alarmQueue.push(newAlarm);
alarmQueue.sort(this._sortAlarmByTimeStamps.bind(this));
this._debugCurrentAlarm();
ppmm.sendAsyncMessage(
"AlarmsManager:Add:Return:OK",
{ requestID: json.requestID, id: aNewId }
);
}.bind(this),
function addErrorCb(aErrorMsg) {
ppmm.sendAsyncMessage(
"AlarmsManager:Add:Return:KO",
{ requestID: json.requestID, errorMsg: aErrorMsg }
);
}.bind(this)
);
break;
case "AlarmsManager:Remove":
this._db.remove(
json.id,
function removeSuccessCb() {
debug("Callback after removing alarm from database.");
// if there is no alarm being set
if (!this._currentAlarm) {
this._debugCurrentAlarm();
return;
}
// check if the alarm to be removed is in the queue
let alarmQueue = this._alarmQueue;
if (this._currentAlarm.id != json.id) {
for (let i = 0; i < alarmQueue.length; i++) {
if (alarmQueue[i].id == json.id) {
alarmQueue.splice(i, 1);
break;
}
}
this._debugCurrentAlarm();
return;
}
// the alarm to be removed is the current alarm
// reset the next alarm from 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),
function removeErrorCb(aErrorMsg) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
}
);
break;
default:
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
break;
}
},
_onAlarmFired: function _onAlarmFired() {
debug("_onAlarmFired()");
if (this._currentAlarm) {
debug("Fire system intent: " + JSON.stringify(this._currentAlarm));
// TODO Fire a system message, see bug 755245
this._currentAlarm = null;
}
// reset the next alarm from the queue
let nowTime = Date.now();
let alarmQueue = this._alarmQueue;
while (alarmQueue.length > 0) {
let nextAlarm = alarmQueue.shift();
let nextAlarmTime = this._getAlarmTime(nextAlarm);
// if the next alarm has been expired, directly
// fire system intent for it instead of setting it
if (nextAlarmTime <= nowTime) {
debug("Fire system intent: " + JSON.stringify(nextAlarm));
// TODO Fire a system message, see bug 755245
} 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(
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();
aAlarms.forEach(function addAlarm(aAlarm) {
if (this._getAlarmTime(aAlarm) > nowTime)
alarmQueue.push(aAlarm);
}.bind(this));
// set the next alarm from 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) {
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.
if (aAlarm.ignoreTimezone)
alarmTime += (this._currentTimezoneOffset - aAlarm.timezoneOffset) * 60000;
return alarmTime;
},
_sortAlarmByTimeStamps: function _sortAlarmByTimeStamps(aAlarm1, aAlarm2) {
return this._getAlarmTime(aAlarm1) - this._getAlarmTime(aAlarm2);
},
_debugCurrentAlarm: function _debugCurrentAlarm() {
debug("Current alarm: " + JSON.stringify(this._currentAlarm));
debug("Alarm queue: " + JSON.stringify(this._alarmQueue));
},
}
AlarmService.init();

View File

@ -1,159 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* static functions */
const DEBUG = false;
function debug(aStr) {
if (DEBUG)
dump("AlarmsManager: " + aStr + "\n");
}
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");
const ALARMSMANAGER_CONTRACTID = "@mozilla.org/alarmsManager;1";
const ALARMSMANAGER_CID = Components.ID("{fea1e884-9b05-11e1-9b64-87a7016c3860}");
const nsIDOMMozAlarmsManager = Ci.nsIDOMMozAlarmsManager;
const nsIClassInfo = Ci.nsIClassInfo;
function AlarmsManager()
{
debug("Constructor");
}
AlarmsManager.prototype = {
__proto__: DOMRequestIpcHelper.prototype,
classID : ALARMSMANAGER_CID,
QueryInterface : XPCOMUtils.generateQI([nsIDOMMozAlarmsManager, Ci.nsIDOMGlobalPropertyInitializer]),
classInfo : XPCOMUtils.generateCI({ classID: ALARMSMANAGER_CID,
contractID: ALARMSMANAGER_CONTRACTID,
classDescription: "AlarmsManager",
interfaces: [nsIDOMMozAlarmsManager],
flags: nsIClassInfo.DOM_OBJECT }),
add: function add(aDate, aRespectTimezone, aData) {
debug("add()");
let isIgnoreTimezone = true;
switch (aRespectTimezone) {
case "honorTimezone":
isIgnoreTimezone = false;
break;
case "ignoreTimezone":
isIgnoreTimezone = true;
break;
default:
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
break;
}
let request = this.createRequest();
this._cpmm.sendAsyncMessage(
"AlarmsManager:Add",
{ requestID: this.getRequestId(request), date: aDate, ignoreTimezone: isIgnoreTimezone, data: aData }
);
return request;
},
remove: function remove(aId) {
debug("remove()");
return this._cpmm.sendSyncMessage(
"AlarmsManager:Remove",
{ id: aId }
);
},
getAll: function getAll() {
debug("getAll()");
let request = this.createRequest();
this._cpmm.sendAsyncMessage(
"AlarmsManager:GetAll",
{ requestID: this.getRequestId(request) }
);
return request;
},
receiveMessage: function receiveMessage(aMessage) {
debug("receiveMessage(): " + aMessage.name);
let json = aMessage.json;
let request = this.getRequest(json.requestID);
if (!request) {
debug("No request stored! " + json.requestID);
return;
}
switch (aMessage.name) {
case "AlarmsManager:Add:Return:OK":
Services.DOMRequest.fireSuccess(request, json.id);
break;
case "AlarmsManager:GetAll:Return:OK":
Services.DOMRequest.fireSuccess(request, json.alarms);
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()");
// Set navigator.mozAlarms to null.
if (!Services.prefs.getBoolPref("dom.mozAlarms.enabled"))
return null;
let principal = aWindow.document.nodePrincipal;
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
let perm = principal == secMan.getSystemPrincipal() ?
Ci.nsIPermissionManager.ALLOW_ACTION : Services.perms.testExactPermission(principal.URI, "alarms");
// Only pages with perm set can use the alarms.
this.hasPrivileges = perm == Ci.nsIPermissionManager.ALLOW_ACTION;
if (!this.hasPrivileges)
return null;
this._cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsISyncMessageSender);
// Add the valid messages to be listened.
this.initHelper(aWindow, ["AlarmsManager:Add:Return:OK", "AlarmsManager:Add:Return:KO",
"AlarmsManager:GetAll:Return:OK", "AlarmsManager:GetAll:Return:KO"]);
},
// Called from DOMRequestIpcHelper.
uninit: function uninit() {
debug("uninit()");
},
}
const NSGetFactory = XPCOMUtils.generateNSGetFactory([AlarmsManager])

View File

@ -1,3 +0,0 @@
component {fea1e884-9b05-11e1-9b64-87a7016c3860} AlarmsManager.js
contract @mozilla.org/alarmsManager;1 {fea1e884-9b05-11e1-9b64-87a7016c3860}
category JavaScript-navigator-property mozAlarms @mozilla.org/alarmsManager;1

View File

@ -1,52 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = dom
XPIDL_MODULE = dom_alarm
LIBRARY_NAME = domalarm_s
LIBXUL_LIBRARY = 1
FORCE_STATIC_LIB = 1
GRE_MODULE = 1
include $(topsrcdir)/dom/dom-config.mk
EXPORTS_NAMESPACES = mozilla/dom/alarm
EXTRA_COMPONENTS = \
AlarmsManager.js \
AlarmsManager.manifest \
$(NULL)
EXTRA_JS_MODULES = \
AlarmDB.jsm \
AlarmService.jsm \
$(NULL)
XPIDLSRCS = \
nsIDOMAlarmsManager.idl \
nsIAlarmHalService.idl \
$(NULL)
EXPORTS_mozilla/dom/alarm = \
AlarmHalService.h \
$(NULL)
CPPSRCS = \
AlarmHalService.cpp \
$(NULL)
ifdef ENABLE_TESTS
DIRS += test
endif
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk

View File

@ -1,33 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
[scriptable, function, uuid(9f3ed2c0-aed9-11e1-8c3d-5310bd393466)]
interface nsIAlarmFiredCb : nsISupports
{
void onAlarmFired();
};
[scriptable, function, uuid(0ca52e84-ba8f-11e1-87e8-63235527db9e)]
interface nsITimezoneChangedCb : nsISupports
{
void onTimezoneChanged(in long aTimezoneOffset);
};
%{C++
#define NS_ALARMHALSERVICE_CID { 0x7dafea4c, 0x7163, 0x4b70, { 0x95, 0x4e, 0x5a, 0xd4, 0x09, 0x94, 0x83, 0xd7 } }
#define ALARMHALSERVICE_CONTRACTID "@mozilla.org/alarmHalService;1"
%}
[scriptable, builtinclass, uuid(057b1ee4-f696-486d-bd55-205e21e88fab)]
interface nsIAlarmHalService : nsISupports
{
bool setAlarm(in long aSeconds, in long aNanoseconds);
void setAlarmFiredCb(in nsIAlarmFiredCb aAlarmFiredCb);
void setTimezoneChangedCb(in nsITimezoneChangedCb aTimezoneChangedCb);
};

View File

@ -1,15 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "domstubs.idl"
interface nsIDOMDOMRequest;
[scriptable, uuid(fea1e884-9b05-11e1-9b64-87a7016c3860)]
interface nsIDOMMozAlarmsManager : nsISupports
{
nsIDOMDOMRequest getAll();
nsIDOMDOMRequest add(in jsval date, in DOMString respectTimezone, [optional] in jsval data);
void remove(in unsigned long id);
};

View File

@ -1,25 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/alarm/test
include $(DEPTH)/config/autoconf.mk
DIRS = \
$(NULL)
include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
test_alarm_permitted_app.html \
test_alarm_non_permitted_app.html \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -1,32 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test Non-Permitted Application for Alarm API</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
SpecialPowers.removePermission("alarms", document);
var mozAlarms = navigator.mozAlarms;
ok('mozAlarms' in navigator, "navigator.mozAlarms should exist");
is(mozAlarms, null, "navigator.mozAlarms should return null");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>

View File

@ -1,35 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test Permitted Application for Alarm API</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
SpecialPowers.addPermission("alarms", true, document);
var mozAlarms = navigator.mozAlarms;
ok('mozAlarms' in navigator, "navigator.mozAlarms should exist");
ok(mozAlarms, "navigator.mozAlarms should return an object");
ok(mozAlarms instanceof Components.interfaces.nsIDOMMozAlarmsManager,
"navigator.mozAlarms should be an nsIDOMMozAlarmsManager object");
SpecialPowers.removePermission("alarms", document);
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>

View File

@ -12,7 +12,6 @@ DOM_SRCDIRS = \
dom/settings \
dom/sms/src \
dom/contacts \
dom/alarm \
dom/src/events \
dom/src/storage \
dom/src/offline \

View File

@ -689,42 +689,5 @@ NotifySwitchChange(const hal::SwitchEvent& aEvent)
observer.Broadcast(aEvent);
}
static AlarmObserver* sAlarmObserver;
bool
RegisterTheOneAlarmObserver(AlarmObserver* aObserver)
{
MOZ_ASSERT(!InSandbox());
MOZ_ASSERT(!sAlarmObserver);
sAlarmObserver = aObserver;
RETURN_PROXY_IF_SANDBOXED(EnableAlarm());
}
void
UnregisterTheOneAlarmObserver()
{
if (sAlarmObserver) {
sAlarmObserver = NULL;
PROXY_IF_SANDBOXED(DisableAlarm());
}
}
void
NotifyAlarmFired()
{
if (sAlarmObserver) {
sAlarmObserver->Notify(void_t());
}
}
bool
SetAlarm(long aSeconds, long aNanoseconds)
{
// It's pointless to program an alarm nothing is going to observe ...
MOZ_ASSERT(sAlarmObserver);
RETURN_PROXY_IF_SANDBOXED(SetAlarm(aSeconds, aNanoseconds));
}
} // namespace hal
} // namespace mozilla

View File

@ -42,7 +42,6 @@ class Observer;
namespace hal {
typedef Observer<void_t> AlarmObserver;
typedef Observer<ScreenConfiguration> ScreenConfigurationObserver;
class WindowIdentifier;
@ -367,41 +366,6 @@ void NotifySwitchChange(const hal::SwitchEvent& aEvent);
*/
hal::SwitchState GetCurrentSwitchState(hal::SwitchDevice aDevice);
/**
* Register an observer that is notified when a programmed alarm
* expires.
*
* Currently, there can only be 0 or 1 alarm observers.
*/
bool RegisterTheOneAlarmObserver(hal::AlarmObserver* aObserver);
/**
* Unregister the alarm observer. Doing so will implicitly cancel any
* programmed alarm.
*/
void UnregisterTheOneAlarmObserver();
/**
* Notify that the programmed alarm has expired.
*
* This API is internal to hal; clients shouldn't call it directly.
*/
void NotifyAlarmFired();
/**
* Program the real-time clock to expire at the time |aSeconds|,
* |aNanoseconds|. These specify a point in real time relative to the
* UNIX epoch. The alarm will fire at this time point even if the
* real-time clock is changed; that is, this alarm respects changes to
* the real-time clock. Return true iff the alarm was programmed.
*
* The alarm can be reprogrammed at any time.
*
* This API is currently only allowed to be used from non-sandboxed
* contexts.
*/
bool SetAlarm(long aSeconds, long aNanoseconds);
} // namespace MOZ_HAL_NAMESPACE
} // namespace mozilla

View File

@ -64,16 +64,6 @@ void EnableSwitchNotifications(hal::SwitchDevice aDevice);
*/
void DisableSwitchNotifications(hal::SwitchDevice aDevice);
/**
* Enable alarm notifications from the backend.
*/
bool EnableAlarm();
/**
* Disable alarm notifications from the backend.
*/
void DisableAlarm();
} // namespace MOZ_HAL_NAMESPACE
} // namespace mozilla

View File

@ -47,7 +47,6 @@ CPPSRCS += \
AndroidHal.cpp \
AndroidSensor.cpp \
FallbackPower.cpp \
FallbackAlarm.cpp \
$(NULL)
else ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
CPPSRCS += \
@ -63,7 +62,6 @@ CPPSRCS += \
FallbackScreenConfiguration.cpp \
FallbackSensor.cpp \
FallbackVibration.cpp \
FallbackAlarm.cpp \
$(NULL)
ifdef MOZ_ENABLE_DBUS
CPPSRCS += UPowerClient.cpp
@ -77,7 +75,6 @@ CPPSRCS += \
FallbackVibration.cpp \
FallbackScreenConfiguration.cpp \
FallbackPower.cpp \
FallbackAlarm.cpp \
$(NULL)
else ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
CPPSRCS += \
@ -85,7 +82,6 @@ CPPSRCS += \
FallbackVibration.cpp \
FallbackPower.cpp \
FallbackScreenConfiguration.cpp \
FallbackAlarm.cpp \
$(NULL)
CMMSRCS += \
CocoaSensor.mm \
@ -97,7 +93,6 @@ CPPSRCS += \
FallbackVibration.cpp \
FallbackPower.cpp \
FallbackScreenConfiguration.cpp \
FallbackAlarm.cpp \
$(NULL)
ifdef MOZ_ENABLE_DBUS
CPPSRCS += UPowerClient.cpp
@ -111,7 +106,6 @@ CPPSRCS += \
FallbackVibration.cpp \
FallbackPower.cpp \
FallbackScreenConfiguration.cpp \
FallbackAlarm.cpp \
$(NULL)
endif

View File

@ -1,28 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Hal.h"
namespace mozilla {
namespace hal_impl {
bool
EnableAlarm()
{
return false;
}
void
DisableAlarm()
{
}
bool
SetAlarm(long aSeconds, long aNanoseconds)
{
return false;
}
} // hal_impl
} // namespace mozilla

View File

@ -6,7 +6,6 @@
#include <errno.h>
#include <fcntl.h>
#include <linux/android_alarm.h>
#include <math.h>
#include <stdio.h>
#include <sys/syscall.h>
@ -627,167 +626,5 @@ UnlockScreenOrientation()
OrientationObserver::GetInstance()->UnlockScreenOrientation();
}
static pthread_t sAlarmFireWatcherThread;
// If |sAlarmData| is non-null, it's owned by the watcher thread.
typedef struct AlarmData {
public:
AlarmData(int aFd) : mFd(aFd), mGeneration(sNextGeneration++), mShuttingDown(false) {}
ScopedClose mFd;
int mGeneration;
bool mShuttingDown;
static int sNextGeneration;
} AlarmData;
int AlarmData::sNextGeneration = 0;
AlarmData* sAlarmData = NULL;
class AlarmFiredEvent : public nsRunnable {
public:
AlarmFiredEvent(int aGeneration) : mGeneration(aGeneration) {}
NS_IMETHOD Run() {
// Guard against spurious notifications caused by an alarm firing
// concurrently with it being disabled.
if (sAlarmData && !sAlarmData->mShuttingDown && mGeneration == sAlarmData->mGeneration) {
hal::NotifyAlarmFired();
}
return NS_OK;
}
private:
int mGeneration;
};
// Runs on alarm-watcher thread.
static void
DestroyAlarmData(void* aData)
{
AlarmData* alarmData = static_cast<AlarmData*>(aData);
delete alarmData;
}
// Runs on alarm-watcher thread.
void ShutDownAlarm(int aSigno)
{
if (aSigno == SIGUSR2) {
sAlarmData->mShuttingDown = true;
}
return;
}
static void*
WaitForAlarm(void* aData)
{
pthread_cleanup_push(DestroyAlarmData, aData);
AlarmData* alarmData = static_cast<AlarmData*>(aData);
while (!alarmData->mShuttingDown) {
int alarmTypeFlags = 0;
// ALARM_WAIT apparently will block even if an alarm hasn't been
// programmed, although this behavior doesn't seem to be
// documented. We rely on that here to avoid spinning the CPU
// while awaiting an alarm to be programmed.
do {
alarmTypeFlags = ioctl(alarmData->mFd, ANDROID_ALARM_WAIT);
} while (alarmTypeFlags < 0 && errno == EINTR && !alarmData->mShuttingDown);
if (!alarmData->mShuttingDown &&
alarmTypeFlags >= 0 && (alarmTypeFlags & ANDROID_ALARM_RTC_WAKEUP_MASK)) {
NS_DispatchToMainThread(new AlarmFiredEvent(alarmData->mGeneration));
}
}
pthread_cleanup_pop(1);
return NULL;
}
bool
EnableAlarm()
{
MOZ_ASSERT(!sAlarmData);
int alarmFd = open("/dev/alarm", O_RDWR);
if (alarmFd < 0) {
HAL_LOG(("Failed to open alarm device: %s.", strerror(errno)));
return false;
}
nsAutoPtr<AlarmData> alarmData(new AlarmData(alarmFd));
struct sigaction actions;
memset(&actions, 0, sizeof(actions));
sigemptyset(&actions.sa_mask);
actions.sa_flags = 0;
actions.sa_handler = ShutDownAlarm;
if (sigaction(SIGUSR2, &actions, NULL)) {
HAL_LOG(("Failed to set SIGUSR2 signal for alarm-watcher thread."));
return false;
}
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
int status = pthread_create(&sAlarmFireWatcherThread, &attr, WaitForAlarm, alarmData.get());
if (status) {
alarmData = NULL;
HAL_LOG(("Failed to create alarm watcher thread. Status: %d.", status));
return false;
}
pthread_attr_destroy(&attr);
// The thread owns this now. We only hold a pointer.
sAlarmData = alarmData.forget();
return true;
}
void
DisableAlarm()
{
MOZ_ASSERT(sAlarmData);
// NB: this must happen-before the thread cancellation.
sAlarmData = NULL;
// The cancel will interrupt the thread and destroy it, freeing the
// data pointed at by sAlarmData.
DebugOnly<int> err = pthread_kill(sAlarmFireWatcherThread, SIGUSR2);
MOZ_ASSERT(!err);
}
bool
SetAlarm(long aSeconds, long aNanoseconds)
{
if (!sAlarmData) {
HAL_LOG(("We should have enabled the alarm."));
return false;
}
struct timespec ts;
ts.tv_sec = aSeconds;
ts.tv_nsec = aNanoseconds;
// currently we only support RTC wakeup alarm type
const int result = ioctl(sAlarmData->mFd, ANDROID_ALARM_SET(ANDROID_ALARM_RTC_WAKEUP), &ts);
if (result < 0) {
HAL_LOG(("Unable to set alarm: %s.", strerror(errno)));
return false;
}
return true;
}
} // hal_impl
} // mozilla

View File

@ -260,26 +260,6 @@ GetCurrentSwitchState(SwitchDevice aDevice)
return state;
}
bool
EnableAlarm()
{
NS_RUNTIMEABORT("Alarms can't be programmed from sandboxed contexts. Yet.");
return false;
}
void
DisableAlarm()
{
NS_RUNTIMEABORT("Alarms can't be programmed from sandboxed contexts. Yet.");
}
bool
SetAlarm(long aSeconds, long aNanoseconds)
{
NS_RUNTIMEABORT("Alarms can't be programmed from sandboxed contexts. Yet.");
return false;
}
class HalParent : public PHalParent
, public BatteryObserver
, public NetworkObserver

View File

@ -62,7 +62,6 @@ SHARED_LIBRARY_LIBS = \
$(DEPTH)/dom/base/$(LIB_PREFIX)jsdombase_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/battery/$(LIB_PREFIX)dom_battery_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/contacts/$(LIB_PREFIX)jsdomcontacts_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/alarm/$(LIB_PREFIX)domalarm_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/devicestorage/$(LIB_PREFIX)domdevicestorage_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/file/$(LIB_PREFIX)domfile_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/power/$(LIB_PREFIX)dom_power_s.$(LIB_SUFFIX) \

View File

@ -217,7 +217,6 @@ static void Shutdown();
#include "mozilla/dom/sms/SmsRequestManager.h"
#include "mozilla/dom/sms/SmsServicesFactory.h"
#include "nsIPowerManagerService.h"
#include "nsIAlarmHalService.h"
using namespace mozilla::dom::sms;
@ -225,10 +224,6 @@ using namespace mozilla::dom::sms;
using mozilla::dom::power::PowerManagerService;
#include "mozilla/dom/alarm/AlarmHalService.h"
using mozilla::dom::alarm::AlarmHalService;
// Transformiix
/* 5d5d92cd-6bf8-11d9-bf4a-000a95dc234c */
#define TRANSFORMIIX_NODESET_CID \
@ -278,8 +273,6 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISmsDatabaseService, SmsServicesFacto
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPowerManagerService,
PowerManagerService::GetInstance)
NS_GENERIC_FACTORY_CONSTRUCTOR(SmsRequestManager)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIAlarmHalService,
AlarmHalService::GetInstance)
//-----------------------------------------------------------------------------
@ -778,7 +771,6 @@ NS_DEFINE_NAMED_CID(SMS_SERVICE_CID);
NS_DEFINE_NAMED_CID(SMS_DATABASE_SERVICE_CID);
NS_DEFINE_NAMED_CID(SMS_REQUEST_MANAGER_CID);
NS_DEFINE_NAMED_CID(NS_POWERMANAGERSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_ALARMHALSERVICE_CID);
static nsresult
CreateWindowCommandTableConstructor(nsISupports *aOuter,
@ -1046,7 +1038,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kSMS_DATABASE_SERVICE_CID, false, NULL, nsISmsDatabaseServiceConstructor },
{ &kSMS_REQUEST_MANAGER_CID, false, NULL, SmsRequestManagerConstructor },
{ &kNS_POWERMANAGERSERVICE_CID, false, NULL, nsIPowerManagerServiceConstructor },
{ &kNS_ALARMHALSERVICE_CID, false, NULL, nsIAlarmHalServiceConstructor },
{ NULL }
};
@ -1179,7 +1170,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
{ SMS_DATABASE_SERVICE_CONTRACTID, &kSMS_DATABASE_SERVICE_CID },
{ SMS_REQUEST_MANAGER_CONTRACTID, &kSMS_REQUEST_MANAGER_CID },
{ POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID },
{ ALARMHALSERVICE_CONTRACTID, &kNS_ALARMHALSERVICE_CID },
{ NULL }
};

View File

@ -3577,9 +3577,6 @@ pref("dom.sms.whitelist", "");
pref("dom.mozContacts.enabled", false);
pref("dom.mozContacts.whitelist", "");
// WebAlarms
pref("dom.mozAlarms.enabled", false);
// WebSettings
pref("dom.mozSettings.enabled", false);

View File

@ -35,7 +35,6 @@ MAKEFILES_dom="
dom/interfaces/xbl/Makefile
dom/interfaces/xpath/Makefile
dom/interfaces/xul/Makefile
dom/alarm/Makefile
dom/base/Makefile
dom/battery/Makefile
dom/file/Makefile
@ -710,7 +709,6 @@ if [ "$ENABLE_TESTS" ]; then
docshell/test/Makefile
docshell/test/chrome/Makefile
docshell/test/navigation/Makefile
dom/alarm/test/Makefile
dom/battery/test/Makefile
dom/indexedDB/test/Makefile
dom/indexedDB/test/unit/Makefile