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

syntax = "proto2";

import public "protos/perfetto/trace/track_event/track_event.proto";
import public "protos/perfetto/trace/track_event/debug_annotation.proto";

package perfetto.protos;

enum ChromeAppState {
  APP_STATE_FOREGROUND = 1;
  APP_STATE_BACKGROUND = 2;
}

enum MemoryPressureLevel {
  MEMORY_PRESSURE_LEVEL_NONE = 0;
  MEMORY_PRESSURE_LEVEL_MODERATE = 1;
  MEMORY_PRESSURE_LEVEL_CRITICAL = 2;
}

message ChromeMemoryPressureNotification {
  optional MemoryPressureLevel level = 1;

  // ID of interned source location where MemoryPressureListener was created
  optional uint64 creation_location_iid = 2;
}

message BlinkTaskScope {
  enum TaskScopeType {
    TASK_SCOPE_UNKNOWN = 0;
    TASK_SCOPE_CALLBACK = 1;
    TASK_SCOPE_SCHEDULED_ACTION = 2;
    TASK_SCOPE_SCRIPT_EXECUTION = 3;
    TASK_SCOPE_POST_MESSAGE = 4;
    TASK_SCOPE_POP_STATE = 5;
    TASK_SCOPE_SCHEDULER_POST_TASK = 6;
    TASK_SCOPE_REQUEST_IDLE_CALLBACK = 7;
  }
  optional TaskScopeType type = 1;
  optional int64 scope_task_id = 2;
  optional int64 running_task_id_to_be_restored = 3;
  optional int64 continuation_task_id_to_be_restored = 4;
  optional int64 parent_task_id = 5;
}

message ChromeTaskAnnotator {
  enum DelayPolicy {
    FLEXIBLE_NO_SOONER = 0;
    FLEXIBLE_PREFER_EARLY = 1;
    PRECISE = 2;
  }
  optional uint32 ipc_hash = 1;
  // The delay in microseconds that was specified, if any, when this task was
  // posted. This is only valid for delayed tasks.
  optional uint64 task_delay_us = 2;
  optional DelayPolicy delay_policy = 3;
}

message ChromeBrowserContext {
  reserved 1;
  optional string id = 2;
}

message ChromeProfileDestroyer {
  optional fixed64 profile_ptr = 1;
  optional bool is_off_the_record = 2;
  optional string otr_profile_id = 3;
  optional uint32 host_count_at_creation = 4;
  optional uint32 host_count_at_destruction = 5;
  optional fixed64 render_process_host_ptr = 6;
}

message ChromeTaskPostedToDisabledQueue {
  optional string task_queue_name = 1;
  optional uint64 time_since_disabled_ms = 2;
  optional uint32 ipc_hash = 3;
  optional uint64 source_location_iid = 4;
}

message ChromeRasterTask {
  optional int64 source_frame_number = 1;
}

message ChromeMessagePumpForUI {
  // The MSG defined in winuser.h.
  optional uint32 message_id = 1;
}

// An enumeration specifying the reason of the RenderFrame deletion.
// This is copied from content/common/frame.mojom.
enum FrameDeleteIntention {
  // The frame being deleted isn't a (speculative) main frame.
  FRAME_DELETE_INTENTION_NOT_MAIN_FRAME = 0;

  // The frame being deleted is a speculative main frame, and it is being
  // deleted as part of the shutdown for that WebContents. The entire RenderView
  // etc will be destroyed by a separate IPC sent later.
  FRAME_DELETE_INTENTION_SPECULATIVE_MAIN_FRAME_FOR_SHUTDOWN = 1;

  // The frame being deleted is a speculative main frame, and it is being
  // deleted because the speculative navigation was cancelled. This is not part
  // of shutdown.
  FRAME_DELETE_INTENTION_SPECULATIVE_MAIN_FRAME_FOR_NAVIGATION_CANCELLED = 2;
}

message RenderFrameImplDeletion {
  // The intent for the deletion.
  optional FrameDeleteIntention intent = 1;

  // Whether the frame that's about to be deleted has a pending navigation
  // commit.
  optional bool has_pending_commit = 2;

  // Whether the frame that's about to be deleted has a pending cross-document
  // navigation commit.
  optional bool has_pending_cross_document_commit = 3;

  // The FrameTreeNode ID of the frame that's about to be deleted.
  optional uint64 frame_tree_node_id = 4;
}

// Matches content::ShouldSwapBrowsingInstance.
enum ShouldSwapBrowsingInstance {
  // Was used for all "no BrowsingInstance swap" scenarios, now broken down in
  // separate reasons.
  SHOULD_SWAP_BROWSING_INSTANCE_NO = 0;

  // Forced BrowsingInstance swap.
  SHOULD_SWAP_BROWSING_INSTANCE_YES_FORCE_SWAP = 1;

  // Proactive BrowsingInstance swap for cross-site navigation.
  SHOULD_SWAP_BROWSING_INSTANCE_YES_CROSS_SITE_PROACTIVE_SWAP = 2;

  // Proactive BrowsingInstance swap for same-site navigation.
  SHOULD_SWAP_BROWSING_INSTANCE_YES_SAME_SITE_PROACTIVE_SWAP = 3;

  SHOULD_SWAP_BROWSING_INSTANCE_NO_PROACTIVE_SWAP_DISABLED = 4;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_NOT_MAIN_FRAME = 5;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_HAS_RELATED_ACTIVE_CONTENTS = 6;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_DOES_NOT_HAVE_SITE = 7;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_SOURCE_URL_SCHEME_NOT_HTTP_OR_HTTPS = 8;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_DESTINATION_URL_SCHEME_NOT_HTTP_OR_HTTPS = 9;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_SAME_SITE_NAVIGATION = 10;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_RELOADING_ERROR_PAGE = 11;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_ALREADY_HAS_MATCHING_BROWSING_INSTANCE = 12;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_RENDERER_DEBUG_URL = 13;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_NOT_NEEDED_FOR_BACK_FORWARD_CACHE = 14;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_SAME_DOCUMENT_NAVIGATION = 15;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_SAME_URL_NAVIGATION = 16;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_WILL_REPLACE_ENTRY = 17;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_RELOAD = 18;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_GUEST = 19;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_HAS_NOT_COMMITTED_ANY_NAVIGATION = 20;
  // The following reason was deprecated from https://crrev.com/c/3858766
  SHOULD_SWAP_BROWSING_INSTANCE_NO_UNLOAD_HANDLER_EXISTS_ON_SAME_SITE_NAVIGATION =
      21;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_NOT_PRIMARY_MAIN_FRAME = 22;
}

message ShouldSwapBrowsingInstancesResult {
  // The FrameTreeNode ID.
  optional uint64 frame_tree_node_id = 1;

  // Whether a navigation will do a BrowsingInstance swap or not.
  optional ShouldSwapBrowsingInstance result = 2;
}

message FrameTreeNodeInfo {
  // The FrameTreeNode ID.
  optional uint64 frame_tree_node_id = 1;

  // Whether the frame is a main frame or not.
  optional bool is_main_frame = 2;

  // Whether there's a speculative RenderFrameHost or not.
  optional bool has_speculative_render_frame_host = 3;

  optional RenderFrameHost current_frame_host = 4;
  optional RenderFrameHost speculative_frame_host = 5;

  // NOTE: this proto must be kept consistent with
  // content::FrameType.
  enum FrameType {
    UNSPECIFIED_FRAME_TYPE = 0;
    SUBFRAME = 1;
    PRIMARY_MAIN_FRAME = 2;
    PRERENDER_MAIN_FRAME = 3;
    FENCED_FRAME_ROOT = 4;
  }

  optional FrameType frame_type = 6;

  // Additional untyped debug information associated with this
  // FrameTreeNode, populated via TracedProto::AddDebugAnnotations API.
  repeated DebugAnnotation debug_annotations = 99;
}

message ChromeHashedPerformanceMark {
  optional uint32 site_hash = 1;
  optional string site = 2;
  optional uint32 mark_hash = 3;
  optional string mark = 4;

  // A randomly generated unique identifier for a given ExecutionContext
  // (document, worker, etc). Used to be able to correlate events in a process
  // where there are multiple execution contexts from the same site.
  optional uint32 execution_context_id = 5;

  // Indicates the sequence number of this particular mark being emitted from
  // a particular site in the scope of a single ExecutionContext. Typical
  // sites emit batches of events that are correlated in time (a thing started,
  // a thing reached a given milestone, a thing completed). When these events
  // are intermixed it is useful to know which ones are semantically related.
  // The value is generated by the content itself, but shifted by a fixed
  // random offset at runtime so as to limit usage as a side channel.
  optional uint32 sequence_number = 6;
}

