From 988d99e20f1844db989339c8bb4dfa50905459b8 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 28 Feb 2022 08:53:21 +0200 Subject: [PATCH] Small refactor --- source | 88 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/source b/source index 910f337c472..ba990c15fcf 100644 --- a/source +++ b/source @@ -2492,6 +2492,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • finalize and report timing
  • serialize a response URL for reporting
  • safely extracting a body
  • +
  • incrementally reading a body
  • processResponseConsumeBody
  • processResponseEndOfBody
  • @@ -33679,7 +33680,7 @@ interface HTMLMediaElement : HTMLElement {

    A media resource has an associated origin, which is either "none", "multiple", "rewritten", or an - origin.

    It is initially set to "none". + origin. It is initially set to "none".

    A media resource can have multiple audio and video tracks. For the purposes of a media element, the video data of the media resource is only that of the @@ -34495,13 +34496,15 @@ interface MediaError {

    To verify a media response given a response - response, a media resource resource and a Null or - (number, Null or number) optionalByteRange:

    + response, a media resource resource and + "entire resource" or (number, number or "until end") + optionalByteRange:

    1. If response is a network error, return false.

    2. -
    3. If optionalByteRange is null, return true.

    4. +
    5. If optionalByteRange is "entire resource", return + true.

    6. Let internalResponse be response's unsafe response.

    7. @@ -34520,7 +34523,7 @@ interface MediaError {
    8. If any of the following conditions are true:

        -
      • previousOrigin is "none
      • +
      • previousOrigin is "none"
      • origin and previousOrigin are "rewritten"
      • @@ -34541,11 +34544,12 @@ interface MediaError {
      • Let (start, end) be the result of - extracting content range from + extracting content-range values from internalResponse.

      • If start is not optionalByteRange[0], or if - optionalByteRange[1] is neither null or end, return false.

      • + optionalByteRange[1] is neither "until end" or end, + return false.

      • Return true.

    @@ -34614,7 +34618,7 @@ interface MediaError {
  • Let destination be "audio" if the media - element is an audio element and to "video" + element is an audio element, or "video" otherwise.

  • Let request be the result of MediaError { media element's node document's relevant settings object.

  • -
  • Let optionalByteRange, which is Null or (number, Null or number) be - the byte range required to satisfy missing data in media data. This value is - implementation-defined and may rely on codec, network conditions or other - heuristics. The user-agent may determine to fetch the resource in full, in which case - optionalByteRange would be null.

  • +
  • Let optionalByteRange, which is "entire resource" or + (number, number or "until end") be the byte range required to satisfy + missing data in media data. This value is implementation-defined + and may rely on codec, network conditions or other heuristics. The user-agent may determine + to fetch the resource in full, in which case optionalByteRange would be + "entire resource", to fetch from a byte offset until the end, + in which case optionalByteRange would be + (number, "until end"), or to fetch a range between two byte offsets, + im which case optionalByteRange (number, number) representing the two + offsets.

  • If optionalByteRange is not null, then add a range header to request given optionalByteRange[0] and @@ -34641,17 +34650,45 @@ interface MediaError {

    Fetch request, with processResponseEndOfBody given response set to - finalize and report timing with response, - the media element's node document's - relevant global object, and destination + and processResponse set to the following steps given response response:

      +
    1. Let global be the media element's + node document's relevant global object.

    2. + +
    3. Let updateMedia be to queue a media element task given + the media element to run the first appropriate steps from the + media data processing steps list below. (A new task is used for + this so that the work described below occurs relative to the appropriate + media element event task source rather than using the + networking task source.)

      + +
    4. Let finalize be to finalize and report timing with + response, global, and destination, and call + updateMedia.

    5. + +
    6. +

      Let processEndOfMedia be the following steps:

      + +
        +
      1. Call finalize.

        + +
      2. If the fetching process has completes without errors, including decoding the + media data, and if all of the data is available to the user agent without network + access, then, the user agent must move on to the final step below. + This might never happen, e.g. when streaming an infinite resource such as web radio, or + if the resource is longer than the user agent's ability to cache data.

        +
      +
    7. +
    8. If the result of verifying response given the current media resource and - optionalByteRange is false, then set response to a new - network error.

    9. + optionalByteRange is false, then set call finalize; Otherwise, + incrementally read response's + body given updateMedia, + processEndOfMedia, finalize, and global.

    10. Update media data with the contents of response's unsafe response obtained in this fashion. response can be @@ -34718,21 +34755,6 @@ interface MediaError { given the media element to fire an event named progress at the element.

      -

      The networking task source tasks to - process the data as it is being fetched must each immediately queue a - media element task given the media element to run the first appropriate - steps from the media data processing steps list below. (A new task is used for - this so that the work described below occurs relative to the appropriate media element - event task source rather than using the networking task source.)

      - -

      When the networking task source has queued the last task as part of fetching the - media resource (i.e. once the download has completed), if the fetching process - completes without errors, including decoding the media data, and if all of the data is available - to the user agent without network access, then, the user agent must move on to the final step below. - This might never happen, e.g. when streaming an infinite resource such as web radio, or if the - resource is longer than the user agent's ability to cache data.

      -

      While the user agent might still need network access to obtain parts of the media resource, the user agent must remain on this step.