Skip to content

Commit 995477e

Browse files
committed
Update algorithm
1 parent 2bd25f1 commit 995477e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/index.bs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,6 +2565,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
25652565

25662566
Note: Keep this definition in sync with [=fetch a classic worker-imported script=].
25672567

2568+
A <dfn id="dfn-race-result">race result</dfn> is a tuple of a [=/response=] and [=race result/used route=].
2569+
2570+
A [=/race result=] has an associated <dfn export id="dfn-used-route">used route</dfn> (a [=/RouterSourceEnum=]).
2571+
25682572
<section algorithm>
25692573
<h3 id="create-job-algorithm"><dfn>Create Job</dfn></h3>
25702574

@@ -3223,16 +3227,16 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
32233227
* |request| is a [=non-subresource request=].
32243228
* |request| is a [=subresource request=] and |registration| is [=stale=].
32253229
1. If |activeWorker|'s [=service worker/list of router rules=] [=list/is not empty=]:
3226-
1. Let |source| be the result of running the [=Get Router Source=] algorithm with |registration|'s <a>active worker</a> and |request|.
32273230
1. Set |timingInfo|’s [=service worker timing info/worker router evaluation start=] to the [=coarsened shared current time=] given |useHighResPerformanceTimers|.
3231+
1. Let |source| be the result of running the [=Get Router Source=] algorithm with |registration|'s <a>active worker</a> and |request|.
32283232
1. If |source| is non-null, then:
32293233
1. Set |timingInfo|'s [=service worker timing info/worker matched router source=] be set to |source|, and [=service worker timing info/worker final router source=] be set to {{RouterSourceEnum/"network"}}.
32303234
1. If |source| is {{RouterSourceEnum/"network"}}:
32313235
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
32323236
1. Return null.
32333237
1. Else if |source| is {{RouterSourceEnum/"cache"}}, or |source|["{{RouterSourceDict/cacheName}}"] [=map/exists=], then:
3234-
1. Set |timingInfo|’s [=service worker timing info/worker cache lookup start=] to the [=coarsened shared current time=] given |useHighResPerformanceTimers|.
32353238
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3239+
1. Set |timingInfo|’s [=service worker timing info/worker cache lookup start=] to the [=coarsened shared current time=] given |useHighResPerformanceTimers|.
32363240
1. [=map/For each=] |cacheName| &#x2192; |cache| of the |registration|'s [=service worker registration/storage key=]'s [=name to cache map=].
32373241
1. If |source|["{{RouterSourceDict/cacheName}}"] [=map/exists=] and |source|["{{RouterSourceDict/cacheName}}"] [=string/is=] not |cacheName|, [=continue=].
32383242
1. Let |requestResponses| be the result of running [=Query Cache=] with |request|, a new {{CacheQueryOptions}}, and |cache|.
@@ -3253,14 +3257,14 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
32533257
1. Return null.
32543258
1. Else if |source| is {{RouterSourceEnum/"race-network-and-fetch-handler"}}, and |request|'s [=request/method=] is \`<code>GET</code>\` then:
32553259
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3256-
1. Let |queue| be an empty [=queue=] of tuple of a [=/response=] and a [=RouterSourceEnum/used route=].
3260+
1. Let |queue| be an empty [=queue=] of tuple of [=race result=].
32573261
1. Let |raceFetchController| be null.
32583262
1. Let |raceResponse| be a [=race response=] whose [=race response/value=] is "<code>pending</code>".
32593263
1. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>":
32603264
1. Set |raceFetchController| to the result of calling [=fetch=] given |request|, with [=fetch/processResponse=] set to the following steps given a [=/response=] |raceNetworkRequestResponse|:
32613265
1. If |raceNetworkRequestResponse|'s [=response/status=] is [=ok status=], then:
32623266
1. Set |raceResponse|'s [=race response/value=] to |raceNetworkRequestResponse|.
3263-
1. [=queue/Enqueue=] |raceNetworkRequestResponse| as [=/response=] and {{RouterSourceEnum/"network"}} as [=RouterSourceEnum/used route=] to |queue|.
3267+
1. [=queue/Enqueue=] |raceNetworkRequestResponse| as [=/response=] and {{RouterSourceEnum/"network"}} as [=/used route=] to |queue|.
32643268
1. Otherwise, set |raceResponse|'s [=race response/value=] to a [=network error=].
32653269
1. [=If aborted=] and |raceFetchController| is not null, then:
32663270
1. [=fetch controller/Abort=] |raceFetchController|.
@@ -3269,7 +3273,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
32693273
1. Run the following substeps [=in parallel=]:
32703274
1. Let |fetchHandlerResponse| be the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and |raceResponse|.
32713275
1. If |fetchHandlerResponse| is not null and not a [=network error=], and |raceFetchController| is not null, [=fetch controller/abort=] |raceFetchController|.
3272-
1. [=queue/Enqueue=] |fetchHandlerResponse| as [=/response=] and {{RouterSourceEnum/"fetch-event"}} as [=RouterSourceEnum/used route=] to |queue|.
3276+
1. [=queue/Enqueue=] |fetchHandlerResponse| as [=/response=] and {{RouterSourceEnum/"fetch-event"}} as [=/used route=] to |queue|.
32733277
1. Wait until |queue| is not empty.
32743278
1. Let |result| be the result of [=dequeue=] |queue|.
32753279
1. Set |timingInfo|'s [=service worker timing info/worker final router source=] be set to [=result/used route=] in |result|.

0 commit comments

Comments
 (0)