// Sent on SQL errors where we need string diagnostics. Corresponds to
// `Database::DatabaseDiagnostics` in the Chrome SQL code. Does not contain any
// PII, because the bound values are not included in the SQL statement.
message ChromeSqlDiagnostics {
  optional int32 reported_sqlite_error_code = 1;
  optional int32 error_code = 2;
  optional int32 last_errno = 3;
  optional string sql_statement = 4;
  optional int32 version = 5;

  // Most rows in 'sql_schema' have a non-NULL 'sql' column. Those rows' 'sql'
  // contents are logged here, one element per row.
  repeated string schema_sql_rows = 6;

  // Some rows of 'sql_schema' have a NULL 'sql' column. They are typically
  // autogenerated indices, like "sqlite_autoindex_downloads_slices_1". These
  // are also logged here by their 'name' column, one element per row.
  repeated string schema_other_row_names = 7;

  optional bool has_valid_header = 8;
  optional bool has_valid_schema = 9;
  optional string error_message = 10;
}

message ChromeWebAppBadNavigate {
  optional bool is_kiosk = 1;
  optional bool has_hosted_app_controller = 2;
  optional string app_name = 3;
  optional uint32 system_app_type = 4;
  optional bool web_app_provider_registry_ready = 5;
  optional bool system_web_app_manager_synchronized = 6;
}

// These IDs are generated at compile time and differ for each chrome version.
// IDs are stable on for a given chrome version but are changing when resources
// are added or removed to chrome.
message ResourceBundle {
  optional uint32 resource_id = 1;
}

// Information about RenderProcessHost.
message RenderProcessHost {
  // Unique Id to identify the RenderProcessHost. This is the browser-side,
  // persistent id for this RenderProcessHost that stays constant even across OS
  // layer processes managed by this RenderProcessHost.
  optional uint32 id = 1;
  // See ProcessLock::ToString().
  optional string process_lock = 2;
  // The PID of the child process.
  optional int32 child_process_id = 3;

  // Details about the associated browser context.
  optional ChromeBrowserContext browser_context = 4;

  // Additional untyped debug information associated with this
  // RenderProcessHost, populated via TracedProto::AddDebugAnnotations API.
  repeated DebugAnnotation debug_annotations = 99;
}

message RenderProcessHostListener {
  // Routing ID of the listener to the RenderProcessHost, recorded when a new ID
  // is added or when an ID is removed.
  optional uint32 routing_id = 1;
}

message RenderProcessHostCleanup {
  // Number of IPC listeners registered to the host when Cleanup() was called.
  optional uint32 listener_count = 1;
  // Number of "keep alive" references active in the RenderProcessHost, recorded
  // when Cleanup() was called.
  optional uint32 keep_alive_ref_count = 2;
  // Number of "shutdown delay" references active in the RenderProcessHost,
  // recorded when Cleanup() was called.
  optional uint32 shutdown_delay_ref_count = 3;
  // Number of "worker delay" references active in the RenderProcessHost,
  // recorded when Cleanup() was called.
  optional uint32 worker_ref_count = 4;
  // Number of "pending reuse" references active in the RenderProcessHost,
  // recorded when Cleanup() was called.
  optional uint32 pending_reuse_ref_count = 5;
}

message ChildProcessLauncherPriority {
  // True if the new priority set to background.
  optional bool is_backgrounded = 1;
  // True if the renderer proecss has pending views.
  optional bool has_pending_views = 2;

  // Importance of the child process in Android.
  enum Importance {
    IMPORTANCE_NORMAL = 1;
    IMPORTANCE_MODERATE = 2;
    IMPORTANCE_IMPORTANT = 3;
  }
  optional Importance importance = 3;
}

// Information that identifies a Chrome Extension.
message ChromeExtensionId {
  // Unique id that identifies a Chrome Extension.
  optional string extension_id = 1;

  // Pseudonymized `extension_id` field (see also
  // content::PseudonymizationUtil::PseudonymizeString method).
  optional uint32 pseudonymized_extension_id = 2;
}

message SiteInstance {
  // The ID of the SiteInstance.
  optional int32 site_instance_id = 1;

  // The ID of the BrowsingInstance that the SiteInstance belongs to.
  optional int32 browsing_instance_id = 2;

  // Whether the SiteInstance is the "default SiteInstance" or not. Non-isolated
  // sites on Android are not assigned to their own specific per-site process,
  // and shares SiteInstances with each other (the default SiteInstance).
  optional bool is_default = 3;

  // Whether this SiteInstance has a running process associated with it.
  optional bool has_process = 4;

  // Returns the total active WebContents count for this SiteInstance and all
  // related SiteInstances in the same BrowsingInstance.
  optional int32 related_active_contents_count = 5;

  // The number of active RenderFrameHosts this SiteInstance's SiteInstanceGroup
  // has.
  optional int32 active_rfh_count = 6;

  // The SiteInstanceGroup this SiteInstance belongs to.
  optional SiteInstanceGroup site_instance_group = 7;

  // Additional untyped debug information associated with this
  // SiteInstance, populated via TracedProto::AddDebugAnnotations API.
  repeated DebugAnnotation debug_annotations = 99;
}

message SiteInstanceGroup {
  // The ID of the SiteInstanceGroup.
  optional int32 site_instance_group_id = 1;

  // The number of active frames in this SiteInstanceGroup.
  optional int32 active_frame_count = 2;

  // The process ID of the SiteInstanceGroup.
  optional RenderProcessHost process = 3;

  // Additional untyped debug information associated with this
  // SiteInstanceGroup, populated via TracedProto::AddDebugAnnotations API.
  repeated DebugAnnotation debug_annotations = 99;
}

// Next ID: 7
message RenderViewHost {
  // The RenderViewHostMapId for the RenderViewHost.
  optional int32 rvh_map_id = 1;

  // The routing ID for the RenderViewHost.
  optional int32 routing_id = 2;

  // The process ID of the RenderViewHost. Deprecated in favour of |process|.
  optional int32 process_id = 3;

  // Process this RenderViewHost is associated with.
  optional RenderProcessHost process = 6;

  // Whether the RenderViewHost is in back/forward cache or not.
  optional bool is_in_back_forward_cache = 4;

  // Whether the renderer-side RenderView is created.
  optional bool renderer_view_created = 5;

  // Additional untyped debug information associated with this
  // RenderViewHost, populated via TracedProto::AddDebugAnnotations API.
  repeated DebugAnnotation debug_annotations = 99;
}

message RenderFrameProxyHost {
  // The routing ID for the RenderFrameProxyHost.
  optional int32 routing_id = 1;

  // The process ID of the RenderFrameProxyHost.
  optional int32 process_id = 2;

  // The RenderViewHostMapId of the RenderViewHost associated with the
  // RenderFrameProxyHost.
  optional int32 rvh_map_id = 3;

  // The SiteInstanceId of the SiteInstance associated with the
  // RenderFrameProxyHost.
  optional int32 site_instance_id = 4;

  // Whether the renderer-side RenderFrameProxy is live or not.
  optional bool is_render_frame_proxy_live = 5;

  // The SiteInstanceGroupId of the SiteInstanceGroup associated with the
  // RenderFrameProxyHost.
  optional int32 site_instance_group_id = 6;

  // Additional untyped debug information associated with this
  // RenderFrameProxyHost, populated via TracedProto::AddDebugAnnotations API.
  repeated DebugAnnotation debug_annotations = 99;
}

message AndroidView {
  optional int32 id = 1;
  optional int32 parent_id = 2;
  optional bool is_shown = 3;
  optional bool is_dirty = 4;
  optional string class_name = 5;
  optional string resource_name = 6;
}

message AndroidActivity {
  optional string name = 1;
  repeated AndroidView view = 2;
}

message AndroidViewDump {
  repeated AndroidActivity activity = 1;
}

message ParkableStringCompressInBackground {
  // The size of the string that is being compressed, in bytes.
  optional int32 size_bytes = 1;
}

message ParkableStringUnpark {
  // The size of the string that is being unparked, in bytes.
  optional int32 size_bytes = 1;

  // The elapsed time since the string was written to disk (in seconds), or -1
  // if it hadn't yet been written to disk.
  optional int32 time_since_last_disk_write_sec = 2;
}

