From 34c8b84b7fd7627fddb66e47b1566a6b3f7e49bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Daoust?= Date: Wed, 20 Apr 2016 14:36:29 +0200 Subject: [PATCH] Getting connectionList now always returns the same object This update should address last Pull Request comments, as well as #281. Note I ended up introducing two new idioms to talk about the Promise and PresentationConnectionList singletons, as I believe it improves the readability of algorithms, and makes the list of objects that user agents need to maintain explicit. However, as usual, finding names for things is hard. I came up with "presentation controllers monitor" and "presentation controllers promise". It may be possible to find better names. For instance, instead of "monitor", we could use "manager", "holder", "wrapper", "container". --- index.html | 101 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 39 deletions(-) diff --git a/index.html b/index.html index 2bcceb9..2a1eb3d 100644 --- a/index.html +++ b/index.html @@ -728,6 +728,22 @@

connections in this set share the same presentation URL and presentation identifier.

+

+ In a receiving browsing context, the presentation + controllers monitor, initially set to null, + exposes the current set of presentation controllers to the + receiving application. The presentation controllers monitor is + represented by a PresentationConnectionList. +

+

+ In a receiving browsing context, the presentation + controllers promise, which is initially set to + null, exposes the presentation controllers + monitor once the initial presentation connection is + established. The presentation controllers promise is + represented by a Promise that holds the presentation + controllers monitor. +

@@ -1524,10 +1540,9 @@

A receiving user agent fires a trusted event named connectionavailable on a PresentationReceiver when an incoming connection is - created. It is fired at the PresentationConnectionList - instance associated with the PresentationReceiver instance, - using the PresentationConnectionAvailableEvent interface, - with the presentation controllers + monitor, using the PresentationConnectionAvailableEvent + interface, with the connection attribute set to the PresentationConnection object that was created. The event is fired for all connections that are created @@ -2282,34 +2297,35 @@

be implemented in a receiving browsing context provided by a receiving user agent.

-

- When the PresentationReceiver object is created, a - PresentationConnectionList object is also created and - associated with that PresentationReceiver object. -

On getting, the connectionList attribute MUST return the result of running the following steps:

    -
  1. If there is already an unsettled Promise P from - a previous call to get the connectionList attribute for the same - PresentationReceiver object, return P and abort all - remaining steps. +
  2. If the presentation controllers promise is not + null, return the presentation controllers promise + and abort all remaining steps.
  3. -
  4. Let P be a new Promise. +
  5. Otherwise, let the presentation controllers promise be a + new Promise.
  6. -
  7. Return P, but continue running these steps in - parallel. +
  8. Return the presentation controllers promise, but continue + running these steps in parallel.
  9. If the set of presentation controllers contains at least - one presentation connection, resolve P with - the PresentationConnectionList object associated with the - PresentationReceiver object. + one presentation connection, then run the following steps: +
      +
    1. Let the presentation controllers monitor be a new + PresentationConnectionList. +
    2. +
    3. + Resolve the presentation controllers promise with + the presentation controllers monitor. +
    4. +
  10. -
  11. Otherwise, P remains unsettled and associated with the - PresentationReceiver object. +
  12. Otherwise, the presentation controllers promise remains + unsettled.
@@ -2423,24 +2439,31 @@

  • Add S to the set of presentation controllers.
  • -
  • If there is an unsettled Promise P from a - previous call to get the connectionList attribute for the same - PresentationReceiver object, resolve P - with the PresentationConnectionList object associated with - the PresentationReceiver object and abort all remaining - steps. +
  • If the presentation controllers promise is + null, then abort all remaining steps.
  • -
  • - Queue a task to fire a trusted event with - the name connectionavailable, that uses - the PresentationConnectionAvailableEvent interface, with - the connection - attribute initialized to S, at the - PresentationConnectionList object associated with the - PresentationReceiver object. The event must not bubble, - must not be cancelable, and has no default action. +
  • Otherwise, if the presentation controllers promise is + unsettled, then run the following steps: +
      +
    1. Let the presentation controllers monitor be a new + PresentationConnectionList. +
    2. +
    3. + Resolve the presentation controllers promise + with the presentation controllers monitor. +
    4. +
    5. Abort all remaining steps. +
    6. +
    +
  • +
  • Otherwise, queue a task to fire a trusted + event with the name connectionavailable, that uses the + PresentationConnectionAvailableEvent interface, with the + connection + attribute initialized to S, at the presentation + controllers monitor. The event must not bubble, must not be + cancelable, and has no default action.