chromium/content/browser/aggregation_service/proto/aggregatable_report.proto

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Protos for persisting AggregatableReportRequests.

syntax = "proto3";

package content.proto;

option optimize_for = LITE_RUNTIME;

// Proto equivalent of `blink::mojom::AggregationServiceMode`
enum AggregationServiceMode {
  TEE_BASED = 0;
  EXPERIMENTAL_POPLAR = 1;
}

// Proto equivalent of `blink::mojom::AggregatableReportHistogramContribution`
message AggregatableReportHistogramContribution {
  uint64 bucket_high = 1;
  uint64 bucket_low = 2;
  int32 value = 3;
  optional uint64 filtering_id = 4;
}

// Proto equivalent of `content::AggregationServicePayloadContents`
message AggregationServicePayloadContents {
  enum Operation {
    HISTOGRAM = 0;
  }

  Operation operation = 1;
  repeated AggregatableReportHistogramContribution contributions = 2;
  AggregationServiceMode aggregation_mode = 3;
  int32 max_contributions_allowed = 5;
  optional string aggregation_coordinator_origin = 6;
  optional uint32 filtering_id_max_bytes = 7;

  reserved 4;
  reserved "aggregation_coordinator";
}

// Proto equivalent of `content::AggregatableReportSharedInfo`
message AggregatableReportSharedInfo {
  enum DebugMode {
    DISABLED = 0;
    ENABLED = 1;
  }

  // Stored as microseconds since the Windows epoch (1601-01-01 00:00:00 UTC).
  int64 scheduled_report_time = 1;
  string report_id = 2;
  string reporting_origin = 3;
  DebugMode debug_mode = 4;
  // additional_fields is assumed to be empty (for now)
  string api_version = 5;
  string api_identifier = 6;
}

// Proto equivalent of `content::AggregatableReportRequest`
message AggregatableReportRequest {
  // processing_urls is inferred to be the default value(s).
  AggregationServicePayloadContents payload_contents = 1;
  AggregatableReportSharedInfo shared_info = 2;
  string reporting_path = 3;
  optional uint64 debug_key = 4;
  int32 failed_send_attempts = 5;
  map<string, string> additional_fields = 6;

  // Rough categories of report scheduling delays used for metrics. Keep this
  // synchronized with `content::AggregatableReportRequest::DelayType`. Do not
  // remove or renumber enumerators because protos containing these values are
  // persisted to disk.
  enum DelayType {
    SCHEDULED_WITH_REDUCED_DELAY = 0;
    SCHEDULED_WITH_FULL_DELAY = 1;
    // Unscheduled requests are never scheduled, and thus never written to disk.
    reserved 2;
    reserved "UNSCHEDULED";
  }
  optional DelayType delay_type = 7;
}