Hello,

As part of allowing various APIs (Push notifications, Notifications, 
BackgroundSync etc.) to use ServiceWorkers, we need some way to start them in 
the child process. I'm trying to figure out how to do this properly in e10s and 
on b2g. Here is an outline, I'm hoping someone with more knowledge will help 
fill in the gaps. The way we do this right now is to insert a frame script in 
all the children that listens to a broadcast event sent by the message manager, 
but eventually we may have sensitive data in the messages and would prefer to 
send it only to the correct child.

1. What information do dependent APIs need to store? I can think of:
a) appID
b) inBrowserElement
c) origin
d) scope
e) (optional) manifestURL when appID is not UNKNOWN?
Can any or all of these be replaced by a nsIPrincipal and something else?

2. When the parent process wants to wake up a SW and send it an event, we need 
to implement the following algorithm:
  If there is a child process capable of handling the set of data in step 1:
    send event to that child process.
  else:
    create a new child process with the data in step 1 (and presumably the 
privileges get set accordingly)
    send this child process the message

>From my limited reading of ContentParent and friends, this is what I 
>understand:

1) Use ContentParent::GetAll() to get existing content processes.
2) On each ContentParent get the list of TabContexts
3) Ask each TabContext if it can deal with this event using something like 
AssertAppProcess - 
https://dxr.mozilla.org/mozilla-central/source/dom/ipc/AppProcessChecker.cpp#76
4) If some TabContext replies in the affirmative, send it a message (How do I 
do this?)
5) Otherwise, create a new content process - I'm looking at 
ContentParent::CreateBrowserOrApp()

Ideally, I'd like to do all of this from privileged JS, but it should be easy 
to wrap if it isn't right now.

Best,
Nikhil
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to