




























@@ -297,6 +297,7 @@
297297 readonly attribute Megabit downlinkMax;
298298 readonly attribute Megabit downlink;
299299 readonly attribute Millisecond rtt;
300+ readonly attribute boolean saveData;
300301 attribute EventHandler onchange;
301302 };
302303332333333334 The `rtt` attribute represents the effective round-trip time estimate in <dfn data-lt="Millisecond">milliseconds</dfn>, rounded to nearest multiple of 25 milliseconds, and is based on recently observed application-layer RTT measurements across recently active connections, excluding connections made to private address space [[!RFC1918]]. In absence of recent RTT measurement data, the attribute value is determined by the properties of the <a>underlying connection technology</a>.
334335336+ ### <dfn>saveData</dfn> attribute
337+338+ The `saveData` attribute, when getting, returns `true` if the user has requested a reduced data usage mode from the user agent, and `false` otherwise.
339+340+<p class="note">The user may enable such preference, if made available by the user agent, due to high data transfer costs, slow connection speeds, or other reasons.</p>
341+342+<section>
343+ #### Save-Data (Client Hint) Request Header Field
344+345+ The “Save-Data” request header field consists of one or more tokens that indicate user agent's preference for reduced data usage.
346+347+<pre class="highlight">
348+ Save-Data = sd-token *( OWS ";" OWS [sd-token] )
349+ sd-token = token
350+</pre>
351+352+ This specification defines the "`on`" `sd-token` value, which is used as a signal indicating explicit user opt-in into a reduced data usage mode (i.e. when <a>saveData</a>'s value is `true`), and when communicated to origins allows them to deliver alternate content honoring such preference - e.g. smaller image and video resources, alternate markup, and so on.
353+354+ If Save-Data occurs in a message more than once, the last value overrides all previous occurrences.
355+356+<p class="issue">TODO: update <a href="https://fetch.spec.whatwg.org/#fetching">Fetch#fetching algorithm</a> to use `connection.saveData` as signal to append the Save-Data header.</p>
357+</section>
335358</section>
336359337360368391<section data-link-for="NetworkInformation">
369392### Handling changes to the underlying connection
370393371-When the properties of the <a>underlying connection technology</a> change, due to a switch to a different <a>connection type</a> or <a>effective connection type</a>, change in <a>upper bound on the downlink speed of the first network hop</a>, or change in effective <a>downlink</a> or <a>rtt</a> estimates, the user agent MUST run the <dfn>steps to update the connection values</dfn>:
394+When the properties of the <a>underlying connection technology</a> change, due to a switch to a different <a>connection type</a> or <a>effective connection type</a>, change in <a>upper bound on the downlink speed of the first network hop</a>, change in effective <a>downlink</a> or <a>rtt</a> estimates, or change in <a>saveData</a> preference, the user agent MUST run the <dfn>steps to update the connection values</dfn>:
372395373396 1. Let <var>new-type</var> be the <a>connection type</a> that represents the <a>underlying connection technology</a>.
374397 1. Let <var>new-effective-type</var> be the <a>effective connection type</a> determined by current <a>downlink</a> and <a>rtt</a> values.
398+ 1. Let <var>new-saveData</var> be the current <a>saveData</a> preference.
375399 1. Let <var>new-downlink</var> be the result of:
376400 1. Rounding <a>downlink</a> value to nearest multiple of 25 kilobits per second.
377401 1. If the resulting value is 10% greater or smaller than the value of `connection.downlink`, then set <var>new-dowlink</var> to resulting value. Otherwise, set <var>new-downlink</var> to the value of `connection.downlink`.
@@ -382,13 +406,14 @@
382406 1. if <var>new-type</var> is "unknown", set <var>max-value</var> to `+Infinity`.
383407 1. If <var>new-type</var> is "mixed", set <var>max-value</var> to an applicable value for the interface configuration used to service new network requests - e.g. if multiple interfaces may be used, sum their <a>downlinkMax for an available interface</a> values.
384408 1. Otherwise, set <var>max-value</var> to <a>downlinkMax for an available interface</a>.
385- 1. If <var>max-value</var> is not equal to the value of `connection.downlinkMax`, or if <var>new-type</var> is not equal to the value of `connection.type`, or if <var>new-downlink</var> is not equal to the value of `connection.downlink`, or if <var>new-rtt</var> is not equal to the value of `connection.rtt`:
409+ 1. If <var>max-value</var> is not equal to the value of `connection.downlinkMax`, or if <var>new-type</var> is not equal to the value of `connection.type`, or if <var>new-downlink</var> is not equal to the value of `connection.downlink`, or if <var>new-rtt</var> is not equal to the value of `connection.rtt`, or if <var>new-saveData</var> is not equal to the value of `connection.saveData`:
386410 1. Using the <a data-cite="!HTML#networking-task-source">networking task source</a>, <a data-cite="!HTML#queue-a-task">queue a task</a> to perform the following:
387411 1. Set `connection.downlinkMax` to <var>max-value</var>.
388412 1. Set `connection.type` to <var>new-type</var>.
389413 1. set `connection.effectiveType` to <var>new-effective-type</var>.
390414 1. Set `connection.downlink` to <var>new-downlink</var>.
391415 1. Set `connection.rtt` to <var>new-rtt</var>.
416+ 1. Set `connection.saveData` to <var>new-saveData</var>.
392417 1. <a data-cite="!DOM#concept-event-fire">Fire an event</a> named `change` at the `NetworkInformation` object.
393418</section>
394419此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。