message ChromeSamplingProfilerSampleCollected {
  optional int32 frame_count = 1;

  enum WriteStatus {
    WRITE_STATUS_NONE = 0;
    WRITE_STATUS_BUFFERING_SAMPLE = 1;
    WRITE_STATUS_WRITING_BUFFERED = 2;
    WRITE_STATUS_WRITING_TO_TRACE = 3;
  }
  optional WriteStatus write_status = 2;

  optional int32 sampled_thread_id = 3;
}

// Reports the latency caused by each breakdown in the
// SendBeginMainFrameToCommit stage of the PipelineReporter.
message SendBeginMainFrameToCommitBreakdown {
  // Handle input events breakdown
  optional uint64 handle_input_events_us = 1;

  // Animate breakdown
  optional uint64 animate_us = 2;

  // Style update breakdown
  optional uint64 style_update_us = 3;

  // Layout update breakdown
  optional uint64 layout_update_us = 4;

  // Accessibility update breakdown
  optional uint64 accessibility_update_us = 12;

  // Prepaint breakdown
  optional uint64 prepaint_us = 5;

  // Compositing inputs breakdown
  optional uint64 compositing_inputs_us = 6;

  // Compositing assignments breakdown
  optional uint64 compositing_assignments_us = 7;

  // Paint breakdown
  optional uint64 paint_us = 8;

  // Composite commit breakdown
  optional uint64 composite_commit_us = 9;

  // Update layers breakdown
  optional uint64 update_layers_us = 10;

  // Beginmainsenttostarted breakdown
  optional uint64 begin_main_sent_to_started_us = 11;
}

message GlobalRenderFrameHostId {
  optional int32 routing_id = 1;
  optional int32 process_id = 2;
}

message BrowsingContextState {
  // The ID of the BrowsingInstance that the BrowsingContextState belongs to.
  optional int32 browsing_instance_id = 1;

  // The ID of the CoopRelatedGroup that the BrowsingContextState belongs to.
  optional int32 coop_related_group_id = 2 [deprecated = true];

  // The token of the CoopRelatedGroup that the BrowsingContextState belongs to.
  optional string coop_related_group_token = 3;

  // Additional untyped debug information associated with this
  // FrameTreeNode, populated via TracedProto::AddDebugAnnotations API.
  repeated DebugAnnotation debug_annotations = 99;
}

message RenderFrameHost {
  optional RenderProcessHost process = 1;
  optional GlobalRenderFrameHostId render_frame_host_id = 2;

  // NOTE: this proto must be kept consistent with
  // RenderFrameHostImpl::LifecycleStateImpl.
  enum LifecycleState {
    UNSPECIFIED = 0;
    SPECULATIVE = 1;
    PENDING_COMMIT = 2;
    PRERENDERING = 3;
    ACTIVE = 4;
    IN_BACK_FORWARD_CACHE = 5;
    RUNNING_UNLOAD_HANDLERS = 6;
    READY_TO_BE_DELETED = 7;
  }

  optional LifecycleState lifecycle_state = 3;
  optional string origin = 4;
  optional string url = 5;
  optional uint64 frame_tree_node_id = 6;
  optional SiteInstance site_instance = 7;
  optional RenderFrameHost parent = 8;
  optional RenderFrameHost outer_document = 9;
  optional RenderFrameHost embedder = 10;
  optional BrowsingContextState browsing_context_state = 11;
  optional FrameTreeNodeInfo.FrameType frame_type = 12;

  // Additional untyped debug information associated with this
  // RenderViewHost, populated via TracedProto::AddDebugAnnotations API.
  repeated DebugAnnotation debug_annotations = 99;
}

message ChromeThreadPoolTask {
  enum Priority {
    PRIORITY_UNSPECIFIED = 0;
    PRIORITY_BEST_EFFORT = 1;
    PRIORITY_USER_VISIBLE = 2;
    PRIORITY_USER_BLOCKING = 3;
  }

  enum ExecutionMode {
    EXECTUION_MODE_UNSPECIFIED = 0;
    EXECUTION_MODE_PARALLEL = 1;
    EXECUTION_MODE_SEQUENCED = 2;
    EXECUTION_MODE_SINGLE_THREAD = 3;
    EXECUTION_MODE_JOB = 4;
  }

  enum ShutdownBehavior {
    SHUTDOWN_BEHAVIOR_UNSPECIFIED = 0;
    SHUTDOWN_BEHAVIOR_CONTINUE_ON_SHUTDOWN = 1;
    SHUTDOWN_BEHAVIOR_SKIP_ON_SHUTDOWN = 2;
    SHUTDOWN_BEHAVIOR_BLOCK_SHUTDOWN = 3;
  }

  optional Priority task_priority = 1;
  optional ExecutionMode execution_mode = 2;
  optional int64 sequence_token = 3;
  optional ShutdownBehavior shutdown_behavior = 4;
}

// TODO(crbug.com/1258495): Add more information.
message BackForwardCacheCanStoreDocumentResult {
  enum BackForwardCacheNotRestoredReason {
    NOT_MAIN_FRAME = 1;
    // BackForwardCache is disabled due to low memory device, base::Feature or
    // command line. Note that the more specific NotRestoredReasons
    // BACK_FORWARD_CACHE_DISABLED_BY_LOW_MEMORY and
    // BACK_FORWARD_CACHE_DISABLED_BY_COMMAND_LINE will also be set as other
    // reasons along with this when appropriate.
    BACK_FORWARD_CACHE_DISABLED = 2;
    RELATED_ACTIVE_CONTENTS_EXIST = 3;
    HTTP_STATUS_NOT_OK = 4;
    SCHEME_NOT_HTTP_OR_HTTPS = 5;
    LOADING = 6;
    WAS_GRANTED_MEDIA_ACCESS = 7;
    BLOCKLISTED_FEATURES = 8;
    DISABLE_FOR_RENDER_FRAME_HOST_CALLED = 9;
    DOMAIN_NOT_ALLOWED = 10;
    HTTP_METHOD_NOT_GET = 11;
    SUBFRAME_IS_NAVIGATING = 12;
    TIMEOUT = 13;
    CACHE_LIMIT = 14;
    JAVASCRIPT_EXECUTION = 15;
    RENDERER_PROCESS_KILLED = 16;
    RENDERER_PROCESS_CRASHED = 17;
    GRANTED_MEDIA_STREAM_ACCESS = 19;
    SCHEDULER_TRACKED_FEATURE_USED = 20;
    CONFLICTING_BROWSING_INSTANCE = 21;
    CACHE_FLUSHED = 22;
    SERVICE_WORKER_VERSION_ACTIVATION = 23;
    SESSION_RESTORED = 24;
    UNKNOWN = 25;
    SERVICE_WORKER_POST_MESSAGE = 26;
    ENTERED_BACK_FORWARD_CACHE_BEFORE_SERVICE_WORKER_HOST_ADDED = 27;
    NOT_MOST_RECENT_NAVIGATION_ENTRY = 28;
    SERVICE_WORKER_CLAIM = 29;
    IGNORE_EVENT_AND_EVICT = 30;
    HAVE_INNER_CONTENTS = 31;
    TIMEOUT_PUTTING_IN_CACHE = 32;
    // BackForwardCache is disabled due to low memory device.
    BACK_FORWARD_CACHE_DISABLED_BY_LOW_MEMORY = 33;
    // BackForwardCache is disabled due to command-line switch (may include
    // cases where the embedder disabled it due to, e.g., enterprise policy).
    BACK_FORWARD_CACHE_DISABLED_BY_COMMAND_LINE = 34;
    NETWORK_REQUEST_REDIRECTED = 35;
    NETWORK_REQUEST_TIMEOUT = 36;
    NETWORK_EXCEEDS_BUFFER_LIMIT = 37;
    NAVIGATION_CANCELLED_WHILE_RESTORING = 38;
    BACK_FORWARD_CACHE_DISABLED_FOR_PRERENDER = 39;
    USER_AGENT_OVERRIDE_DIFFERS = 40;
    NETWORK_REQUEST_DATAPIPE_DRAINED_AS_BYTES_CONSUMER = 41;
    FOREGROUND_CACHE_LIMIT = 42;
    BROWSING_INSTANCE_NOT_SWAPPED = 43;
    BACK_FORWARD_CACHE_DISABLED_FOR_DELEGATE = 44;
    OPT_IN_UNLOAD_HEADER_NOT_PRESENT = 45;
    UNLOAD_HANDLER_EXISTS_IN_MAIN_FRAME = 46;
    UNLOAD_HANDLER_EXISTS_IN_SUBFRAME = 47;
    SERVICE_WORKER_UNREGISTRATION = 48;
    CACHE_CONTROL_NO_STORE = 49;
    CACHE_CONTROL_NO_STORE_COOKIE_MODIFIED = 50;
    CACHE_CONTROL_NO_STORE_HTTP_ONLY_COOKIE_MODIFIED = 51;
    NO_RESPONSE_HEAD = 52;
    ACTIVATION_NAVIGATION_DISALLOWED_FOR_BUG_1234857 = 53;
    ERROR_DOCUMENT = 54;
    FENCED_FRAMES_EMBEDDER = 55;
    COOKIE_DISABLED = 56;
    HTTP_AUTH_REQUIRED = 57;
    COOKIE_FLUSHED = 58;
  }

  optional BackForwardCacheNotRestoredReason
      back_forward_cache_not_restored_reason = 1;
}

