Skip to content

Commit

Permalink
[giow] (1) Rephrase how EventSource is protected from garbage collect…
Browse files Browse the repository at this point in the history
…ion to make more sense. Note that EventSource objects are allowed to survive the bfcache (unlike, say, WebSocket connections).

Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=13812

git-svn-id: http://svn.whatwg.org/webapps@6624 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Oct 4, 2011
1 parent ab2770e commit c77fd96
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 90 deletions.
82 changes: 54 additions & 28 deletions complete.html
Expand Up @@ -65712,6 +65712,12 @@ <h4 id=unloading-documents><span class=secno>6.5.11 </span>Unloading documents</

</li>

<li><p>If the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state is
false, <a href=#concept-eventsource-forcibly-close title=concept-EventSource-forcibly-close>forcibly
close</a> any <code><a href=#eventsource>EventSource</a></code> objects that whose
constructor was invoked from the <code><a href=#document>Document</a></code>'s
<code><a href=#window>Window</a></code> object.</li>

<li><p>If the <code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state is
false, empty the <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code>'s
<a href=#list-of-active-timeouts>list of active timeouts</a> and its <a href=#list-of-active-intervals>list of active
Expand Down Expand Up @@ -79705,10 +79711,10 @@ <h4 id=the-eventsource-interface><span class=secno>11.2.2 </span>The <code><a hr
changes.</p>

<p>The <dfn id=dom-eventsource-close title=dom-EventSource-close><code>close()</code></dfn>
method must close the connection, if any; must abort any instances
of the <a href=#fetch>fetch</a> algorithm started for this
<code><a href=#eventsource>EventSource</a></code> object; and must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
<code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>.</p>
method must abort any instances of the <a href=#fetch>fetch</a> algorithm
started for this <code><a href=#eventsource>EventSource</a></code> object, and must set the
<code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute
to <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>.</p>

<p>The following are the <a href=#event-handlers>event handlers</a> (and their
corresponding <a href=#event-handler-event-type title="event handler event type">event handler
Expand Down Expand Up @@ -79817,18 +79823,17 @@ <h4 id=processing-model-5><span class=secno>11.2.3 </span>Processing model</h4>
<p>For non-HTTP protocols, UAs should act in equivalent ways.</p>

<hr><p>When a user agent is to <dfn id=announce-the-connection>announce the connection</dfn>, the
user agent must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
<code title=dom-EventSource-OPEN><a href=#dom-eventsource-open>OPEN</a></code> and <a href=#queue-a-task>queue a
task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-open>open</code> at the
<code><a href=#eventsource>EventSource</a></code> object.</p>
user agent must <a href=#queue-a-task>queue a task</a> to set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
<code title=dom-EventSource-OPEN><a href=#dom-eventsource-open>OPEN</a></code> and <a href=#fire-a-simple-event>fire a
simple event</a> named <code title=event-open>open</code> at
the <code><a href=#eventsource>EventSource</a></code> object.</p>

<p>When a user agent is to <dfn id=reestablish-the-connection>reestablish the connection</dfn>,
the user agent must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
<code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code>,
<a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named
<code title=event-error>error</code> at the
<code><a href=#eventsource>EventSource</a></code> object, and then, after a delay equal to
the reconnection time of the event source, if the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute is
the user agent must <a href=#queue-a-task>queue a task</a> to set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
<code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code> and
<a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#eventsource>EventSource</a></code>
object, and then, after a delay equal to the reconnection time of
the event source, if the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute is
still set to <code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code>, once again do
a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of the <a href=#absolute-url>absolute
URL</a> of the event source resource, with the <i>mode</i> being
Expand All @@ -79842,12 +79847,12 @@ <h4 id=processing-model-5><span class=secno>11.2.3 </span>Processing model</h4>
section.</p>

<p>When a user agent is to <dfn id=fail-the-connection>fail the connection</dfn>, the user
agent must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
<code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code> and <a href=#queue-a-task>queue a
task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#eventsource>EventSource</a></code>
object. <strong>Once the user agent has <a href=#fail-the-connection title="fail the
connection">failed the connection</a>, it does <em>not</em>
attempt to reconnect!</strong></p>
agent must <a href=#queue-a-task>queue a task</a> to set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
<code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code> and <a href=#fire-a-simple-event>fire a
simple event</a> named <code title=event-error>error</code> at
the <code><a href=#eventsource>EventSource</a></code> object. <strong>Once the user agent has
<a href=#fail-the-connection title="fail the connection">failed the connection</a>, it
does <em>not</em> attempt to reconnect!</strong></p>

