The need for talking to Unix domain sockets from Gecko has come up
several times now:
* Radio: for talking to rild we invented
https://mxr.mozilla.org/mozilla-central/source/ipc/ril/Ril.cpp and
https://mxr.mozilla.org/mozilla-central/source/dom/system/gonk/SystemWorkerManager.cpp
* USB volumes: for talking to vold we created
https://mxr.mozilla.org/mozilla-central/source/dom/system/gonk/VolumeManager.cpp
* USB/Wifi tethering will require talking to a daemon over Unix domain socket
* AFAIK bluetooth may have a need for it, too (I'll let qDot chime in himself)
* can people think of other uses?
We're thinking of exposing this functionality directly to JS, thus
eliminating the need for lots of C++ boilerplate code. Since this
stuff currently happens on IO / IPC threads, I propose we only expose
the JS API to ChromeWorkers. The ril_worker would then directly talk
to rild/rilproxy. The VolumeManager could be reimplemented as a
ChromeWorker. The tethering stuff could be added to the net_worker.
You get the picture.
Here's an API proposal based on an earlier one by cjones:
interface ChromeWorker {
DOMRequest openSocket(String addr);
};
interface Socket {
void send(byte[] data); // byte[] can be regular Array or Uint8Array
attribute Function onrecv; // gets Uint8Array
attribute Function onclose;
attribute Function onerror;
};
Example:
let req = openSocket("unix:/dev/socket/netd");
req.onerror = ...;
req.onsuccess = function onsuccess() {
let sock = req.result;
sock.onrecv = ...;
sock.onclose = ...;
sock.onerror = ...;
sock.send("start\n"); };
};
What do folks think?