message RendererMainThreadTaskExecution {
  enum TaskType {
    TASK_TYPE_UNKNOWN = 0;
    TASK_TYPE_DOM_MANIPULATION = 1;
    TASK_TYPE_USER_INTERACTION = 2;
    TASK_TYPE_NETWORKING = 3;
    TASK_TYPE_NETWORKING_CONTROL = 4;
    TASK_TYPE_HISTORY_TRAVERSAL = 5;
    TASK_TYPE_EMBED = 6;
    TASK_TYPE_MEDIA_ELEMENT_EVENT = 7;
    TASK_TYPE_CANVAS_BLOB_SERIALIZATION = 8;
    TASK_TYPE_MICROTASK = 9;
    TASK_TYPE_JAVASCRIPT_TIMER_DELAYED_HIGH_NESTING = 10;
    TASK_TYPE_REMOTE_EVENT = 11;
    TASK_TYPE_WEB_SOCKET = 12;
    TASK_TYPE_POSTED_MESSAGE = 13;
    TASK_TYPE_UNSHIPPED_PORT_MESSAGE = 14;
    TASK_TYPE_FILE_READING = 15;
    TASK_TYPE_DATABASE_ACCESS = 16;
    TASK_TYPE_PRESENTATION = 17;
    TASK_TYPE_SENSOR = 18;
    TASK_TYPE_PERFORMANCE_TIMELINE = 19;
    TASK_TYPE_WEB_GL = 20;
    TASK_TYPE_IDLE_TASK = 21;
    TASK_TYPE_MISC_PLATFORM_API = 22;
    TASK_TYPE_INTERNAL_DEFAULT = 23;
    TASK_TYPE_INTERNAL_LOADING = 24;

    TASK_TYPE_INTERNAL_TEST = 26;
    TASK_TYPE_INTERNAL_WEB_CRYPTO = 27;

    TASK_TYPE_INTERNAL_MEDIA = 29;
    TASK_TYPE_INTERNAL_MEDIA_REALTIME = 30;

    TASK_TYPE_INTERNAL_USER_INTERACTION = 32;
    TASK_TYPE_INTERNAL_INSPECTOR = 33;

    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_V8 = 37;
    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_COMPOSITOR = 38;
    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_DEFAULT = 39;
    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_INPUT = 40;
    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_IDLE = 41;

    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_CONTROL = 43;
    TASK_TYPE_INTERNAL_INTERSECTION_OBSERVER = 44;
    TASK_TYPE_COMPOSITOR_THREAD_TASK_QUEUE_DEFAULT = 45;
    TASK_TYPE_WORKER_THREAD_TASK_QUEUE_DEFAULT = 46;
    TASK_TYPE_WORKER_THREAD_TASK_QUEUE_V8 = 47;
    TASK_TYPE_WORKER_THREAD_TASK_QUEUE_COMPOSITOR = 48;
    TASK_TYPE_COMPOSITOR_THREAD_TASK_QUEUE_INPUT = 49;

    // TODO(crbug.com/860545): Obsolete. Remove.
    TASK_TYPE_NETWORKING_WITH_URL_LOADER_ANNOTATION = 50;

    TASK_TYPE_WORKER_ANIMATION = 51;

    TASK_TYPE_INTERNAL_TRANSLATION = 55;
    TASK_TYPE_FONT_LOADING = 56;
    TASK_TYPE_APPLICATION_LIFECYCLE = 57;
    TASK_TYPE_BACKGROUND_FETCH = 58;
    TASK_TYPE_PERMISSION = 59;
    TASK_TYPE_SERVICE_WORKER_CLIENT_MESSAGE = 60;
    TASK_TYPE_INTERNAL_CONTENT_CAPTURE = 61;
    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_MEMORY_PURGE = 62;
    TASK_TYPE_INTERNAL_NAVIGATION_ASSOCIATED = 63;
    TASK_TYPE_INTERNAL_NAVIGATION_ASSOCIATED_UNFREEZABLE = 64;
    TASK_TYPE_INTERNAL_CONTINUE_SCRIPT_LOADING = 65;
    TASK_TYPE_WEB_LOCKS = 66;
    TASK_TYPE_WEB_SCHEDULING_POSTED_TASK = 67;
    TASK_TYPE_INTERNAL_FRAME_LIFE_CYCLE_CONTROL = 68;
    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_NON_WAKING = 69;
    TASK_TYPE_INTERNAL_FIND_IN_PAGE = 70;
    TASK_TYPE_INTERNAL_HIGH_PRIORITY_LOCAL_FRAME = 71;
    TASK_TYPE_JAVASCRIPT_TIMER_IMMEDIATE = 72;
    TASK_TYPE_JAVASCRIPT_TIMER_DELAYED_LOW_NESTING = 73;
    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_IPC_TRACKING = 74;
    TASK_TYPE_NETWORKING_UNFREEZABLE = 75;
    TASK_TYPE_WAKE_LOCK = 76;
    TASK_TYPE_INTERNAL_INPUT_BLOCKING = 77;
    TASK_TYPE_WEB_GPU = 78;
    TASK_TYPE_INTERNAL_POST_MESSAGE_FORWARDING = 79;
    TASK_TYPE_INTERNAL_NAVIGATION_CANCELLATION = 80;
    TASK_TYPE_LOW_PRIORITY_SCRIPT_EXECUTION = 81;
    TASK_TYPE_STORAGE = 82;
    TASK_TYPE_NETWORKING_UNFREEZABLE_RENDER_BLOCKING_LOADING = 83;
    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_V8_LOW_PRIORITY = 84;
    TASK_TYPE_CLIPBOARD = 85;
  }

  enum FrameType {
    FRAME_TYPE_UNSPECIFIED = 0;
    FRAME_TYPE_MAIN_FRAME = 1;
    FRAME_TYPE_SAME_ORIGIN_SUBFRAME = 2;
    FRAME_TYPE_CROSS_ORIGIN_SUBFRAME = 3;
  }

  optional TaskType task_type = 1;

  // FrameScheduler related data
  optional bool frame_visible = 2;
  optional bool page_visible = 3;
  optional FrameType frame_type = 4;
  optional bool is_ad_frame = 5;
}

message EventLatency {
  enum EventType {
    EVENT_TYPE_UNSPECIFIED = 0;
    MOUSE_PRESSED = 1;
    MOUSE_RELEASED = 2;
    MOUSE_WHEEL = 3;
    KEY_PRESSED = 4;
    KEY_RELEASED = 5;
    TOUCH_PRESSED = 6;
    TOUCH_RELEASED = 7;
    TOUCH_MOVED = 8;
    GESTURE_SCROLL_BEGIN = 9;
    GESTURE_SCROLL_UPDATE = 10;
    GESTURE_SCROLL_END = 11;
    GESTURE_DOUBLE_TAP = 12;
    GESTURE_LONG_PRESS = 13;
    GESTURE_LONG_TAP = 14;
    GESTURE_SHOW_PRESS = 15;
    GESTURE_TAP = 16;
    GESTURE_TAP_CANCEL = 17;
    GESTURE_TAP_DOWN = 18;
    GESTURE_TAP_UNCONFIRMED = 19;
    GESTURE_TWO_FINGER_TAP = 20;
    FIRST_GESTURE_SCROLL_UPDATE = 21;
    MOUSE_DRAGGED = 22;
    GESTURE_PINCH_BEGIN = 23;
    GESTURE_PINCH_END = 24;
    GESTURE_PINCH_UPDATE = 25;
    INERTIAL_GESTURE_SCROLL_UPDATE = 26;
    MOUSE_MOVED_EVENT = 27;
  }

  optional EventType event_type = 1;
  optional bool has_high_latency = 2;
  repeated string high_latency_stage = 3;
  // This is same as LatencyInfo's trace_id, using the name event_latency_id to
  // move away from the generic trace_id name used at other places as well.
  optional int64 event_latency_id = 4;
  // This is set only for scroll updates and is based on the
  // Event.ScrollJank.DelayedFramesPercentage.FixedWindow metric.
  optional bool is_janky_scrolled_frame = 5;
  // The interval that this frame was produced for according to the
  // BeginFrameArgs.
  optional double vsync_interval_ms = 6;
}