<hr><p>The <a href=#task-source>task source</a> for any <a href=#concept-task title=concept-task>tasks</a> that are <a href=#queue-a-task title="queue a
task">queued</a> by <code><a href=#eventsource>EventSource</a></code> objects is the
Expand Down Expand Up @@ -80250,23 +80255,44 @@ <h4 id=eventsource-push><span class=secno>11.2.7 </span>Connectionless push and

<h4 id=garbage-collection-1><span class=secno>11.2.8 </span>Garbage collection</h4>

<p>While an <code><a href=#eventsource>EventSource</a></code> object's <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> is not <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>, and the object has one
or more event listeners registered for <code title=event-message><a href=#event-message>message</a></code> events, there must be a strong
<p>While an <code><a href=#eventsource>EventSource</a></code> object's <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> is <code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code>, and the object
has one or more event listeners registered for <code title=event-open>open</code>, <code title=event-message><a href=#event-message>message</a></code> or <code title=event-error>error</code> events, there must be a strong
reference from the <code><a href=#window>Window</a></code> or <code><a href=#workerutils>WorkerUtils</a></code>
object that the <code><a href=#eventsource>EventSource</a></code> object's constructor was
invoked from to the <code><a href=#eventsource>EventSource</a></code> object itself.</p>

<p>While an <code><a href=#eventsource>EventSource</a></code> object's <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> is <code title=dom-EventSource-OPEN><a href=#dom-eventsource-open>OPEN</a></code>, and the object has one or
more event listeners registered for <code title=event-message><a href=#event-message>message</a></code> or <code title=event-error>error</code> events, there must be a strong
reference from the <code><a href=#window>Window</a></code> or <code><a href=#workerutils>WorkerUtils</a></code>
object that the <code><a href=#eventsource>EventSource</a></code> object's constructor was
invoked from to the <code><a href=#eventsource>EventSource</a></code> object itself.</p>

<p>While there is a task queued by an <code><a href=#eventsource>EventSource</a></code>
object on the <a href=#remote-event-task-source>remote event task source</a>, there must be a
strong reference from the <code><a href=#window>Window</a></code> or
<code><a href=#workerutils>WorkerUtils</a></code> object that the <code><a href=#eventsource>EventSource</a></code>
object's constructor was invoked from to that
<code><a href=#eventsource>EventSource</a></code> object.</p>

<p>If a user agent is to <dfn id=concept-eventsource-forcibly-close title=concept-EventSource-forcibly-close>forcibly close</dfn> an
<code><a href=#eventsource>EventSource</a></code> object (this happens when a
<code><a href=#document>Document</a></code> object goes away permanently), the user agent
must abort any instances of the <a href=#fetch>fetch</a> algorithm started
for this <code><a href=#eventsource>EventSource</a></code> object, and must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
<code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>.</p> <!-- same as
calling close() -->

<p>If an <code><a href=#eventsource>EventSource</a></code> object is garbage collected while
its connection is still open, the user agent must cancel any
instance of the <a href=#fetch title=fetch>fetch</a> algorithm opened by
this <code><a href=#eventsource>EventSource</a></code>, discarding any <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a
task">queued</a> for them, and discarding any further data
received from the network for them.</p>
its connection is still open, the user agent must abort any instance
of the <a href=#fetch title=fetch>fetch</a> algorithm opened by this
<code><a href=#eventsource>EventSource</a></code>.</p> <!-- no need to throw tasks away or
anything; for it to get garbage collected, there can't be anything
that would be able to receive those events -->

<p class=note>It's possible for one active network connection to
be shared by multiple <code><a href=#eventsource>EventSource</a></code> objects and their
<a href=#fetch>fetch</a> algorithms, which is why the above is phrased in
terms of canceling the <a href=#fetch>fetch</a> algorithm and not the
terms of aborting the <a href=#fetch>fetch</a> algorithm and not the
actual underlying download.</p>


Expand Down

0 comments on commit c77fd96

Please sign in to comment.