Skip to content

Commit

Permalink
Update network module naming to match module-namespaced convention
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraham committed Nov 7, 2022
1 parent 7c05c56 commit 96bffd2
Showing 1 changed file with 69 additions and 67 deletions.
136 changes: 69 additions & 67 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3738,10 +3738,10 @@ NetworkResult = (
)

NetworkEvent = (
NetworkBeforeRequestSentEvent //
NetworkResponseStartedEvent //
NetworkResponseCompletedEvent //
NetworkFetchErrorEvent
network.BeforeRequestSent //
network.ResponseStarted //
network.ResponseCompleted //
network.FetchError
)

</pre>
Expand All @@ -3751,16 +3751,16 @@ NetworkEvent = (
#### The network.BaseEventParams type #### {#type-network-BasEventParams}

<pre class="cddl local-cddl">
NetworkBaseEventParams = {
request: NetworkRequestData,
network.BaseParameters = {
request: network.RequestData,
navigation: Navigation / null,
context: BrowsingContext / null,
timestamp: int
}
</pre>

The <code>BaseEventParams</code> type is an abstract type representing the data
that's common to all network events.
The <code>network.BaseParameters</code> type is an abstract type representing
the data that's common to all network events.

<div algorithm>
To <dfn>get the base network event data</dfn> given |request|:
Expand All @@ -3786,7 +3786,7 @@ To <dfn>get the base network event data</dfn> given |request|:

1. Let |timestamp| be a [=time value=] representing the current date and time in UTC.

1. Let |params| be [=map=] matching the <div>NetworkEventData</div> production, with
1. Let |params| be [=map=] matching the <div>network.BaseParameters</div> production, with
the <code>request</code> field set to |request data|, the |navigation| field
set to <code>navigation</code>, the <code>context</code> field set to
|context id|, and the <code>timestamp</code> field set to |timestamp|.
Expand All @@ -3800,7 +3800,7 @@ To <dfn>get the base network event data</dfn> given |request|:
[=Remote end definition=] and [=local end definition=]

<pre class="cddl local-cddl">
NetworkCookie = {
network.Cookie = {
name: text,
? value: text,
? binaryValue: [ uint ]
Expand All @@ -3815,7 +3815,7 @@ NetworkCookie = {
};
</pre>

The <code>Cookie</code> type represents a cookie.
The <code>network.Cookie</code> type represents a cookie.

If the cookie value can be represented as a UTF-8 encoded string, the
<code>value</code> field will be present. Otherwise the <code>binaryValue</code>
Expand All @@ -3827,7 +3827,7 @@ of the cookie value.
[=Remote end definition=] and [=local end definition=]

<pre class="cddl local-cddl">
NetworkFetchTimingInfo = {
network.FetchTimingInfo = {
requestTime: float,
redirectStart: float,
redirectEnd: float,
Expand All @@ -3845,7 +3845,7 @@ NetworkFetchTimingInfo = {
};
</pre>

The <code>FetchTimingInfo</code> type represents the time of each part of
The <code>network.FetchTimingInfo</code> type represents the time of each part of
the request, relative to <code>requestTime</code>.

<div algorithm>
Expand All @@ -3854,7 +3854,7 @@ To <dfn>get the fetch timings</div> given |request|:
1. Let |global| be |request|'s [=request/client=].
1. If |global| is null, return a map matching the
<code>NetworkFetchTimingInfo</code> production, with all fields set to 0.
<code>network.FetchTimingInfo</code> production, with all fields set to 0.
1. Let |timings| be |request|'s [=fetch timing info=].
Expand Down Expand Up @@ -3897,7 +3897,7 @@ To <dfn>get the fetch timings</div> given |request|:
1. Let |response end| be [=convert fetch timestamp=] given |timing|'s
<a spec=fetch>end time</a> and |global|.
1. Return a [=map=] matching the <code>NetworkFetchTimingInfo</code> production
1. Return a [=map=] matching the <code>network.FetchTimingInfo</code> production
with the <code>requestTime</code> field set to |request time|, the
<code>redirectStart</code> field set to |redirect start|, the
<code>redirectEnd</code> field set to |redirect end|, the
Expand All @@ -3919,14 +3919,14 @@ TODO: Add service worker fields
[=Remote end definition=] and [=local end definition=]
<pre class="cddl local-cddl">
NetworkHeader = {
network.Header = {
name: text,
? value: text,
? binaryValue: [ uint ]
};
</pre>
The <code>Header</code> type represents a single request header.
The <code>network.Header</code> type represents a single request header.
If the header value can be represented as a UTF-8 encoded string, the
<code>value</code> field will be present. Otherwise the <code>binaryValue</code>
Expand Down Expand Up @@ -3954,7 +3954,7 @@ To <dfn>get a header</dfn> given |name bytes| and |value bytes|:
Otherwise: let |value| be |utf8 decoded value| and let |binary value|
be null.

1. Return a map matching the <code>NetworkHeader</code> production, with the
1. Return a map matching the <code>network.Header</code> production, with the
<code>name</code> field set to |name|, the <code>value</code> field
set to |value| if it's not null, or omitted otherwise, and the
<code>binaryValue</code> field set to |binary value| if it's not null, or
Expand All @@ -3967,16 +3967,17 @@ To <dfn>get a header</dfn> given |name bytes| and |value bytes|:
[=Remote end definition=] and [=local end definition=]

<pre class="cddl local-cddl">
NetworkInitiator = {
network.Initiator = {
type: "parser" / "script" / "preflight" / "other",
?columnNumber: uint,
?lineNumber: uint,
?stackTrace: StackTrace,
?request: NetworkRequest
?request: network.Request
};
</pre>

The <code>Initiatior</code> type represents the source of a network request.
The <code>network.Initiatior</code> type represents the source of a network
request.

<div algorithm>
To <dfn>get the initiator</dfn> given |request|:
Expand Down Expand Up @@ -4006,7 +4007,7 @@ To <dfn>get the initiator</dfn> given |request|:
TODO: Chrome includes the current parser position as column number / line
number for parser-inserted resources.

1. Return a [=map=] matching the <code>NetworkInitiator</code> production, with
1. Return a [=map=] matching the <code>network.Initiator</code> production, with
the |type| field set to "<code>type</code>", the <code>columnNumber</code>
field set to |column number| if it's not null, or omitted otherwise, the
<code>lineNumber</code> field set to |line number| if it's not null, or
Expand All @@ -4020,7 +4021,7 @@ To <dfn>get the initiator</dfn> given |request|:
[=Remote end definition=] and [=local end definition=]

<pre class="cddl local-cddl remote-cddl">
NetworkRequest = text;
network.Request = text;
</pre>

Each network request has an associated <dfn export>request id</dfn>, which is a
Expand All @@ -4032,19 +4033,19 @@ redirect matches that of the request that initiated it.
[=Remote end definition=] and [=local end definition=]

<pre class="cddl local-cddl">
NetworkRequestData = {
request: NetworkRequest,
network.RequestData = {
request: network.Request,
url: text,
method: text,
headers: [ *NetworkHeader ],
cookies: [ *NetworkCookie ],
headers: [*network.Header],
cookies: [*network.Cookie],
headersSize: uint,
bodySize: uint,
timings: NetworkFetchTimingInfo,
timings: network.FetchTimingInfo,
};
</pre>

The <code>RequestData</code> type represents an ongoing network request.
The <code>network.RequestData</code> type represents an ongoing network request.

<div algorithm>

Expand Down Expand Up @@ -4094,7 +4095,7 @@ To <dfn>get the request data</dfn> given |request|:

1. Let |timings| be [=get the fetch timings=] with |request|.

1. Return a map matching the <code>NetworkRequestData</code> production, with
1. Return a map matching the <code>network.RequestData</code> production, with
the <code>request</code> field set to |request id|, <code>url</code> field
set to |url|, the <code>method</code> field set to |method|, the
<code>headers</code> field set to |headers|, the |cookies| field set to
Expand All @@ -4109,21 +4110,21 @@ To <dfn>get the request data</dfn> given |request|:
[=Remote end definition=] and [=local end definition=]

<pre class="cddl local-cddl">
NetworkResponseContent = {
network.ResponseContent = {
size: unit / null
};
</pre>

The <code>ResponseContent</code> type represents the decoded response to a
network request.
The <code>network.ResponseContent</code> type represents the decoded response to
a network request.

<!-- Not sure this is worthwhile if it only ends up with a single field, but it
would be natural to add a field here if we have a way to return the body -->

<div algorithm>
To <dfn>get the response content info</dfn> given |response|.

1. Return a new map matching the <code>NetworkResponseContent</code>
1. Return a new map matching the <code>network.ResponseContent</code>
production, with the <code>size</code> field set to |response|'s [=response body
info=]'s [=decoded size=]

Expand All @@ -4134,21 +4135,22 @@ To <dfn>get the response content info</dfn> given |response|.
[=Remote end definition=] and [=local end definition=]

<pre class="cddl local-cddl">
NetworkResponseData = {
network.ResponseData = {
url: text,
protocol: text,
status: uint,
statusText: text,
headers: [ *NetworkHeader ],
headers: [*network.Header],
mimeType: text,
bytesReceived: uint,
headersSize: uint / null,
bodySize: uint / null,
content: NetworkResponseContent
content: network.ResponseContent
};
</pre>

The <code>RequestData</code> type represents the response to a network request.
The <code>network.RequestData</code> type represents the response to a network
request.

<div algorithm>
To <dfn>get the response data</div> given |response|:
Expand Down Expand Up @@ -4180,7 +4182,7 @@ To <dfn>get the response data</div> given |response|:
1. Let |content| be |response|'s [=get the response content info=] with |response|.
1. Return a [=map=] matching the <code>NetworkResponseData</code> production,
1. Return a [=map=] matching the <code>network.ResponseData</code> production,
with the <code>url</code> field set to |url|, the <code>protocol</code> field
set to |protocol|, the <code>status</code> field set to |status|, the
<code>statusText</code> field set to |status text|, the <code>headers</code>
Expand All @@ -4200,14 +4202,14 @@ To <dfn>get the response data</div> given |response|:
<dt>Event Type</dt>
<dd>
<pre class="cddl local-cddl">
NetworkBeforeRequestSentEvent = {
network.BeforeRequestSent = {
method: "network.beforeRequestSent",
params: NetworkBeforeRequestSentParams
params: network.BeforeRequestSentParameters
}
NetworkBeforeRequestSentParams = {
NetworkBaseEventParams,
initiator: NetworkInitiator
network.BeforeRequestSentParameters = {
network.BaseParameters,
initiator: network.Initiator
}
</pre>
</dd>
Expand All @@ -4226,10 +4228,10 @@ request sent</dfn> steps given |request|:

1. Set the <code>initiatior</code> field of |params| to |initiator|.

1. Assert: |params| matches the <code>NetworkBeforeRequestSentParams</code>
1. Assert: |params| matches the <code>network.BeforeRequestSentParameters</code>
production.

1. Let |body| be a map matching the <code>NetworkResponseStarted</code>
1. Let |body| be a map matching the <code>network.ResponseStarted</code>
production, with the <code>params</code> field set to |params|.

1. [=Emit events=] with |body| and |related browsing contexts|.
Expand All @@ -4242,13 +4244,13 @@ request sent</dfn> steps given |request|:
<dt>Event Type</dt>
<dd>
<pre class="cddl local-cddl">
NetworkFetchErrorEvent = {
network.FetchError = {
method: "network.fetchError",
params: NetworkFetchErrorParams
params: network.FetchErrorParameters
}

NetworkFetchErrorParams = {
NetworkBaseEventParams,
network.FetchErrorParameters = {
network.BaseParameters,
errorText: text,
}
</pre>
Expand All @@ -4267,10 +4269,10 @@ error</dfn> steps given |request|:

1. TODO: Set the <code>errorText</code> field of |params|.

1. Assert: |params| matches the <code>NetworkFetchErrorParams</code>
1. Assert: |params| matches the <code>network.FetchErrorParameters</code>
production.

1. Let |body| be a map matching the <code>NetworkFetchErrorEvent</code>
1. Let |body| be a map matching the <code>network.FetchError</code>
production, with the <code>params</code> field set to |params|.

1. [=Emit events=] with |body| and |related browsing contexts|.
Expand All @@ -4283,14 +4285,14 @@ error</dfn> steps given |request|:
<dt>Event Type</dt>
<dd>
<pre class="cddl local-cddl">
NetworkResponseCompletedEvent = {
network.ResponseCompleted = {
method: "network.responseCompleted",
params: NetworkResponseCompletedParams
params: network.ResponseCompletedParameters
}

NetworkResponseCompletedParams = {
NetworkBaseEventParams,
response: NetworkResponseData,
network.ResponseCompletedParameters = {
network.BaseParameters,
response: network.ResponseData,
}
</pre>
</dd>
Expand All @@ -4309,10 +4311,10 @@ completed</dfn> steps given |request| and |response|:

1. Set the <code>response</code> field of |params| to |response data|.

1. Assert: |params| matches the <code>NetworkResponseCompletedParams</code>
1. Assert: |params| matches the <code>network.ResponseCompletedParameters</code>
production.

1. Let |body| be a map matching the <code>NetworkResponseCompleted</code>
1. Let |body| be a map matching the <code>network.ResponseCompleted</code>
production, with the <code>params</code> field set to |params|.

1. [=Emit events=] with |body| and |related browsing contexts|.
Expand All @@ -4325,14 +4327,14 @@ completed</dfn> steps given |request| and |response|:
<dt>Event Type</dt>
<dd>
<pre class="cddl local-cddl">
NetworkResponseStartedEvent = {
method: "network.responseStartedEvent",
params: NetworkResponseStartedParams
network.ResponseStarted = {
method: "network.responseStarted",
params: network.ResponseStartedParameters
}

NetworkResponseStartedParams = {
NetworkBaseEventParams,
response: NetworkResponseData,
network.ResponseStartedParameters = {
network.BaseParameters,
response: network.ResponseData,
}
</pre>
</dd>
Expand All @@ -4352,10 +4354,10 @@ started</dfn> steps given |request| and |response|:

1. Set the <code>response</code> field of |params| to |response data|.

1. Assert: |params| matches the <code>NetworkResponseStartedParams</code>
1. Assert: |params| matches the <code>network.ResponseStartedParameters</code>
production.

1. Let |body| be a map matching the <code>NetworkResponseStarted</code>
1. Let |body| be a map matching the <code>network.ResponseStarted</code>
production, with the <code>params</code> field set to |params|.

1. [=Emit events=] with |body| and |related browsing contexts|.
Expand Down

0 comments on commit 96bffd2

Please sign in to comment.