message ProcessSingleton {
  enum RemoteProcessInteractionResult {
    INTERACTION_RESULT_UNSPECIFIED = 0;
    TERMINATE_FAILED = 1;
    REMOTE_PROCESS_NOT_FOUND = 2;
    TERMINATE_WAIT_TIMEOUT = 3;
    RUNNING_PROCESS_NOTIFY_ERROR = 4;
    TERMINATE_NOT_ENOUGH_PERMISSIONS = 5;
    REMOTE_PROCESS_SHUTTING_DOWN = 6;
    PROFILE_UNLOCKED = 7;
    PROFILE_UNLOCKED_BEFORE_KILL = 8;
    SAME_BROWSER_INSTANCE = 9;
    SAME_BROWSER_INSTANCE_BEFORE_KILL = 10;
    FAILED_TO_EXTRACT_PID = 11;
    INVALID_LOCK_FILE = 12;
    ORPHANED_LOCK_FILE = 13;
    USER_REFUSED_TERMINATION = 14;
    TERMINATE_SUCCEEDED = 100;
  }

  enum RemoteHungProcessTerminateReason {
    TERMINATE_REASON_UNSPECIFIED = 0;
    USER_ACCEPTED_TERMINATION = 1;
    NO_VISIBLE_WINDOW_FOUND = 2;
    NOTIFY_ATTEMPTS_EXCEEDED = 3;
    SOCKET_WRITE_FAILED = 4;
    SOCKET_READ_FAILED = 5;
  }

  optional RemoteProcessInteractionResult remote_process_interaction_result = 1;
  optional RemoteHungProcessTerminateReason remote_process_terminate_reason = 2;
}

message NavigationHandle {
  optional int64 navigation_id = 1;
  optional bool has_committed = 2;
  optional bool is_error_page = 3;
  optional FrameTreeNodeInfo frame_tree_node = 4;
  optional RenderFrameHost render_frame_host = 5;

  // Additional untyped debug information associated with this
  // NavigationHandle/Request, populated via TracedProto::AddDebugAnnotations
  // API.
  repeated DebugAnnotation debug_annotations = 99;
}

enum DeviceThermalState {
  DEVICE_THERMAL_STATE_UNKNOWN = 0;
  DEVICE_THERMAL_STATE_NOMINAL = 1;
  DEVICE_THERMAL_STATE_FAIR = 2;
  DEVICE_THERMAL_STATE_SERIOUS = 3;
  DEVICE_THERMAL_STATE_CRITICAL = 4;
}

// Used to log which Android IPC was called and how long it took.
message AndroidIPC {
  optional string name = 1;
  optional int64 dur_ms = 2;
}

message SequenceManagerTask {
  enum Priority {
    UNKNOWN = 0;
    CONTROL_PRIORITY = 1;
    HIGHEST_PRIORITY = 2;
    VERY_HIGH_PRIORITY = 3;
    HIGH_PRIORITY = 4;
    NORMAL_PRIORITY = 5;
    LOW_PRIORITY = 6;
    BEST_EFFORT_PRIORITY = 7;

    // Renderer-specific priorities.
    HIGH_PRIORITY_CONTINUATION = 8;
    NORMAL_PRIORITY_CONTINUATION = 9;
    LOW_PRIORITY_CONTINUATION = 10;
    EXTREMELY_HIGH_PRIORITY = 11;
  }

  enum QueueName {
    UNKNOWN_TQ = 0;
    DEFAULT_TQ = 1;
    TASK_ENVIRONMENT_DEFAULT_TQ = 2;
    TEST2_TQ = 3;
    TEST_TQ = 4;
    CONTROL_TQ = 5;

    SUBTHREAD_CONTROL_TQ = 6;
    SUBTHREAD_DEFAULT_TQ = 7;
    SUBTHREAD_INPUT_TQ = 8;

    UI_BEST_EFFORT_TQ = 9;
    UI_BOOTSTRAP_TQ = 10;
    UI_CONTROL_TQ = 11;
    UI_DEFAULT_TQ = 12;
    UI_NAVIGATION_NETWORK_RESPONSE_TQ = 13;
    UI_RUN_ALL_PENDING_TQ = 14;
    UI_SERVICE_WORKER_STORAGE_CONTROL_RESPONSE_TQ = 15;
    UI_THREAD_TQ = 16;
    UI_USER_BLOCKING_TQ = 17;
    UI_USER_INPUT_TQ = 18;
    UI_USER_VISIBLE_TQ = 19;

    IO_BEST_EFFORT_TQ = 20;
    IO_BOOTSTRAP_TQ = 21;
    IO_CONTROL_TQ = 22;
    IO_DEFAULT_TQ = 23;
    IO_NAVIGATION_NETWORK_RESPONSE_TQ = 24;
    IO_RUN_ALL_PENDING_TQ = 25;
    IO_SERVICE_WORKER_STORAGE_CONTROL_RESPONSE_TQ = 26;
    IO_THREAD_TQ = 27;
    IO_USER_BLOCKING_TQ = 28;
    IO_USER_INPUT_TQ = 29;
    IO_USER_VISIBLE_TQ = 30;

    COMPOSITOR_TQ = 31;
    DETACHED_TQ = 32;
    FRAME_DEFERRABLE_TQ = 33;
    FRAME_LOADING_CONTROL_TQ = 34;
    FRAME_LOADING_TQ = 35;
    FRAME_PAUSABLE_TQ = 36;
    FRAME_THROTTLEABLE_TQ = 37;
    FRAME_UNPAUSABLE_TQ = 38;
    IDLE_TQ = 39;
    INPUT_TQ = 40;
    IPC_TRACKING_FOR_CACHED_PAGES_TQ = 41;
    NON_WAKING_TQ = 42;
    OTHER_TQ = 43;
    V8_TQ = 44;
    WEB_SCHEDULING_TQ = 45;

    WORKER_IDLE_TQ = 46;
    WORKER_PAUSABLE_TQ = 47;
    WORKER_THREAD_INTERNAL_TQ = 48;
    WORKER_THROTTLEABLE_TQ = 49;
    WORKER_UNPAUSABLE_TQ = 50;
    WORKER_WEB_SCHEDULING_TQ = 51;

    UI_USER_BLOCKING_DEFERRABLE_TQ = 52;
    IO_USER_BLOCKING_DEFERRABLE_TQ = 53;

    UI_BEFORE_UNLOAD_BROWSER_RESPONSE_TQ = 54;
    IO_BEFORE_UNLOAD_BROWSER_RESPONSE_TQ = 55;

    V8_LOW_PRIORITY_TQ = 56;
  }

  optional Priority priority = 1;
  optional QueueName queue_name = 2;
}

