@@ -2711,12 +2711,15 @@ has the following <a for=struct>items</a>:
27112711 <dt> <dfn export for="deferred fetch record">inactivity deferred delay</dfn> (default null)
27122712 <dd> Null or a <a>duration</a>
27132713
2714- <dt> <dfn export for="deferred fetch record">pending steps</dfn> (default null)
2715- <dt> <dfn export for="deferred fetch record">invoked callback</dfn> (default null)
2716- <dd> Null or an algortihm accepting nothing
2717-
2718- <dt> <dfn export for="deferred fetch record">invoked</dfn> (default false)
2714+ <dt> <dfn export for="deferred fetch record">sent</dfn> (default false)
27192715 <dd> A boolean
2716+
2717+ <dt> <dfn export for="deferred fetch record">invoke state</dfn> (default "<code> deferred</code> ")
2718+ <dd>
2719+ <p> "<code> deferred</code> ", "<code> scheduled</code> ", "<code> terminated</code> ",
2720+ "<code> aborted</code> ", or "<code> sent</code> "
2721+
2722+ <p class=note> This value can be modified <a>in parallel</a> .
27202723</dl>
27212724
27222725
@@ -2726,79 +2729,60 @@ has the following <a for=struct>items</a>:
27262729<dfn export for="fetch group" id=concept-fetch-group-terminate>terminated</dfn> :
27272730
27282731<ol>
2729- <li>
2730- <p> <a for=list>For each</a> <a for="fetch group">deferred fetch record</a>
2731- <var> deferredRecord</var> in <var> fetchGroup</var> 's
2732- <a for="fetch group">deferred fetch records</a> whose <a for="deferred fetch record">invoked</a> is
2733- false:
2734-
2735- <ol>
2736- <li><p> If <var> deferredRecord</var> 's <a for="deferred fetch record">pending steps</a> is not
2737- null then <a>abort</a> <var> deferredRecord</var> 's
2738- <a for="deferred fetch record">pending steps</a> .
2739-
2740- <li><p> <a for=/>fetch</a> <var> deferredRecord</var> 's <a for="deferred fetch record">request</a> .
2741- </ol>
2742-
27432732 <li><p> For each associated <a for="fetch group">fetch record</a> <var> record</var> ,
27442733 if <var> record</var> 's <a for="fetch record">controller</a> is non-null and
27452734 <var> record</var> 's <a for="fetch record">request</a>' s <a>done flag</a> is unset or
27462735 <a for=request>keepalive</a> is false, <a for="fetch controller">terminate</a> <var> record</var> 's
27472736 <a for="fetch record">controller</a> .
2748- </ol>
2749-
2750- <p> When a <a for=fetch>fetch group</a> <var> fetchGroup</var> is
2751- <dfn export for="fetch group" id=concept-fetch-group-activate>activated</dfn> :
2752- <a for=list>for each</a> <a for=/>deferred fetch record</a> <var> deferredRecord</var> in
2753- <var> fetchGroup</var> 's <a for="fetch group">deferred fetch records</a> :
2754-
2755- <ol>
2756- <li>
2757- <p> If <var> deferredRecord</var> 's <a for="deferred fetch record">invoked</a> is true then:
2758- <ol>
2759- <li><p> If <var> deferredRecord</var> 's <a for="deferred fetch record">invoked callback</a> is not
2760- null then call <var> deferredRecord</var> 's <a for="deferred fetch record">invoked callback</a> .
2761-
2762- <li><p> <a for=list>Remove</a> <var> deferredRecord</var> from <var> fetchGroup</var> 's
2763- <a for="fetch group">deferred fetch records</a> .
2764- </ol>
27652737
2766- <li><p> Otherwise, if <var> deferredRecord</var> 's
2767- <a for="deferred fetch record">pending steps</a> is not null, then <a>abort</a>
2768- <var> deferredRecord</var> 's <a for="deferred fetch record">pending steps</a> and set
2769- <var> deferredRecord</var> 's <a for="deferred fetch record">pending steps</a> to null.
2738+ <li><p> <a for=list>For each</a> <a for="fetch group">deferred fetch record</a>
2739+ <var> deferredRecord</var> in <var> fetchGroup</var> 's
2740+ <a for="fetch group">deferred fetch records</a> : If the result of atomically exchanging the value
2741+ of <var> deferredRecord</var> 's <a for="deferred fetch record">invoke state</a> with
2742+ "<code> terminated</code> " is not "<code> sent</code> ", then the user agent should
2743+ <a for=/>fetch</a> <var> deferredRecord</var> 's <a for="deferred fetch record">request</a> . The
2744+ exact time in which the <a for=/>fetch</a> takes place is <a>implementation-defined</a> .
27702745</ol>
27712746
27722747<p> When a <a for=fetch>fetch group</a> <var> fetchGroup</var> is
27732748<dfn export for="fetch group" id=concept-fetch-group-deactivate>deactivated</dfn> :
2749+ <a for=list>For each</a> <a>deferred fetch record</a> <var> deferredRecord</var> in
2750+ <var> fetchGroup</var> 's <a for="fetch group">deferred fetch records</a> whose
2751+ <a for="deferred fetch record">inactivity deferred delay</a> is not null:
27742752
27752753<ol>
2754+ <li><p> Set <var> deferredRecord</var> 's <a for="deferred fetch record">invoke state</a> to
2755+ "<code> scheduled</code> ".
2756+
27762757 <li>
2777- <p> <a for=list>For each</a> <a>deferred fetch record</a> <var> deferredRecord</var> in
2778- <var> fetchGroup</var> 's <a for="fetch group">deferred fetch records</a> whose
2779- <a for="deferred fetch record">inactivity deferred delay</a> is not null: set
2780- <var> deferredRecord</var> 's <a for="deferred fetch record">pending steps</a> to running the
2781- following steps <a>in parallel</a> :
2758+ <p> Run the following steps <a>in parallel</a> :
27822759
27832760 <ol>
2784- <li><p> Wait until <var> deferredRecord</var> 's
2785- <a for="deferred fetch record">inactivity deferred delay</a> have passed.
2786-
2787- <li>
2788- <p> <a>Queue a fetch task</a> to run the following steps with
2789- <a for="fetch record">request</a> 's <a for=request>client</a>' s
2790- <a for="environment settings object">global object</a> :
2791-
2792- <ol>
2793- <li><p> <a for=/>Fetch</a> <var> record</var> 's <a for="fetch record">request</a> .
2794-
2795- <li><p> Set <var> deferredRecord</var> <a for="deferred fetch record">invoked</a> to true.
2796- </ol>
2797- </li>
2761+ <li><p> The user agent should wait until <var> deferredRecord</var> 's
2762+ <a for="deferred fetch record">inactivity deferred delay</a> have passed or until
2763+ <var> deferredRecord</var> 's <a for="deferred fetch record">invoke state</a> is not
2764+ "<code> scheduled</code> ". The user agent may wait for a longer or shorter period time, e.g., to
2765+ optimize batching of deferred fetches.
2766+
2767+ <li><p> If the result of atomically exchanging the value of <var> deferredRecord</var> 's
2768+ <a for="deferred fetch record">invoke state</a> with "<code> sent</code> " is
2769+ "<code> scheduled</code> ", then <a for=/>fetch</a> <var> record</var> 's
2770+ <a for="fetch record">request</a> .
27982771 </ol>
27992772 </li>
28002773</ol>
28012774
2775+ <p> When a <a for=fetch>fetch group</a> <var> fetchGroup</var> is
2776+ <dfn export for="fetch group" id=concept-fetch-group-reactivate>reactivated</dfn> :
2777+ <a for=list>For each</a> <a for=/>deferred fetch record</a> <var> deferredRecord</var> in
2778+ <var> fetchGroup</var> 's <a for="fetch group">deferred fetch records</a> : If the result of atomically
2779+ exchanging the value of <var> deferredRecord</var> 's <a for="deferred fetch record">invoke state</a>
2780+ with "<code> deferred</code> " is "<code> sent</code> ", then <a for=list>remove</a>
2781+ <var> deferredRecord</var> from <var> fetchGroup</var> 's
2782+ <a for="fetch group">deferred fetch records</a> and set <var> deferredRecord</var> 's
2783+ <a for="deferred fetch record">sent</a> to true.
2784+
2785+
28022786<h3 id=resolving-domains>Resolving domains</h3>
28032787
28042788<div algorithm>
@@ -8637,19 +8621,29 @@ dictionary DeferredRequestInit : RequestInit {
86378621 DOMHighResTimeStamp backgroundTimeout;
86388622};
86398623
8624+ interface FetchLaterResult {
8625+ readonly attribute boolean sent;
8626+ };
8627+
86408628partial interface mixin WindowOrWorkerGlobalScope {
8641- [NewObject] Promise<Response> fetchLater(RequestInfo input, optional DeferredRequestInit init = {});
8629+ [NewObject] FetchLaterResult fetchLater(RequestInfo input, optional DeferredRequestInit init = {});
86428630};
86438631</pre>
86448632
8633+ <p> A {{FetchLaterResult}} has an associated <a>deferred fetch record</a>
8634+ <dfn for=FetchLaterResult>deferred record</dfn> .
8635+
8636+ <div algorithm>
8637+ <p> The <dfn attribute for=FetchLaterResult><code>sent</code></dfn> getter steps are to return
8638+ <a>this</a> 's <a for=FetchLaterResult>deferred record</a>' s <a for="deferred fetch record">sent</a> .
8639+ </div>
8640+
86458641<div algorithm="dom-fetch-later">
86468642<p> The
86478643<dfn id=dom-global-fetch-later method for=WindowOrWorkerGlobalScope><code>fetchLater(<var>input</var>, <var>init</var>)</code></dfn>
86488644method steps are:
86498645
86508646<ol>
8651- <li><p> Let <var> promise</var> be a new promise.
8652-
86538647 <li><p> Let <var> requestObject</var> be the result of invoking the initial value of {{Request}} as
86548648 constructor with <var> input</var> and <var> init</var> as arguments. If that threw an exception,
86558649 <a for=/>reject</a> <var> promise</var> with that exception and return <var> promise</var> .
@@ -8669,17 +8663,24 @@ method steps are:
86698663 <li><p> If <var> backgroundTimeout</var> is not a {{DOMHighResTimeStamp}} then throw a {{TypeError}} .
86708664
86718665 <li><p> Let <var> deferredRecord</var> be the result of calling
8672- <a>request a deferred fetch</a> given <var> request</var> and <var> backgroundTimeout</var> . If that
8673- threw an exception, <a for=/>reject</a> <var> promise</var> with that exception and return
8674- <var> promise</var> .
8666+ <a>request a deferred fetch</a> given <var> request</var> and <var> backgroundTimeout</var> . This
8667+ may throw an exception.
86758668
8676- <li><p> Set <var> deferredRecord</var> 's <a for="deferred fetch record">invoke callback</a> to
8677- <a for=/>resolve</a> <var> promise</var> .
8669+ <li>
8670+ <p> <a for=AbortSignal lt=add>Add the following abort steps</a> to <var> requestObject</var> 's
8671+ <a for=Request>signal</a> :
86788672
8679- <li><p> <a for=AbortSignal lt=add>Add the following abort steps</a> to <var> requestObject</var> 's
8680- <a for=Request>signal</a> : <a for=list>remove</a> <var> deferredRecord</var> from
8681- <var> request</var> 's <a for=request>client</a>' s <a for=fetch>fetch group</a> 's
8682- <a for="fetch group">deferred fetch records</a> .
8673+ <ol>
8674+ <li><p> Set <var> deferredRecord</var> 's <a for="deferred fetch record">invoke state</a> to
8675+ "<code> aborted</code> ".
8676+
8677+ <li><p> <a for=list>Remove</a> <var> deferredRecord</var> from
8678+ <var> request</var> 's <a for=request>client</a>' s <a for=fetch>fetch group</a> 's
8679+ <a for="fetch group">deferred fetch records</a> .
8680+ </ol>
8681+
8682+ <li><p> Return a new {{FetchLaterResult}} whose <a for=FetchLaterResult>deferred record</a> is
8683+ <var> deferredRecord</var> .
86838684</ol>
86848685
86858686
0 commit comments