diff --git a/index.bs b/index.bs index 19a88b321..54dd228d0 100644 --- a/index.bs +++ b/index.bs @@ -655,6 +655,38 @@ Note: The [=report window list/total window=] is conceptually a union of [=report windows=], because there are no gaps in time between any of the [=report windows|windows=]. +

Summary window operator

+ +A summary window operator summarizes the triggers within a +[=report window=]. Its value is one of the following: + +
+: "count" +:: Number of triggers attributed. +: "value_sum" +:: Sum of the value of triggers. + +
+ +

Summary bucket

+ +A summary bucket is a [=struct=] with the following items: + +
+: start +:: An unsigned 32-bit integer. +: end +:: An unsigned 32-bit integer. + +
+ +A summary bucket list is a [=list=] of [=summary buckets=]. +It has the following constraints: + +* Elements are strictly in ascending order based on their [=summary bucket/start=]. +* Every element's [=summary bucket/end=] is equal to the next element's [=summary bucket/start=] - 1, if it exists. +* There is at least one element in the list. +

Trigger-data matching mode

A trigger-data matching mode is one of the following: @@ -1866,6 +1898,42 @@ To parse report windows given a |value|, a 1. Set |startDuration| to |endDuration|. 1. Return |windows|. +To parse summary window operator given a [=map=] |map|: + +1. Let |value| be "[=summary window operator/count=]". +1. If |map|["`summary_window_operator`"] [=map/exists=]: + 1. If |map|["`summary_window_operator`"] is not a [=string=], return an + error. + 1. If |map|["`summary_window_operator`"] is not a + [=summary window operator=], return an error. + 1. Set |value| to |map|["`summary_window_operator`"]. +1. Return |value|. + +To parse summary buckets given a [=map=] |map| and an integer |maxEventLevelReports|: + +1. Let |values| be [=the inclusive range|the range=] 1 to + |maxEventLevelReports|, inclusive. +1. If |map|["`summary_buckets`"] [=map/exists=]: + 1. If |map|["`summary_buckets`"] is not a [=list=], [=list/is empty=], or + its [=list/size=] is greater than |maxEventLevelReports|, return an + error. + 1. Set |values| to |map|["`summary_buckets`"]. +1. Let |prev| be 0. +1. Let |summaryBuckets| be an [=list/is empty|empty=] [=list=]. +1. [=list/iterate|For each=] |item| of |values|: + 1. If |item| is not an integer or cannot be represented by an unsigned + 32-bit integer, or is less than or equal to |prev|, return an error. + 1. Let |summaryBucket| be a new [=summary bucket=] whose items are + + : [=summary bucket/start=] + :: |prev| + : [=summary bucket/end=] + :: |item| - 1 + + 1. [=list/Append=] |summaryBucket| to |summaryBuckets|. + 1. Set |prev| to |item|. +1. Return |summaryBuckets|. + To parse trigger specs given a [=map=] |map|, a [=moment=] |sourceTime|, a [=duration=] |expiry|, a [=report window list=] |defaultReportWindows|, an unsigned 32-bit integer @@ -1915,7 +1983,8 @@ To parse trigger specs given a [=map=] |map|, a [=moment=] 1. Set |i| to |i| + 1. 1. Return |specs|. -Issue: Parse "`summary_window_operator`" and "`summary_buckets`" fields. +Issue: Invoke [=parse summary buckets=] and [=parse summary window operator=] +from this algorithm. To parse source-registration JSON given a [=byte sequence=] |json|, a [=suitable origin=] |sourceOrigin|, a [=suitable origin=] |reportingOrigin|, a