message AndroidToolbar {
  enum BlockCaptureReason {
    BLOCKED_UNKNOWN = 0;
    BLOCKED_TOOLBAR_OR_RESULT_NULL = 1;
    BLOCKED_VIEW_NOT_DIRTY = 2;
    BLOCKED_SNAPSHOT_SAME = 3;
    BLOCKED_URL_BAR_HAS_FOCUS = 4;
    BLOCKED_URL_BAR_FOCUS_IN_PROGRESS = 5;
    BLOCKED_OPTIONAL_BUTTON_ANIMATION_IN_PROGRESS = 6;
    BLOCKED_STATUS_ICON_ANIMATION_IN_PROGRESS = 7;
    BLOCKED_SCROLL_ABLATION = 8;
    BLOCKED_BROWSER_CONTROLS_LOCKED = 9;
    BLOCKED_TAB_SWITCHER_MODE = 10;
    BLOCKED_COMPOSITOR_IN_MOTION = 11;
    BLOCKED_NTP_Y_TRANSLATION = 12;
    BLOCKED_FULLSCREEN = 13;
  }
  enum AllowCaptureReason {
    ALLOWED_UNKNOWN = 0;
    ALLOWED_FORCE_CAPTURE = 1;
    ALLOWED_SNAPSHOT_DIFFERENCE = 2;
  }
  enum SnapshotDifference {
    DIFF_NONE = 0;
    DIFF_NULL = 1;
    DIFF_TINT = 2;
    DIFF_TAB_COUNT = 3;
    DIFF_OPTIONAL_BUTTON = 4;
    DIFF_VISUAL_STATE = 5;
    DIFF_SECURITY_ICON = 6;
    DIFF_SHOWING_UPDATE_BADGE = 7;
    DIFF_PAINT_PREVIEW = 8;
    DIFF_PROGRESS = 9;
    DIFF_LOCATION_BAR_WIDTH = 10;
    DIFF_URL_TEXT = 11;
    DIFF_HOME_BUTTON = 12;
    DIFF_TITLE_TEXT = 13;
    DIFF_CCT_ANIMATION = 14;
    DIFF_BOOKMARK_BUTTON = 15;
    DIFF_BACK_BUTTON = 16;
    DIFF_FORWARD_BUTTON = 17;
    DIFF_RELOAD_BUTTON = 18;
  }

  optional BlockCaptureReason block_capture_reason = 1;
  optional AllowCaptureReason allow_capture_reason = 2;
  optional SnapshotDifference snapshot_difference = 3;
}

message ActiveProcesses {
  repeated int32 pid = 1;
}

message UkmPageLoadTimingUpdate {
  // This can be used to uniquely identify a navigation from the point of view
  // of UKM.
  optional int64 ukm_source_id = 1;

  // The URL of a page can change throughout its lifetime. This is the current
  // url when this timing update was dispatched.
  optional string latest_url = 2;

  // Latest fully aggregated value of Cumulative Layout Shift.
  optional float latest_cumulative_layout_shift = 3;

  // Latest fully aggregated value of Largest Contentful Paint.
  optional double latest_largest_contentful_paint_ms = 4;

  optional double first_contentful_paint_ms = 5;
}

// A serialisation of v8StackFrame class.
message V8StackFrame {
  // Code location (path to the script and line/column number)
  message ScriptLocation {
    optional string source_url = 1;
    optional int64 line_number = 2;
    optional int64 column_number = 3;
  }

  // The name of the function that was called
  optional string function_name = 1;

  // If the function was defined in a script, contains the location within the
  // script.
  optional ScriptLocation script_location = 2;
}

// Serializes the blink::ExecutionContext object.
message BlinkExecutionContext {
  // Definition of different context types.
  enum ContextType {
    UNKNOWN_CONTEXT = 0;
    WINDOW = 1;
    WORKLET = 2;
    DEDICATED_WORKER = 3;
    SHARED_WORKER = 4;
    SERVICE_WORKER = 5;
  }

  // Definition of world type.
  enum WorldType {
    WORLD_UNKNOWN = 0;
    WORLD_MAIN = 1;
    WORLD_ISOLATED = 2;
    WORLD_INSPECTOR_ISOLATED = 3;
    WORLD_REG_EXP = 4;
    WORLD_FOR_V8_CONTEXT_SNAPSHOT_NON_MAIN = 5;
    WORLD_WORKER = 6;
    WORLD_SHADOW_REALM = 7;
  }

  optional ContextType type = 1;
  // Contains url of frame or worker.
  optional string url = 2;
  // The origin of the execution context.
  optional string origin = 3;
  // The world type of the execution context.
  optional WorldType world_type = 4;
}

// Serializes the blink::SourceLocation object.
message BlinkSourceLocation {
  optional string function_name = 1;
  optional int32 script_id = 2;
  optional string url = 3;
  optional int32 line_number = 4;
  optional int32 column_number = 5;
  optional string stack_trace = 6;
  repeated V8StackFrame stack_frames = 7;
}

// Contains the meta information for high entropy events (like api calls)
// that are to be traced for debugging in the context of identifiability study.
message BlinkHighEntropyAPI {
  // Serialization of a parameter passed to a javascript function.
  // Contains the stringified type of the object and some string representation
  // of its value.
  message JSFunctionArgument {
    // Definition of different types of function parameters.
    enum ArgumentType {
      UNKNOWN_TYPE = 0;
      NULL_TYPE = 1;
      UNDEFINED = 2;
      BIGINT = 3;
      BOOLEAN = 4;
      FUNCTION = 5;
      NUMBER = 6;
      STRING = 7;
      SYMBOL = 8;
      OBJECT = 9;
    }
    optional ArgumentType type = 1;
    optional string value = 2;
  }

  // Describes a Javascript API call.
  message CalledJsApi {
    // Contains class and function name of api called
    // similar to "Navigator.languages.get".
    optional string identifier = 1;
    repeated JSFunctionArgument func_arguments = 2;

    // Deprecated in favour of outer source_location. Not filled anymore in
    // newer versions of chrome.
    optional BlinkSourceLocation source_location = 3 [deprecated = true];
  }
  optional BlinkExecutionContext execution_context = 1;
  optional CalledJsApi called_api = 2;
  optional BlinkSourceLocation source_location = 3;

  // Describes lookup of a font.
  message FontLookup {
    enum FontLookupType {
      FONT_LOOKUP_UNKNOWN_TYPE = 0;
      FONT_LOOKUP_UNIQUE_OR_FAMILY_NAME = 1;
      FONT_LOOKUP_UNIQUE_NAME_ONLY = 2;
    }
    optional FontLookupType type = 1;
    optional string name = 2;
    optional uint64 weight = 3;
    optional uint64 width = 4;
    optional uint64 slope = 5;
  }
  optional FontLookup font_lookup = 4;
}

// Contains information about a tab switch measurement.
message TabSwitchMeasurement {
  // Possible outcomes of a tab switch. Maps to
  // blink::ContentToVisibleTimeReporter::TabSwitchResult.
  enum Result {
    RESULT_UNSPECIFIED = 0;
    // A frame was successfully presented after a tab switch.
    RESULT_SUCCESS = 1;
    // Tab was hidden before a frame was presented after a tab switch.
    RESULT_INCOMPLETE = 2;
    // TabWasShown called twice for a frame without TabWasHidden between. Treat
    // the first TabWasShown as an incomplete tab switch.
    RESULT_MISSED_TAB_HIDE = 3;
  }

  // State of the target tab. Corresponds to the suffixes of the
  // Browser.TabSwitchResult2.* histograms.
  enum TabState {
    STATE_UNSPECIFIED = 0;
    // The tab has frames in the frame cache, which can be composited in the
    // browser process.
    STATE_WITH_SAVED_FRAMES = 1;
    // The tab has no frames in the frame cache so must be rendered and
    // composited in a renderer process.
    STATE_LOADED_NO_SAVED_FRAMES = 2;
    // The tab has no frames in the frame cache and is not fully loaded, so it
    // must be reloaded before it can be rendered and composited in a renderer
    // process.
    STATE_NOT_LOADED_NO_SAVED_FRAMES = 3;
  }

  optional Result result = 1;
  optional TabState tab_state = 2;
}

// Data about scroll deltas and offsets.
// All values are in physical screen pixels.
message ScrollDeltas {
  // The trace_id of the current input.
  optional int64 trace_id = 1;
  // The original delta for current input. That is, this is the delta that
  // the Browser receives from Android, but already scaled to the device's
  // screen.
  optional float original_delta_x = 2;
  optional float original_delta_y = 3;
  // The trace_id of the input that the current input is coalesced with.
  // If input is not coalesced, this field is null.
  optional int64 coalesced_to_trace_id = 4;
  // The delta which arrived to compositor.
  // This is the sum of all the inputs coalesced together
  // with the resampler applied to them.
  // This delta is used to calculate a |visual_offset|.
  optional float provided_to_compositor_delta_x = 5;
  optional float provided_to_compositor_delta_y = 6;
  // The offset which compositor set.
  optional int64 visual_offset_x = 7;
  optional int64 visual_offset_y = 8;

  // Data which GPU returns.
  // Number of inputs which were shown together in one GPU frame.
  optional int32 event_count_in_gpu_frame = 9;
  // The trace_ids of inputs which were shown together in one GPU frame.
  repeated int64 trace_ids_in_gpu_frame = 10;
  // The sum of original deltas of inputs which were shown together in one GPU
  // frame.
  optional float original_delta_in_gpu_frame_y = 11;
  // The sum of predicted deltas of inputs which were shown together in one GPU
  // frame.
  optional float predicted_delta_in_gpu_frame_y = 12;
  // The array of original deltas of inputs which were shown together in one GPU
  // frame.
  repeated float segregated_original_deltas_in_gpu_frame_y = 13;
  // The array of predicted deltas of inputs which were shown together in one
  // GPU frame.
  repeated float segregated_predicted_deltas_in_gpu_frame_y = 14;
}

