Skip to content

Commit

Permalink
Pass response's cache state to Resource Timing
Browse files Browse the repository at this point in the history
And hand processResponseDone a response.

Resource Timing PR: w3c/resource-timing#266.

Closes #1201. Follow-up: #1215.
  • Loading branch information
noamr authored Apr 21, 2021
1 parent 6453947 commit 5fac9e8
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,8 @@ message as HTTP/2 does not support them.
<dfn export for=response id=concept-response-cache-state>cache state</dfn> (the empty string or
"<code>local</code>"). Unlesss stated otherwise, it is the empty string.

<p class=note>This is intended solely for usage by service workers. [[SW]]
<p class=note>This is intended for usage by <cite>Service Workers</cite> and
<cite>Resource Timing</cite>. [[SW]] [[RESOURCE-TIMING]]
<!-- If we ever expand the utility of this we need to carefully consider whether filtered responses
need to mask it, whether the cache API needs to store it, etc. -->

Expand Down Expand Up @@ -3512,7 +3513,7 @@ representing the number of bytes transmitted. If given, <var>processRequestEndOf
an algorithm accepting no arguments. If given, <var>processResponse</var> must be an algorithm
accepting a <a for=/>response</a>. If given, <var>processResponseEndOfBody</var> must be an
algorithm accepting a <a for=/>response</a> and null, failure, or a <a for=/>byte sequence</a>. If
given, <var>processResponseDone</var> must be an algorithm accepting no arguments.
given, <var>processResponseDone</var> must be an algorithm accepting a <a for=/>response</a>.

<p>An ongoing <a for=/>fetch</a> can be
<dfn export for=fetch id=concept-fetch-terminate>terminated</dfn> with flag <var>aborted</var>,
Expand Down Expand Up @@ -3986,9 +3987,9 @@ steps:
<a for=request>done flag</a>.

<li><p>If <var>fetchParams</var>'s <a for="fetch params">process response done</a> is not null,
then <a>queue a fetch task</a> given <var>fetchParams</var>'s
<a for="fetch params">process response done</a> and <var>fetchParams</var>'s
<a for="fetch params">task destination</a>.
then <a>queue a fetch task</a> to run <var>fetchParams</var>'s
<a for="fetch params">process response done</a> given <var>response</var>,
with <var>fetchParams</var>'s <a for="fetch params">task destination</a>.
</ol>

<p>To <dfn export>finalize and report timing</dfn> given a <a for=/>response</a>
Expand All @@ -4003,13 +4004,21 @@ steps:

<li><p>Let <var>timingInfo</var> be <var>response</var>'s <a for=response>timing info</a>.

<li><p>Let <var>cacheState</var> be <var>response</var>'s <a for=response>cache state</a>.

<li><p>If <var>timingInfo</var> is null, then return.

<li><p>If <var>response</var>'s <a for=response>timing allow passed flag</a> is not set, then set
<var>timingInfo</var> to a new <a for=/>fetch timing info</a> whose
<a for="fetch timing info">start time</a> and
<a for="fetch timing info">post-redirect start time</a> are <var>timingInfo</var>'s
<a for="fetch timing info">start time</a>.
<li>
<p>If <var>response</var>'s <a for=response>timing allow passed flag</a> is not set, then:

<ol>
<li><p>Set <var>timingInfo</var> to a new <a for=/>fetch timing info</a> whose
<a for="fetch timing info">start time</a> and
<a for="fetch timing info">post-redirect start time</a> are <var>timingInfo</var>'s
<a for="fetch timing info">start time</a>.

<li><p>Set <var>cacheState</var> to the empty string.
</ol>

<li><p>Set <var>timingInfo</var>'s <a for="fetch timing info">end time</a> to the
<a for=/>coarsened shared current time</a> given <var>global</var>'s
Expand All @@ -4018,9 +4027,8 @@ steps:

<li><p>Set <var>response</var>'s <a for="response">timing info</a> to <var>timingInfo</var>.

<li><p><a href="https://github.com/w3c/resource-timing/pull/261">Mark resource timing</a> for
<var>timingInfo</var>, <var>originalURL</var>, <var>initiatorType</var>, and <var>global</var>.
<!-- TODO -->
<li><p><a for=/>Mark resource timing</a> for <var>timingInfo</var>, <var>originalURL</var>,
<var>initiatorType</var>, <var>global</var>, and <var>cacheState</var>.
</ol>


Expand Down Expand Up @@ -7269,8 +7277,9 @@ method steps are:
<li><p><a lt=terminated for=fetch>Terminate</a> the ongoing fetch with the aborted flag set.
</ol>

<li><p>Let <var>handleFetchDone</var> be to <a>finalize and report timing</a> with
<var>response</var>, <var>globalObject</var>, and "<code>fetch</code>".
<li><p>Let <var>handleFetchDone</var> given <a for=/>response</a> <var>response</var> be to
<a>finalize and report timing</a> with <var>response</var>, <var>globalObject</var>, and
"<code>fetch</code>".

<li>
<p><a for=/>Fetch</a> <var>request</var> with <a for=fetch><i>processResponseDone</i></a> set to
Expand Down

0 comments on commit 5fac9e8

Please sign in to comment.