Bug 879671 - 1/2: pass multiple initial options to ril_worker. r=yoshi

This commit is contained in:
Vicamo Yang 2013-06-07 15:32:20 +08:00
parent 422a1ec197
commit c383847d41
3 changed files with 16 additions and 18 deletions

View File

@ -223,6 +223,8 @@ XPCOMUtils.defineLazyGetter(this, "gAudioManager", function getAudioManager() {
function RadioInterfaceLayer() {
this.clientId = 0;
this.dataNetworkInterface = new RILNetworkInterface(this, Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE);
this.mmsNetworkInterface = new RILNetworkInterface(this, Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS);
this.suplNetworkInterface = new RILNetworkInterface(this, Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL);
@ -232,6 +234,13 @@ function RadioInterfaceLayer() {
this.worker.onerror = this.onerror.bind(this);
this.worker.onmessage = this.onmessage.bind(this);
// Pass initial options to ril_worker.
this.worker.postMessage({
rilMessageType: "setInitialOptions",
debug: debugPref,
clientId: this.clientId,
});
this.rilContext = {
radioState: RIL.GECKO_RADIOSTATE_UNAVAILABLE,
cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
@ -360,11 +369,7 @@ function RadioInterfaceLayer() {
this._targetMessageQueue = [];
// pass debug pref to ril_worker
this.worker.postMessage({rilMessageType: "setDebugEnabled",
enabled: debugPref});
gSystemWorkerManager.registerRilWorker(0, this.worker);
gSystemWorkerManager.registerRilWorker(this.clientId, this.worker);
}
RadioInterfaceLayer.prototype = {

View File

@ -60,11 +60,8 @@ SystemWorkerManager *gInstance = nullptr;
class ConnectWorkerToRIL : public WorkerTask
{
const unsigned long mClientId;
public:
ConnectWorkerToRIL(unsigned long aClientId)
: mClientId(aClientId)
ConnectWorkerToRIL()
{ }
virtual bool RunTask(JSContext *aCx);
@ -157,11 +154,6 @@ ConnectWorkerToRIL::RunTask(JSContext *aCx)
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
JSObject *workerGlobal = JS_GetGlobalForScopeChain(aCx);
if (!JS_DefineProperty(aCx, workerGlobal, "CLIENT_ID",
INT_TO_JSVAL(mClientId), nullptr, nullptr, 0)) {
return false;
}
return !!JS_DefineFunction(aCx, workerGlobal, "postRILMessage", PostToRIL, 1,
0);
}
@ -496,7 +488,7 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId,
return NS_ERROR_FAILURE;
}
nsRefPtr<ConnectWorkerToRIL> connection = new ConnectWorkerToRIL(aClientId);
nsRefPtr<ConnectWorkerToRIL> connection = new ConnectWorkerToRIL();
if (!wctd->PostTask(connection)) {
NS_WARNING("Failed to connect worker to ril");
return NS_ERROR_UNEXPECTED;

View File

@ -42,7 +42,7 @@ importScripts("ril_consts.js", "systemlibs.js");
// set to true in ril_consts.js to see debug messages
let DEBUG = DEBUG_WORKER;
let CLIENT_ID = -1;
let GLOBAL = this;
const INT32_MAX = 2147483647;
@ -4337,8 +4337,9 @@ let RIL = {
}
},
setDebugEnabled: function setDebugEnabled(options) {
DEBUG = DEBUG_WORKER || options.enabled;
setInitialOptions: function setInitialOptions(options) {
DEBUG = DEBUG_WORKER || options.debug;
CLIENT_ID = options.clientId;
}
};