Hey,

We've been working on a new service proposal at Cloud Services [1] and
when we started to write a FxOS prototype we ended up looking for a way
to write a "background daemon whith chrome privileges".

I am adding quotes here because I know all these words have different
meanings depending on the projects - and I am probably not using them
correctly - please be indulgent I am just a Python guy

One good example is the Firefox Account integration. It needs to :

- interact with a 3rd party servers
- load UI content from another app
- is mostly a headless app that interacts through events in Gaia and
does network stuff

The current security model prevents a web app to do some of these things
(which is a good thing),
so the FxA code was built in Gecko, using "low-level code"  (JSM?)

Another example is the Simple Push daemon: it was added as a callback in
the gecko main loop, and is able to start apps on some network events.
I guess one important thing about Simple Push is that it cannot be
killed by the oomkiller like web apps since it's part of the b2g process.

One other example is Sync - but you get the idea: headless apps that
interact with a web service in the background.

Adding those features as a "part of gecko" solves a lot of problems but
also raises some concerns:

- the code has to follow the gecko release cycle - so what happens if we
have an urgent FxA security patch to land asap on the phone ?
- the code has a direct impact on the phone performances since it's
synchronously called in the b2g process.
- we (cloud services people) need to work at the gecko level - deal with
low-level things live xpcoms, jsm, etc.
- it's hard to experiment a new service "for real"
- the community would probably love the ability to add background
processes in apps (as long as we make sure we have a good cpu/network
usage restriction strategy like android/iOs)

== Idea ==

One idea that came in mind is to propose the creation of a new kind of
application layer in FxOS, that would be a "Background Service".

A Background Service is a piece of plain JS code that is declared in a
plain web app in a script, and has specific permissions. When FxOS
installs an app that contains a Background Service, the script is
installed in a specific place and managed in a separate process called
"Service Manager".

"Service Manager" would be a little wrapper around Gecko (in a JSM or
whatever), that can then boot up these other cloud scripts (say one for
sync, one for push, etc) - restart
them when the phone is restarted, and load each of these scripts in
their own scope, but with full chrome privileges (like allow IDB and
cross origin XHR and stuff)

We're trying to articulate the idea here :
https://wiki.mozilla.org/CloudServices/FirefoxMobileServicesand would
love some feedback/thoughts from people here.

FWIW I really like Android's approach of the problem, see
http://www.vogella.com/tutorials/AndroidServices/article.html

Cheers
Tarek

[1] https://wiki.mozilla.org/CloudServices/Presence
_______________________________________________

_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to