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

edition = "2023";

package optimization_guide.proto;

option features.enum_type = CLOSED;
option features.utf8_validation = NONE;
option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.components.optimization_guide.proto";
option java_outer_classname = "CommonTypesProto";

// Context in which the items are requested.
enum RequestContext {
  reserved 1, 3, 10, 16;

  // Context not specified.
  CONTEXT_UNSPECIFIED = 0;

  // Requesting items on page navigation.
  CONTEXT_PAGE_NAVIGATION = 2;

  // Requesting as part of a SRP fetch.
  CONTEXT_BATCH_UPDATE_GOOGLE_SRP = 4;

  // Requesting as part of a regularly scheduled fetch for active tabs.
  CONTEXT_BATCH_UPDATE_ACTIVE_TABS = 5;

  // Requesting a batch of models to update.
  CONTEXT_BATCH_UPDATE_MODELS = 6;

  // Requesting page load metadata for a user's bookmarks when visiting the
  // bookmarks surface.
  CONTEXT_BOOKMARKS = 7;

  // Requesting metadata for a user when visiting the Journeys surface.
  CONTEXT_JOURNEYS = 8;

  // Requesting metadata for a user when visiting the new tab page.
  CONTEXT_NEW_TAB_PAGE = 9;

  // Requesting metadata for a user when visiting the Page Insights feature;
  // Gaia can be attached to request.
  CONTEXT_PAGE_INSIGHTS_HUB = 11;

  // Requesting metadata for a user when visiting the Page Insights feature;
  // Gaia cannot be attached to request.
  CONTEXT_NON_PERSONALIZED_PAGE_INSIGHTS_HUB = 12;

  // Requesting metadata for shopping features. This is used for relevant URLs
  // (open tabs, bookmarks, etc.) if information is determined to be stale or
  // has otherwise been flushed from the cache.
  CONTEXT_SHOPPING = 13;

  // Requesting metadata when rendering ShopCard on Magic Stack (which
  // surfaces shopping related information on a user's URL or ShoppingList).
  CONTEXT_SHOP_CARD = 14;

  // Requesting metadata when user starts glic, to determine if a page is
  // eligible for glic zero state suggestions.
  CONTEXT_GLIC_ZERO_STATE_SUGGESTIONS = 15;

  // Requesting metadata for a filter execution strategy (e.g., the target URL
  // with filter parameters) to apply a Magic Filters suggestion.
  CONTEXT_FILTER_EXECUTION = 17;
}

message FieldTrial {
  // The hash of a field trial.
  uint32 name_hash = 1;

  // The hash of the active group within the field trial.
  uint32 group_hash = 2;
}

// A Duration represents a signed, fixed-length span of time represented
// as a count of seconds and fractions of seconds at nanosecond
// resolution. It is independent of any calendar and concepts like "day"
// or "month". It is related to Timestamp in that the difference between
// two Timestamp values is a Duration and it can be added or subtracted
// from a Timestamp. Range is approximately +-10,000 years.
// This is local definition matching server side duration.proto definition.
message Duration {
  // Signed seconds of the span of time. Must be from -315,576,000,000
  // to +315,576,000,000 inclusive.
  int64 seconds = 1;

  // Signed fractions of a second at nanosecond resolution of the span
  // of time. Durations less than one second are represented with a 0
  // `seconds` field and a positive or negative `nanos` field. For durations
  // of one second or more, a non-zero value for the `nanos` field must be
  // of the same sign as the `seconds` field. Must be from -999,999,999
  // to +999,999,999 inclusive.
  int32 nanos = 2;
}

message Timestamp {
  // Represents seconds of UTC time since Unix epoch
  // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
  // 9999-12-31T23:59:59Z inclusive.
  int64 seconds = 1;

  // Non-negative fractions of a second at nanosecond resolution. Negative
  // second values with fractions must still have non-negative nanos values
  // that count forward in time. Must be from 0 to 999,999,999
  // inclusive.
  int32 nanos = 2;
}

message Any {
  // A URL/resource name that uniquely identifies the type of the serialized
  // protocol buffer message.
  string type_url = 1;

  // Must be a valid serialized protocol buffer of the above specified type.
  bytes value = 2;
}

// Information about the request origin, common to all Cacao requests.
message OriginInfo {
  // The platform for the user's Chrome.
  Platform platform = 1;

  reserved 2;

  // The dotted version number of the user's Chrome. e.g. "145.0.7576.0"
  string version = 3;
}

// The platform for the user's Chrome on which the request was made.
enum Platform {
  reserved 7;

  // Undefined is used when the user's platform cannot be resolved.
  PLATFORM_UNDEFINED = 0;

  // Android based platforms.
  PLATFORM_ANDROID = 1;

  // ChromeOS platforms including all architectures.
  PLATFORM_CHROMEOS = 2;

  // IOS based platforms.
  PLATFORM_IOS = 3;

  // Linux platforms including all architectures.
  PLATFORM_LINUX = 4;

  // Mac based platforms.
  PLATFORM_MAC = 5;

  // Windows based platforms.
  PLATFORM_WINDOWS = 6;
}