// Debug information for system layer of audio rendering on Windows.
message WinRenderAudioFromSource {
  // Buffer size used by the platform.
  optional uint32 iaudioclient_buffer_size_frames = 1;
  // Number of available frames in the platform buffer.
  optional uint32 iaudioclient_buffer_unfilled_frames = 2;
  // Number of frames requested from the audio stream client.
  optional uint32 packet_size_frames = 3;
  // Total number of frames requested from the client and written to the
  // platform buffer during the stream lifetime.
  optional uint64 num_written_frames = 4;
  // Total number of frames played by the platform during the stream lifetime.
  optional uint64 num_played_out_frames = 5;
  // Device frequency reported by the platform; used to convert the stream
  // position to frames.
  optional uint64 iaudioclock_device_frequency = 6;
  // Stream position reported by the platform.
  optional uint64 iaudioclock_stream_position = 7;
  // Performance counter position reported by the platform.
  optional uint64 iaudioclock_qpc_position = 8;
  // Stream position increase since the last call, converted to milliseconds.
  optional int64 iaudioclock_stream_position_increase_ms = 9;
  // Performance counter position since the last call, converted to
  // milliseconds.
  optional int64 iaudioclock_qpc_position_increase_ms = 10;
  // Estimated playout delay, milliseconds.
  optional int64 playout_delay_ms = 11;
};

// Debug information for system layer of audio rendering on Mac.
message MacAUHALStream {
  // The number of frames that the stream requests from the audio source.
  optional int32 input_buffer_size = 1;
  // The number of frames that the OS requests for playout.
  optional uint32 output_buffer_size = 2;
  // Sample rate of the stream.
  optional int32 sample_rate = 3;
  // The time that the audio requested by the OS is expected to play out.
  optional int64 os_request_playout_timeticks_us = 4;
  // Total number of frames requested from the audio source.
  optional int32 source_request_frames = 5;
  // The delay between the request for audio from the source and when the audio
  // is expected to be played out.
  optional int64 source_request_playout_delay_us = 6;
  // The time when the audio that is requested from the source is expected to
  // play out.
  optional int64 source_request_playout_timeticks_us = 7;
  // The time when audio audio is requested from the source.
  optional int64 source_request_current_timeticks_us = 8;
  // The audio playout latency that comes from hardware, in milliseconds.
  optional int64 hardware_latency_us = 9;
  // Whether the kAudioTimeStampHostTimeValid is set on the output
  // AudioTimeStamp.
  optional bool audiotimestamp_host_time_valid = 10;
  // The playout time based on the machine time from AudioTimeStamp.
  optional int64 audiotimestamp_mach_timeticks_us = 11;
  // The time that the audio requested by the os is expected to be consumed by
  // the hardware. Measured in frames since the start of playout.
  optional double audiotimestamp_sample_time_frames = 12;
  // The time that the previous audio requested by the os was expected to be
  // consumed by the hardware. Measured in frames since the start of playout.
  optional double audiotimestamp_last_sample_time_frames = 13;
  // The duration of audio that was estimated to be lost in the case of a
  // glitch.
  optional int64 lost_audio_duration_us = 14;
};

// Debug information for system layer of audio rendering using ALSA on Linux.
message LinuxAlsaOutput {
  // The delay between the request for audio from the source and when the audio
  // is expected to be played out.
  optional int64 source_request_playout_delay_us = 1;
  // The number of bytes that are already present in the buffer on a call to
  // BufferPacket.
  optional int32 forward_bytes = 2;
  // Sample rate of the stream.
  optional int32 sample_rate = 3;
  // Delay obtained by the OS in frames.
  optional int32 getcurrentdelay_pcm_delay_frames = 4;
  // The number of frames in ALSA's buffer.
  optional int32 getcurrentdelay_alsa_buffer_frames = 5;
  // The number of frames that can be written to in ALSA's buffer.
  optional int32 getcurrentdelay_available_frames = 6;
  // The final delay that GetCurrentDelay arrives on, in frames.
  optional int32 getcurrentdelay_final_delay_frames = 7;
};

// Debug information for system layer of audio rendering using Pulse on Linux.
message LinuxPulseOutput {
  // The delay between the request for audio from the source and when the audio
  // is expected to be played out.
  optional int64 source_request_playout_delay_us = 1;
  // Sample rate of the stream.
  optional int32 sample_rate = 2;
  // The number of frames that the stream requests from the audio source.
  optional int32 input_buffer_size_frames = 3;
  // The number of bytes that the OS requests.
  optional uint32 stream_request_bytes = 4;
  // The number of bytes in a single frame.
  optional uint32 frame_size_bytes = 5;
};

// Debug information for system layer of audio rendering on ChromeOS.
message CrasUnified {
  // The total duration of silence due to missing samples during the stream.
  optional int64 underrun_duration_us = 1;
  // Previous underrun duration, used for calculating the length of silence
  // since the last callback.
  optional int64 last_underrun_duration_us = 2;
  // Difference in total underrun duration since the last callback. Logged only
  // when positive, which is when a glitch occurs.
  optional int64 underrun_glitch_duration_us = 3;
  // OS playout latency reported by cras.
  optional int64 latency_us = 4;
  // The number of frames that the stream requests from the audio source.
  optional int32 requested_frames = 5;
  // The number of frames that the source provided.
  optional uint32 filled_frames = 6;
  // Sample rate of the stream.
  optional int32 sample_rate = 7;
};

message ChromeUnguessableToken {
  optional uint64 low_token = 1;
  optional uint64 high_token = 2;
}

message FrameSinkId {
  optional uint32 frame_sink_client_id = 1;
  optional uint32 frame_sink_id = 2;
}

message LocalSurfaceId {
  optional uint32 parent_sequence_number = 1;
  optional uint32 child_sequence_number = 2;
  optional ChromeUnguessableToken unguessable_token = 3;
}

message ChromeGraphicsPipeline {
  enum StepName {
    STEP_UNKNOWN = 0;
    STEP_DID_NOT_PRODUCE_FRAME = 1;
    STEP_GENERATE_COMPOSITOR_FRAME = 2;
    STEP_GENERATE_RENDER_PASS = 3;
    STEP_ISSUE_BEGIN_FRAME = 4;
    STEP_RECEIVE_COMPOSITOR_FRAME = 5;
    STEP_RECEIVE_BEGIN_FRAME = 6;
    STEP_RECEIVE_BEGIN_FRAME_DISCARD = 7;
    STEP_SEND_BEGIN_MAIN_FRAME = 8;
    STEP_SUBMIT_COMPOSITOR_FRAME = 9;
    STEP_SURFACE_AGGREGATION = 10;
    STEP_SEND_BUFFER_SWAP = 11;
    STEP_BUFFER_SWAP_POST_SUBMIT = 12;
    STEP_FINISH_BUFFER_SWAP = 13;
    STEP_SWAP_BUFFERS_ACK = 14;
  }
  enum FrameSkippedReason {
    SKIPPED_REASON_UNKNOWN = 0;
    SKIPPED_REASON_RECOVER_LATENCY = 1;
    SKIPPED_REASON_NO_DAMAGE = 2;
    SKIPPED_REASON_WAITING_ON_MAIN = 3;
    SKIPPED_REASON_DRAW_THROTTLED = 4;
  }
  optional StepName step = 1;
  optional FrameSinkId frame_sink_id = 2;
  optional int64 display_trace_id = 3;
  optional LocalSurfaceId local_surface_id = 4;
  optional int64 frame_sequence = 5;
  optional FrameSkippedReason frame_skipped_reason = 6;
};

