mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-13 15:34:01 +00:00
Bug 879671 - 1/2: pass multiple initial options to ril_worker. r=yoshi
This commit is contained in:
parent
422a1ec197
commit
c383847d41
@ -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 = {
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user