Description[Extensions] Extension Port Ids and Initialization 2.0
Extensions can open message ports to communicate between different
contexts. A port can have n different receivers, and communication can
flow bidirectionally.
Currently, this is implemented by the port having a global id, vended by
the browser process, which uniquely identifies a port (amongst all
contexts). In making port creation asynchronous (crbug.com/642380), we
also added the concept of a "local id" to be used in Javascript that
identified a port uniquely in the context. This allowed us to have the
browser asynchronously message us back a global id for the port to use.
Unfortunately, this still has a number of problems:
- Asynchronous port creation doesn't work in onunload
(crbug.com/660706); this also required exposing the unload state from
blink.
- The time-to-message is slower, since we wait on an IPC round trip
(crbug.com/649942).
Instead, construct a new PortId concept as a combination of three
members: context id (a globally-unique id for the context), port number
(a port id within that context), and whether or not the port is an
opener. This allows us to:
- Make a port ID on the renderer, thus making it entirely synchronous
and even faster than before (we don't need the browser involved at
all). Also without exposing knowledge of unload state.
- Identify whether the opposite end of the port was created in the same
context (solving the issue of re-opening extension ports in a same-
process renderer, crbug.com/597698). Test added courtesy of
rob@robwu.nl.
- Increase difficulty in sending bad IPCs since an attacker would have
to guess another context's GUID (rather than just being able to know
that a port with id '1' exists somewhere).
Additionally, eliminate a few hundred lines of code.
BUG=649942
BUG=597698
Committed: https://crrev.com/8e744a465d70e2ab1bf7959a66c3c65bd3850092
Cr-Commit-Position: refs/heads/master@{#436655}
Patch Set 1 #Patch Set 2 : Rob's test #
Total comments: 8
Patch Set 3 : Rob's #
Total comments: 2
Patch Set 4 : rebase + unguessable token #
Total comments: 19
Patch Set 5 : Remove test #Patch Set 6 : lazyboy's #
Total comments: 3
Patch Set 7 : rkaplow #Messages
Total messages: 46 (28 generated)
|