message LibunwindstackUnwinder {
  // The enum is a copy of ErrorCode enum inside third_party/libunwindstack,
  // ideally this should be in sync with that.
  enum ErrorCode {
    ERROR_NONE = 0;            // No error.
    ERROR_MEMORY_INVALID = 1;  // Memory read failed.
    ERROR_UNWIND_INFO = 2;     // Unable to use unwind information to unwind.
    ERROR_UNSUPPORTED = 3;     // Encountered unsupported feature.
    ERROR_INVALID_MAP = 4;     // Unwind in an invalid map.
    ERROR_MAX_FRAMES_EXCEEDED = 5;  // The number of frames exceed the total
                                    // allowed.
    ERROR_REPEATED_FRAME = 6;  // The last frame has the same pc/sp as the next.
    ERROR_INVALID_ELF = 7;     // Unwind in an invalid elf.
    ERROR_THREAD_DOES_NOT_EXIST = 8;  // Attempt to unwind a local thread that
                                      // does not exist.
    ERROR_THREAD_TIMEOUT = 9;  // Timeout trying to unwind a local thread.
    ERROR_SYSTEM_CALL = 10;    // System call failed while unwinding.
    ERROR_BAD_ARCH = 11;       // Arch invalid (none, or mismatched).
    ERROR_MAPS_PARSE = 12;     // Failed to parse maps data.
    ERROR_INVALID_PARAMETER_LIBUNWINDSTACK =
        13;                  // Invalid parameter passed to function.
    ERROR_PTRACE_CALL = 14;  // Ptrace call failed while unwinding.
  }
  optional ErrorCode error_code = 1;
  optional int32 num_frames = 2;
};

message ScrollPredictorMetrics {
  message EventFrameValue {
    optional int64 event_trace_id = 1;
    // The fractional pixels (can be fractional after the predictor adjusts in
    // resampling of input) that the page was scrolled by this frame.
    optional float delta_value_pixels = 2;
  };
  // Data from the previous, current, and next frame used to determine the
  // values below as according to the metric doc:
  // http://doc/1Y0u0Tq5eUZff75nYUzQVw6JxmbZAW9m64pJidmnGWsY.
  optional EventFrameValue prev_event_frame_value = 1;
  optional EventFrameValue cur_event_frame_value = 2;
  optional EventFrameValue next_event_frame_value = 3;
  // This is the amount of delta processed in this frame that was above the
  // janky threshold (as defined by
  // http://doc/1Y0u0Tq5eUZff75nYUzQVw6JxmbZAW9m64pJidmnGWsY)
  optional float janky_value_pixels = 4;
  // True if we are also missing frames (so multiple frames are being presented
  // at once).
  optional bool has_missed_vsyncs = 5;
  // True if we're moving less than the slow scroll threshold as defined by the
  // doc above.
  optional bool is_slow_scroll = 6;
};

//
// Critical User Interaction metrics
//

message PageLoad {
  optional int64 navigation_id = 1;
  optional string url = 2;
}

message StartUp {
  // This enum must be kept up to date with LaunchCauseMetrics.LaunchCause.
  enum LaunchCauseType {
    OTHER = 0;
    CUSTOM_TAB = 1;
    TWA = 2;
    RECENTS = 3;
    RECENTS_OR_BACK = 4;
    FOREGROUND_WHEN_LOCKED = 5;
    MAIN_LAUNCHER_ICON = 6;
    MAIN_LAUNCHER_ICON_SHORTCUT = 7;
    HOME_SCREEN_WIDGET = 8;
    OPEN_IN_BROWSER_FROM_MENU = 9;
    EXTERNAL_SEARCH_ACTION_INTENT = 10;
    NOTIFICATION = 11;
    EXTERNAL_VIEW_INTENT = 12;
    OTHER_CHROME = 13;
    WEBAPK_CHROME_DISTRIBUTOR = 14;
    WEBAPK_OTHER_DISTRIBUTOR = 15;
    HOME_SCREEN_SHORTCUT = 16;
    SHARE_INTENT = 17;
    NFC = 18;
  }

  optional int64 activity_id = 1;
  // deprecated field 2.
  optional LaunchCauseType launch_cause = 3;
}

message WebContentInteraction {
  enum Type {
    INTERACTION_UNSPECIFIED = 0;
    INTERACTION_KEYBOARD = 1;
    INTERACTION_CLICK_TAP = 2;
    INTERACTION_DRAG = 3;
  }

  optional Type type = 1;
  optional int64 total_duration_ms = 2;
}

message ChromeTrackEvent {
  // Extension range for Chrome: 1000-1999
  // Next ID: 1059
  extend TrackEvent {
    optional ChromeAppState chrome_app_state = 1000;

    optional ChromeMemoryPressureNotification
        chrome_memory_pressure_notification = 1001;

    optional ChromeTaskAnnotator chrome_task_annotator = 1002;

    optional ChromeBrowserContext chrome_browser_context = 1003;

    optional ChromeProfileDestroyer chrome_profile_destroyer = 1004;

    optional ChromeTaskPostedToDisabledQueue
        chrome_task_posted_to_disabled_queue = 1005;

    optional ChromeRasterTask chrome_raster_task = 1006;

    optional ChromeMessagePumpForUI chrome_message_pump_for_ui = 1007;

    optional RenderFrameImplDeletion render_frame_impl_deletion = 1008;

    optional ShouldSwapBrowsingInstancesResult
        should_swap_browsing_instances_result = 1009;

    optional FrameTreeNodeInfo frame_tree_node_info = 1010;

    optional ChromeHashedPerformanceMark chrome_hashed_performance_mark = 1011;

    optional RenderProcessHost render_process_host = 1012;
    optional RenderProcessHostCleanup render_process_host_cleanup = 1013;
    optional RenderProcessHostListener render_process_host_listener_changed =
        1014;
    optional ChildProcessLauncherPriority child_process_launcher_priority =
        1015;

    optional ResourceBundle resource_bundle = 1016;

    optional ChromeWebAppBadNavigate chrome_web_app_bad_navigate = 1017;

    optional ChromeExtensionId chrome_extension_id = 1018;

    optional SiteInstance site_instance = 1019;

    optional RenderViewHost render_view_host = 1020;

    optional RenderFrameProxyHost render_frame_proxy_host = 1021;

    optional AndroidViewDump android_view_dump = 1022;

    optional ParkableStringCompressInBackground
        parkable_string_compress_in_background = 1023;
    optional ParkableStringUnpark parkable_string_unpark = 1024;

    optional ChromeSamplingProfilerSampleCollected
        chrome_sampling_profiler_sample_completed = 1025;
    optional SendBeginMainFrameToCommitBreakdown
        send_begin_mainframe_to_commit_breakdown = 1026;

    optional GlobalRenderFrameHostId global_render_frame_host_id = 1027;

    optional RenderFrameHost render_frame_host = 1028;

    optional ChromeThreadPoolTask thread_pool_task = 1029;

    optional BackForwardCacheCanStoreDocumentResult
        back_forward_cache_can_store_document_result = 1030;

    optional RendererMainThreadTaskExecution
        renderer_main_thread_task_execution = 1031;

    optional EventLatency event_latency = 1032;

    optional ProcessSingleton process_singleton = 1033;

    optional SiteInstanceGroup site_instance_group = 1034;

    optional BrowsingContextState browsing_context_state = 1035;

    optional DeviceThermalState device_thermal_state = 1036;

    optional NavigationHandle navigation = 1037;

    optional AndroidIPC android_ipc = 1038;

    optional ChromeSqlDiagnostics sql_diagnostics = 1039;

    optional SequenceManagerTask sequence_manager_task = 1040;

    optional AndroidToolbar android_toolbar = 1041;

    optional ActiveProcesses active_processes = 1042;

    optional BlinkTaskScope blink_task_scope = 1043;

    optional UkmPageLoadTimingUpdate ukm_page_load_timing_update = 1044;

    optional BlinkHighEntropyAPI high_entropy_api = 1045;

    optional TabSwitchMeasurement tab_switch_measurement = 1046;

    optional ScrollDeltas scroll_deltas = 1047;

    optional WinRenderAudioFromSource win_render_audio_from_source = 1048;

    optional MacAUHALStream mac_auhal_stream = 1049;

    optional LinuxAlsaOutput linux_alsa_output = 1050;

    optional LinuxPulseOutput linux_pulse_output = 1051;

    optional ChromeGraphicsPipeline chrome_graphics_pipeline = 1052;

    optional CrasUnified chromeos_cras_unified = 1053;

    optional LibunwindstackUnwinder libunwindstack_unwinder = 1054;

    optional ScrollPredictorMetrics scroll_predictor_metrics = 1055;

    optional PageLoad page_load = 1056;

    optional StartUp startup = 1057;

    optional WebContentInteraction web_content_interaction = 1058;
  }
}
