// 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";
import public "protos/perfetto/trace/track_event/source_location.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;
    TASK_SCOPE_XML_HTTP_REQUEST = 8;
    TASK_SCOPE_SOFT_NAVIGATION = 9;
    TASK_SCOPE_MISC_EVENT = 10;
    TASK_SCOPE_MICROTASK = 11;
    TASK_SCOPE_RESOURCE_TIMING = 12;
    TASK_SCOPE_SCRIPT_TOOL_EXECUTION = 13;
  }
  optional TaskScopeType type = 1;
  optional int64 scope_task_id = 2;
  optional int64 running_task_id_to_be_restored = 3;

  reserved 4, 5;
  reserved "continuation_task_id_to_be_restored", "parent_task_id";
}

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;
  // The result of the Win32 API call WaitForMultipleObjectsEx().
  optional uint32 wait_for_object_result = 2;
}

// 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 is about to be deleted has a pending navigation
  // commit.
  optional bool has_pending_commit = 2;

  // Whether the frame that is 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 is about to be deleted.
  optional uint64 frame_tree_node_id = 4;
}

// Corresponds to `content::ShouldSwapBrowsingInstance`.
// Note that the enum values here are not equivalent to the content enum and
// must be converted explicitly. See `ShouldSwapBrowsingInstanceToProto`.
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;
  SHOULD_SWAP_BROWSING_INSTANCE_NO_INITIATOR_REQUESTED_NO_PROACTIVE_SWAP = 23;
}

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;
  // Number of NavigationStateKeepAlive references active in the
  // RenderProcessHost, recorded when Cleanup() was called.
  optional uint32 navigation_state_keepalive_count = 6;
}

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;
    IMPORTANCE_PERCEPTIBLE = 4;
  }
  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;

  enum SiteInstanceProcessAssignment {
    // No renderer process has been assigned to the SiteInstance yet.
    UNKNOWN = 0;

    // Reused some pre-existing process.
    REUSED_EXISTING_PROCESS = 1;

    // Used an existing spare process.
    USED_SPARE_PROCESS = 2;

    // No renderer could be reused, so a new one was created for the
    // SiteInstance.
    CREATED_NEW_PROCESS = 3;
  }
  optional SiteInstanceProcessAssignment process_assignment = 8;

  // 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;
}

// Describes the CrossOriginIsolated state of a page. See the definition of
// WebExposedIsolationInfo for more information.
message WebExposedIsolationInfo {
  optional bool is_isolated = 1;
  optional string origin = 2;
  optional bool is_isolated_application = 3;
}

// Contains the URL and some additional information necessary to pick a
// SiteInstance and process during a navigation. See the definition of UrlInfo
// for more information about individual fields.
message UrlInfo {
  optional string url = 1;
  optional string origin = 2;
  optional bool is_sandboxed = 3;
  optional bool is_pdf = 4;
  optional bool is_coop_isolation_requested = 5;
  optional int32 origin_isolation_request = 6;
  optional bool is_prefetch_with_cross_site_contamination = 7;
  optional WebExposedIsolationInfo web_exposed_isolation_info = 8;
  optional string storage_partition_config = 9;
}

// 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/40797026): 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;
    BROADCAST_CHANNEL_ON_MESSAGE = 59;
    WEBVIEW_SETTINGS_CHANGED = 60;
    WEBVIEW_JAVASCRIPT_OBJECT_CHANGED = 61;
    WEBVIEW_MESSAGE_LISTENER_INJECTED = 62;
    WEBVIEW_SAFE_BROWSING_ALLOWLIST_CHANGED = 63;
    WEBVIEW_DOCUMENT_START_JAVASCRIPT_CHANGED = 64;
    CACHE_CONTROL_NO_STORE_DEVICE_BOUND_SESSION_TERMINATED = 65;
    CACHE_LIMIT_PRUNED_ON_MODERATE_MEMORY_PRESSURE = 66;
    CACHE_LIMIT_PRUNED_ON_CRITICAL_MEMORY_PRESSURE = 67;
    SHARED_WORKER_MESSAGE = 68;
    SHARED_WORKER_WITH_NO_ACTIVE_CLIENT = 69;
    WEB_LOCKS_CONTENTION = 70;
    FORWARD_CACHE_DISABLED = 71;
  }

  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/40583778): 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_USER_VISIBLE = 84;
    TASK_TYPE_CLIPBOARD = 85;
    TASK_TYPE_MACHINE_LEARNING = 86;
    TASK_TYPE_MAIN_THREAD_TASK_QUEUE_V8_BEST_EFFORT = 87;
    TASK_TYPE_INTERNAL_AUTOFILL = 88;
    TASK_TYPE_BACK_FORWARD_CACHE_POSTED_MESSAGE = 89;
  }

  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;
    INERTIAL_GESTURE_SCROLL_END = 28;
  }

  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;
  // viz::BeginFrameArgs.trace_id of the frame (before surface aggregation) in
  // which the input was first presented. See also
  // ChromeGraphicsPipeline.surface_frame_trace_id.
  optional int64 surface_frame_trace_id = 7;
  // gfx::PresentationFeedback.display_trace_id of the frame (after surface
  // aggregation) in which the input was first presented. See also
  // ChromeGraphicsPipeline.display_trace_id.
  optional int64 display_trace_id = 8;

  // Deprecated in favor of `ChromeTrackEvent.scroll_jank_v4.is_janky`. Not
  // filled anymore in newer versions of Chrome.
  optional bool is_janky_scrolled_frame_v3 = 9 [deprecated = true];

  // Result of the Scroll Jank V4 Metric for a frame that contains one or more
  // scroll updates. See
  // cc::ScrollUpdateEventMetrics::ScrollJankV4MetricResults,
  // https://docs.google.com/document/d/1AaBvTIf8i-c-WTKkjaL4vyhQMkSdynxo3XEiwpofdeA
  // and the Event.ScrollJank.DelayedFramesPercentage4.FixedWindow histogram's
  // documentation for more information.
  //
  message ScrollJankV4Result {
    // Next ID: 15

    // This field is a new version of `EventLatency.is_janky_scrolled_frame`
    // based on the Event.ScrollJank.DelayedFramesPercentage4.FixedWindow
    // metric. This field aims to address the old field's shortcomings and
    // eventually replace it. True if and only if at least one value in
    // `missed_vsyncs_per_jank_reason` is greater than zero.
    optional bool is_janky = 1;

    // Reason why Chrome's scroll jank v4 metric marked a scroll update as
    // janky. A single scroll update can be janky for more than one reason.
    enum JankReason {
      JANK_REASON_UNSPECIFIED = 0;

      // Chrome's input→frame delivery slowed down to the point that it missed
      // one or more VSyncs.
      MISSED_VSYNC_DUE_TO_DECELERATING_INPUT_FRAME_DELIVERY = 1;

      // Chrome missed one or more VSyncs in the middle of a fast regular
      // scroll.
      MISSED_VSYNC_DURING_FAST_SCROLL = 2;

      // Chrome missed one or more VSyncs during the transition from a fast
      // regular scroll to a fling.
      MISSED_VSYNC_AT_START_OF_FLING = 3;

      // Chrome missed one or more VSyncs in the middle of a fling.
      MISSED_VSYNC_DURING_FLING = 4;
    }

    // Number of VSyncs that that Chrome missed before presenting the scroll
    // update for each reason. Essentially a map<JankReason, int32>.
    message MissedVsyncsForJankReason {
      optional JankReason jank_reason = 1;
      optional int32 missed_vsyncs = 2;
    }
    repeated MissedVsyncsForJankReason missed_vsyncs_per_jank_reason = 2;

    // Deprecated in favor of `updates.real.abs_total_raw_delta_pixels`.
    //
    // The absolute total raw (unpredicted) delta of all scroll updates included
    // in this frame (in pixels).
    optional float abs_total_raw_delta_pixels = 3;

    // Deprecated in favor of `updates.real.max_abs_inertial_raw_delta_pixels`.
    //
    // The maximum absolute raw (unpredicted) delta out of all inertial (fling)
    // scroll updates included in this frame (in pixels). Zero if there were no
    // inertial scroll updates in this frame.
    optional float max_abs_inertial_raw_delta_pixels = 4;

    // How many VSyncs were between (A) this frame and (B) the previous frame.
    // If this value is greater than one, then Chrome potentially missed one or
    // more VSyncs (i.e. might have been able to present this scroll update
    // earlier). Empty if this frame is the first frame in a scroll.
    optional int32 vsyncs_since_previous_frame = 5;

    // The running delivery cut-off based on frames preceding this frame. Empty
    // if ANY of the following holds:
    //
    //   * This frame is the first frame in a scroll.
    //   * All frames since the beginning of the scroll up to and including the
    //     previous frame have been non-damaging.
    //   * The most recent janky frame was non-damaging and all frames since
    //     then up to and including the previous frame have been non-damaging.
    optional int64 running_delivery_cutoff_us = 6;

    // The running delivery cut-off adjusted for this frame. Empty if ANY of the
    // following holds:
    //
    //   * This frame is the first frame in a scroll.
    //   * This frame is non-damaging.
    //   * All frames since the beginning of the scroll up to and including the
    //     previous frame have been non-damaging.
    //   * The most recent janky frame was non-damaging and all frames since
    //     then up to and including the previous frame have been non-damaging.
    //   * `vsyncs_since_previous_frame` is equal to one.
    optional int64 adjusted_delivery_cutoff_us = 7;

    // The delivery cut-off of this frame. Empty if this frame is non-damaging.
    optional int64 current_delivery_cutoff_us = 8;

    // Deprecated in favor of `damage_type`.
    //
    // Whether this frame is damaging. This frame is non-damaging if the
    // following conditions are BOTH true:
    //
    //   1. All scroll updates in this frame are non-damaging. A scroll update
    //      is non-damaging if it didn't cause a frame update and/or didn't
    //      change the scroll offset.
    //
    //   2. All frames between (both ends exclusive):
    //        a. the last frame presented by Chrome before this frame and
    //        b. this frame
    //      are non-damaging.
    optional bool is_damaging_frame = 9;

    // Information about the scroll updates that were included in this frame.
    message ScrollUpdates {
      // Real scroll updates which originated from hardware/OS.
      message Real {
        // Trace IDs of the first real scroll update included in this frame. Can
        // be joined with EventLatency.event_latency_id.
        optional int64 first_event_latency_id = 1;

        // The absolute total raw (unpredicted) delta of all real scroll updates
        // included in this frame (in pixels).
        optional float abs_total_raw_delta_pixels = 2;

        // The maximum absolute raw (unpredicted) delta out of all inertial
        // (fling) scroll updates included in this frame (in pixels). Empty if
        // there were no inertial scroll updates in this frame.
        optional float max_abs_inertial_raw_delta_pixels = 3;
      }
      optional Real real = 1;

      // Synthetic scroll updates which were predicted by Chrome
      message Synthetic {
        // Trace IDs of the first synthetic scroll update included in this
        // frame. Can be joined with EventLatency.event_latency_id.
        optional int64 first_event_latency_id = 1;

        // True if the synthetic scroll update was generated from an inertial
        // input (e.g. a fling).
        optional bool has_inertial_input = 2;
      }
      optional Synthetic synthetic = 2;

      // Type of the first scroll update in this frame based on:
      //
      //   * For real scroll updates, we consider their actual input generation
      //     timestamp.
      //   * For synthetic scroll updates, we extrapolate their input generation
      //     timestamp based on the input generation → begin frame duration of
      //     the most recent real scroll update UNLESS ANY of the following
      //     holds (in which case we DON'T extrapolate input generation
      //     timestamps for synthetic scroll updates in this frame):
      //       * This frame is janky.
      //       * All frames since the beginning of the scroll up to and
      //         including the previous frame have contained only synthetic
      //         scroll updates.
      //       * The most recent janky frame contained only synthetic scroll
      //         updates and all frames since then up to and including the
      //         previous frame have contained only synthetic scroll updates.
      //
      // If, based on the above rules, the scroll update with the earliest input
      // generation timestamp is a real scroll update, then this frame's type is
      // `REAL`. If the scroll update with the earliest input generation
      // timestamp is a synthetic scroll update, then this frame's type is
      // `SYNTHETIC_WITH_EXTRAPOLATED_INPUT_GENERATION_TIMESTAMP`.
      //
      // If this frame contained only synthetic scroll updates but it wasn't
      // possible to extrapolate their input generation timestamp (for any of
      // the reasons listed above), then this frame's type is
      // `SYNTHETIC_WITHOUT_EXTRAPOLATED_INPUT_GENERATION_TIMESTAMP`.
      //
      // See `cc::ScrollJankV4FrameStage::ScrollUpdates` and
      // `cc::ScrollJankV4Result::first_input_generation`.
      enum FirstScrollUpdateType {
        UNKNOWN = 0;
        REAL = 1;
        SYNTHETIC_WITH_EXTRAPOLATED_INPUT_GENERATION_TIMESTAMP = 2;
        SYNTHETIC_WITHOUT_EXTRAPOLATED_INPUT_GENERATION_TIMESTAMP = 3;
      }
      optional FirstScrollUpdateType first_scroll_update_type = 3;

      // The timestamp of when the scroll begin event which started the scroll
      // containing this frame's scroll updates arrived in the renderer
      // compositor.
      //
      // This value effectively serves as the ID of the scroll that this frame
      // belongs to. Can be joined with `EventLatency.scroll_begin_arrival_us`.
      optional int64 scroll_begin_arrival_us = 4;
    }
    optional ScrollUpdates updates = 10;

    // Type of scroll damage in this frame. A frame F is non-damaging if the
    // following conditions are BOTH true:
    //
    //   1. All scroll updates in F are non-damaging. A scroll update
    //      is non-damaging if it didn't cause a frame update (i.e.
    //      `EventMetrics::caused_frame_update()` is false) and/or didn't change
    //      the scroll offset (i.e. `ScrollEventMetrics::did_scroll()` is
    //      false).
    //
    //   2. All frames between (both ends exclusive):
    //        a. the last frame presented by Chrome before F and
    //        b. F
    //      are non-damaging.
    //
    // A non-damaging frame has its presentation timestamp extrapolated based on
    // the begin frame → presentation duration of the most recent damaging frame
    // UNLESS ANY of the following holds:
    //
    //   * This frame is janky and non-damaging.
    //   * All frames since the beginning of the scroll up to and including this
    //     frame have been non-damaging.
    //   * The most recent janky frame was non-damaging and all frames since
    //     then up to and including the this frame have been non-damaging.
    //
    // See `cc::ScrollJankV4Frame::ScrollDamage` and
    // `cc::ScrollJankV4Result::presentation`.
    //
    // Note: The `updates.first_scroll_update_type` and `damage_type` fields are
    // orthogonal. The former depends on whether the frame is synthetic (only
    // contains synthetic scroll updates). The latter depends on whether the
    // frame is damaging. For example:
    //
    //   * If a frame is synthetic and damaging, it will[1] have an extrapolated
    //     input generation timestamp.
    //   * If a frame is real and non-damaging, it will[1] have an extrapolated
    //     presentation timestamp.
    //   * If a frame is both synthetic and damaging, it will[1] have both
    //     timestamps extrapolated.
    //
    // [1] As long as there's Chrome past performance to extrapolate based on.
    enum DamageType {
      UNKNOWN = 0;
      DAMAGING = 1;
      NON_DAMAGING_WITH_EXTRAPOLATED_PRESENTATION_TIMESTAMP = 2;
      NON_DAMAGING_WITHOUT_EXTRAPOLATED_PRESENTATION_TIMESTAMP = 3;
    }
    optional DamageType damage_type = 11;

    // The VSync interval that this frame was produced for according to the
    // BeginFrameArgs.
    optional int64 vsync_interval_us = 12;

    // The ID of this frame's result. Used to associate sub-slices (e.g.
    // "Presentation") with the main slice ("ScrollJankV4").
    optional int64 result_id = 13;

    // The state of `cc::ScrollJankV4FrameStageCalculator` before processing a
    // frame.
    message FrameStageCalculation {
      // The timestamp of when the scroll begin event which started the scroll
      // that the calculator most recently encountered. Effectively the ID of
      // the current / most recent scroll. Can be joined with
      // `EventLatency.scroll_begin_arrival_us`.
      optional int64 current_scroll_begin_arrival_us = 1;

      // What the calculator has seen for the current / most recent scroll.
      // LINT.IfChange(ScrollJankV4FrameStageCalculationHasSeen)
      enum HasSeen {
        UNKNOWN = 0;
        // The calculator hasn't seen any GSUs or GSE for the current scroll
        // yet.
        NO_UPDATES = 1;
        // The calculator has seen one or more GSUs for the current scroll (but
        // no GSE).
        ONE_OR_MORE_UPDATES = 2;
        // The calculator has seen a GSE for the most recent scroll.
        END = 3;
      }
      // LINT.ThenChange(//cc/metrics/scroll_jank_v4_frame_stage_calculator.cc:HasSeen)
      optional HasSeen has_seen_in_current_scroll = 2;
    }
    optional FrameStageCalculation frame_stage_calculation = 14;
  }

  // Deprecated in favor of top-level `ChromeTrackEvent.scroll_jank_v4`.
  optional ScrollJankV4Result scroll_jank_v4 = 10 [deprecated = true];

  // The timestamp of when the scroll begin event which started the scroll
  // containing this scroll event arrived in the renderer compositor.
  //
  // This value effectively serves as the ID of the scroll that this event
  // belongs to. For example, if the renderer compositor receives the sequence
  // of events GSB1, GSU1a, GSU1b, GSE1, GSB2, GSU2a, GSU2b, GSE, then:
  //
  //   * `GSB1.scroll_begin_arrival_us`, `GSU1a.scroll_begin_arrival_us`,
  //     `GSU1b.scroll_begin_arrival_us` and `GSE1.scroll_begin_arrival_us` will
  //     all be equal to some value T1.
  //   * `GSB2.scroll_begin_arrival_us`, `GSU2a.scroll_begin_arrival_us`,
  //     `GSU2b.scroll_begin_arrival_us` and `GSE2.scroll_begin_arrival_us` will
  //     all be equal to some value T2 such that T2 > T1.
  //
  // See `EventMetrics::scroll_begin_arrival_timestamp()` and
  // `cc::ScrollSequenceTracker` for more details.
  optional int64 scroll_begin_arrival_us = 11;
}

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;

    // Priorities used in Network Service.
    MEDIUM_PRIORITY = 12;
    LOWEST_PRIORITY = 13;
    IDLE_PRIORITY = 14;
    THROTTLED_PRIORITY = 15;
  }

  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 [deprecated = true];
    IO_USER_BLOCKING_DEFERRABLE_TQ = 53 [deprecated = true];

    UI_BEFORE_UNLOAD_BROWSER_RESPONSE_TQ = 54;
    IO_BEFORE_UNLOAD_BROWSER_RESPONSE_TQ = 55;

    V8_USER_VISIBLE_TQ = 56;
    V8_BEST_EFFORT_TQ = 57;

    // TODO(crbug.com/450428442): Deprecate these TQ names when
    // NetworkServicePerPriorityTaskQueues is enabled by default.
    NETWORK_SERVICE_THREAD_HIGH_TQ = 58;
    NETWORK_SERVICE_THREAD_DEFAULT_TQ = 59;

    UI_STARTUP_TQ = 60;
    IO_STARTUP_TQ = 61;

    NETWORK_SERVICE_THREAD_THROTTLED_TQ = 62;
    NETWORK_SERVICE_THREAD_IDLE_TQ = 63;
    NETWORK_SERVICE_THREAD_LOWEST_TQ = 64;
    NETWORK_SERVICE_THREAD_LOW_TQ = 65;
    NETWORK_SERVICE_THREAD_MEDIUM_TQ = 66;
    NETWORK_SERVICE_THREAD_HIGHEST_TQ = 67;
  }

  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;
    BLOCKED_TABLET_BUTTON_ANIMATION_IN_PROGRESS = 14;
    BLOCKED_LAYOUT_REQUESTED = 15;
  }
  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;
}

// 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;

  // Data for overscrolls.
  // Whether any of the scroll delta was unused.
  optional bool did_overscroll_root = 15;
  // The amount of the scroll delta that was not used for scrolling.
  optional float unused_delta_x = 16;
  optional float unused_delta_y = 17;
}

// 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 {
  // Next id: 26
  enum StepName {
    STEP_UNKNOWN = 0;
    STEP_DID_NOT_PRODUCE_FRAME = 1;
    STEP_DID_NOT_PRODUCE_COMPOSITOR_FRAME = 22;
    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 [deprecated = true];
    STEP_SUBMIT_COMPOSITOR_FRAME = 9;
    STEP_DRAW_AND_SWAP = 21;
    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;

    // While the above steps are part of the cc/viz/gpu pipeline, the STEP_EXO*
    // and STEP_BACKEND* are somehow special.
    //
    // STEP_BACKEND* is platform independent and it can be used to trace any of
    // the backends. For example, it perfectly fits in ozone/drm, ozone/wayland
    // or x11 and can be set before and after buffer swap or overlay submission
    // that helps to understand the flow better.
    //
    // The STEP_EXO* is used only by EXO (see below). It relies on a trace id
    // from a Wayland client, which can use the "augmented_surface" protocol's
    // "augmented_surface.set_frame_trace_id" to pass that value. As a result,
    // any of the Wayland clients that use EXO will be able to have a nice trace
    // connection and see their buffer submissions' flows.

    // Frame submission stages when Exo (Wayland server implementation in Ash
    // browser process) is involved. Wayland clients (such as ARC++) submit
    // visual contents via Wayland surface commits, with which Exo constructs
    // compositor frames and forwards to Ash Viz.
    STEP_EXO_CONSTRUCT_COMPOSITOR_FRAME = 15;
    STEP_EXO_SUBMIT_COMPOSITOR_FRAME = 16;
    STEP_EXO_DISCARD_COMPOSITOR_FRAME = 17;

    // Frame submission stages in backends that viz uses to submit frames to
    // the gpu or to the system compositor. See the explanation above how these
    // stages can be used.
    STEP_BACKEND_SEND_BUFFER_SWAP = 18;
    STEP_BACKEND_SEND_BUFFER_POST_SUBMIT = 19;
    STEP_BACKEND_FINISH_BUFFER_SWAP = 20;

    // Send viz.mojom.CompositorFrameSinkClient::OnBeginFrame Mojo message from
    // Viz to a renderer's compositor.
    STEP_SEND_ON_BEGIN_FRAME_MOJO_MESSAGE = 23;

    // Send viz.mojom.BeginFrameObserver::OnStandaloneBeginFrame Mojo message
    // from Viz to the browser main thread (for flings).
    STEP_SEND_ON_STANDALONE_BEGIN_FRAME_MOJO_MESSAGE = 24;

    // Send viz.mojom.CompositorFrameSink::SubmitCompositorFrame Mojo message
    // from a renderer's compositor to Viz.
    STEP_SEND_SUBMIT_COMPOSITOR_FRAME_MOJO_MESSAGE = 25;
  }
  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;

  // Id used to link `ChromeGraphicsPipeline`s corresponding to work done by a
  // Viz client to produce a frame. This corresponds to
  // `viz::BeginFrameAck.trace_id`. Covers steps:
  // * STEP_ISSUE_BEGIN_FRAME
  // * STEP_RECEIVE_BEGIN_FRAME
  // * STEP_GENERATE_RENDER_PASS
  // * STEP_GENERATE_COMPOSITOR_FRAME
  // * STEP_SUBMIT_COMPOSITOR_FRAME
  // * STEP_RECEIVE_COMPOSITOR_FRAME
  // * STEP_RECEIVE_BEGIN_FRAME_DISCARD
  // * STEP_DID_NOT_PRODUCE_FRAME
  // * STEP_DID_NOT_PRODUCE_COMPOSITOR_FRAME
  optional int64 surface_frame_trace_id = 10;

  // Id used to link `ChromeGraphicsPipeline`s corresponding to work done
  // on creating and presenting one frame *after* surface aggregation. Covers
  // steps:
  // * STEP_DRAW_AND_SWAP
  // * STEP_SURFACE_AGGREGATION
  // * STEP_SEND_BUFFER_SWAP
  // * STEP_BUFFER_SWAP_POST_SUBMIT
  // * STEP_FINISH_BUFFER_SWAP
  // * STEP_SWAP_BUFFERS_ACK
  optional int64 display_trace_id = 3;

  // `viz::BeginFrameAck.trace_id`s for frames aggregated at this step.
  // Used with `STEP_SURFACE_AGGREGATION` only. This can be "joined" with
  // `surface_frame_trace_id`.
  repeated int64 aggregated_surface_frame_trace_ids = 8;

  optional LocalSurfaceId local_surface_id = 4;
  optional int64 frame_sequence = 5;
  optional FrameSkippedReason frame_skipped_reason = 6;

  // Optional variable that can be set together with STEP_BACKEND*.
  optional int64 backend_frame_id = 7;

  // List of LatencyInfo.trace_ids associated with this frame, which
  // should allow us to match input to frame production.
  repeated int64 latency_ids = 9;

  reserved 11;
  reserved "possible_deadlines";
};

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 {
    UNINITIALIZED = -1;
    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;
    AUTH_TAB = 19;
  }

  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 [deprecated = true];
  }

  optional Type type = 1;
  reserved 2;
  reserved "total_duration_ms";
}

// Deprecated in favor of the Perfetto Scroll Jank plugin which has a more
// in-depth track. See `org.chromium.ChromeScrollJank/scroll_track.ts`
message ScrollMetrics {
  optional int64 frame_count = 1;
  optional int64 vsync_count = 2;
  optional int64 missed_vsync_max = 3;
  optional int64 missed_vsync_sum = 4;
  optional int64 delayed_frame_count = 5;
  optional int64 predictor_janky_frame_count = 6;
}

// The EventForwarder is a subsystem in android that forwards events from Java
// code to Chromium's native implementation. In this case we register how many
// events there was, what time this event occurred and the current x & y on the
// device screen (pixels).
//
// All data comes from MotionEvent getters so read these for more context:
// https://developer.android.com/reference/android/view/MotionEvent
// Next id: 11
message EventForwarder {
  // The events getHistorySize().
  optional int32 history_size = 1;
  // The time of the oldest event (getHistoricalEventTimeNanos(0)).
  optional int64 oldest_time_ns = 2;
  // The time of the newest event (getEventTimeNanos(0)).
  optional int64 latest_time_ns = 5;
  // The down time of event gotten from `MotionEvent.GetDownTime` or
  // `AMotionEvent_getDownTime`.
  optional int64 down_time_ns = 8;
  // The X coordinate of the event as reported by MotionEvent.getX().
  optional float x_pixel = 3;
  // The Y coordinate of the event as reported by MotionEvent.getY().
  optional float y_pixel = 4;
  // Determine if the previous forwarded event changed x coordinate.
  optional bool has_x_movement = 6;
  // Determine if the previous forwarded event changed y coordinate.
  optional bool has_y_movement = 7;

  // The enum comes from Android NDK header: `android/input.h`.
  enum AMotionEventAction {
    AMOTION_EVENT_ACTION_DOWN = 0;
    AMOTION_EVENT_ACTION_UP = 1;
    AMOTION_EVENT_ACTION_MOVE = 2;
    AMOTION_EVENT_ACTION_CANCEL = 3;
    AMOTION_EVENT_ACTION_OUTSIDE = 4;
    AMOTION_EVENT_ACTION_POINTER_DOWN = 5;
    AMOTION_EVENT_ACTION_POINTER_UP = 6;
    AMOTION_EVENT_ACTION_HOVER_MOVE = 7;
    AMOTION_EVENT_ACTION_SCROLL = 8;
    AMOTION_EVENT_ACTION_HOVER_ENTER = 9;
    AMOTION_EVENT_ACTION_HOVER_EXIT = 10;
    AMOTION_EVENT_ACTION_BUTTON_PRESS = 11;
    AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12;
  }
  optional AMotionEventAction action = 9;

  // Whether the event came from the system.
  optional bool verified_event = 10;
}

// TouchDispositionGestureFilter is a class on android that detects and forwards
// along gesture events based on touch acks and other information.
message TouchDispositionGestureFilter {
  // The number of gesture's inside of a GestureEventDataPacket.
  optional int32 gesture_count = 1;
}

message ViewClassName {
  // The name associated with a View class in browser UI. The class name is set
  // by the view class itself through metadata macros and contains no data that
  // can be modified by a user.
  optional string name = 1;
}

// Describes Chrome's Compositor scheduler's current state and associated
// variables.
//
// These protos and enums were adapted from the corresponding original JSON
// trace event for the scheduler state. In contrast to the JSON, we use strongly
// typed enum values instead of strings for many fields, and
// microsecond-granularity timestamps.
//
// The original format was generated in JSON by the code at
// https://cs.chromium.org/chromium/src/cc/scheduler/scheduler.cc?l=870&rcl=5e15eabc9c0eec8daf94fdf78e93f13b6e3b63dd
//
// And is now generated as protozero:
// https://cs.chromium.org/chromium/src/cc/scheduler/scheduler.cc?q=Scheduler::AsPro
//
// All non-delta-timestamps are absolute CLOCK_MONOTONIC timestamps.

// Next id: 16
enum ChromeCompositorSchedulerActionV2 {
  CC_SCHEDULER_ACTION_V2_UNSPECIFIED = 0;
  CC_SCHEDULER_ACTION_V2_NONE = 1;
  CC_SCHEDULER_ACTION_V2_SEND_BEGIN_MAIN_FRAME = 2;
  CC_SCHEDULER_ACTION_V2_COMMIT = 3;
  CC_SCHEDULER_ACTION_V2_POST_COMMIT = 14;
  CC_SCHEDULER_ACTION_V2_ACTIVATE_SYNC_TREE = 4;
  CC_SCHEDULER_ACTION_V2_DRAW_IF_POSSIBLE = 5;
  CC_SCHEDULER_ACTION_V2_DRAW_FORCED = 6;
  CC_SCHEDULER_ACTION_V2_DRAW_ABORT = 7;
  CC_SCHEDULER_ACTION_V2_UPDATE_DISPLAY_TREE = 15;
  CC_SCHEDULER_ACTION_V2_BEGIN_LAYER_TREE_FRAME_SINK_CREATION = 8;
  CC_SCHEDULER_ACTION_V2_PREPARE_TILES = 9;
  CC_SCHEDULER_ACTION_V2_INVALIDATE_LAYER_TREE_FRAME_SINK = 10;
  CC_SCHEDULER_ACTION_V2_PERFORM_IMPL_SIDE_INVALIDATION = 11;
  CC_SCHEDULER_ACTION_V2_NOTIFY_BEGIN_MAIN_FRAME_NOT_EXPECTED_UNTIL = 12;
  CC_SCHEDULER_ACTION_V2_NOTIFY_BEGIN_MAIN_FRAME_NOT_EXPECTED_SOON = 13;
}

// Next id: 18
message ChromeCompositorSchedulerStateV2 {
  enum BeginImplFrameDeadlineMode {
    DEADLINE_MODE_UNSPECIFIED = 0;
    DEADLINE_MODE_NONE = 1;
    DEADLINE_MODE_IMMEDIATE = 2;
    DEADLINE_MODE_REGULAR = 3;
    DEADLINE_MODE_LATE = 4;
    DEADLINE_MODE_BLOCKED = 5;
    DEADLINE_MODE_WAIT_FOR_SCROLL = 6;
  }
  optional ChromeCompositorStateMachineV2 state_machine = 1;
  optional bool observing_begin_frame_source = 2;
  optional bool begin_impl_frame_deadline_task = 3;
  optional bool pending_begin_frame_task = 4;
  optional bool skipped_last_frame_missed_exceeded_deadline = 5;
  optional ChromeCompositorSchedulerActionV2 inside_action = 7;
  optional BeginImplFrameDeadlineMode deadline_mode = 8;
  optional int64 deadline_us = 9;
  optional int64 deadline_scheduled_at_us = 10;
  optional int64 now_us = 11;
  optional int64 now_to_deadline_delta_us = 12;
  optional int64 now_to_deadline_scheduled_at_delta_us = 13;
  optional BeginImplFrameArgsV2 begin_impl_frame_args = 14;
  optional BeginFrameObserverStateV2 begin_frame_observer_state = 15;
  optional BeginFrameSourceStateV2 begin_frame_source_state = 16;
  optional CompositorTimingHistoryV2 compositor_timing_history = 17;

  reserved 6;
}

// Describes the current values stored in the Chrome Compositor state machine.
// Next id: 3
message ChromeCompositorStateMachineV2 {
  // Next id: 6
  message MajorStateV2 {
    enum BeginImplFrameState {
      BEGIN_IMPL_FRAME_UNSPECIFIED = 0;
      BEGIN_IMPL_FRAME_IDLE = 1;
      BEGIN_IMPL_FRAME_INSIDE_BEGIN_FRAME = 2;
      BEGIN_IMPL_FRAME_INSIDE_DEADLINE = 3;
    }
    enum BeginMainFrameState {
      BEGIN_MAIN_FRAME_UNSPECIFIED = 0;
      BEGIN_MAIN_FRAME_IDLE = 1;
      BEGIN_MAIN_FRAME_SENT = 2;
      BEGIN_MAIN_FRAME_READY_TO_COMMIT = 3;
    }
    enum LayerTreeFrameSinkState {
      LAYER_TREE_FRAME_UNSPECIFIED = 0;
      LAYER_TREE_FRAME_NONE = 1;
      LAYER_TREE_FRAME_ACTIVE = 2;
      LAYER_TREE_FRAME_CREATING = 3;
      LAYER_TREE_FRAME_WAITING_FOR_FIRST_COMMIT = 4;
      LAYER_TREE_FRAME_WAITING_FOR_FIRST_ACTIVATION = 5;
    }
    enum ForcedRedrawOnTimeoutState {
      FORCED_REDRAW_UNSPECIFIED = 0;
      FORCED_REDRAW_IDLE = 1;
      FORCED_REDRAW_WAITING_FOR_COMMIT = 2;
      FORCED_REDRAW_WAITING_FOR_ACTIVATION = 3;
      FORCED_REDRAW_WAITING_FOR_DRAW = 4;
    }
    optional ChromeCompositorSchedulerActionV2 next_action = 1;
    optional BeginImplFrameState begin_impl_frame_state = 2;
    optional BeginMainFrameState begin_main_frame_state = 3;
    optional LayerTreeFrameSinkState layer_tree_frame_sink_state = 4;
    optional ForcedRedrawOnTimeoutState forced_redraw_state = 5;
  }
  optional MajorStateV2 major_state = 1;

  // Next id: 48
  message MinorStateV2 {
    enum TreePriority {
      TREE_PRIORITY_UNSPECIFIED = 0;
      TREE_PRIORITY_SAME_PRIORITY_FOR_BOTH_TREES = 1;
      TREE_PRIORITY_SMOOTHNESS_TAKES_PRIORITY = 2;
      TREE_PRIORITY_NEW_CONTENT_TAKES_PRIORITY = 3;
    }
    enum ScrollHandlerState {
      SCROLL_HANDLER_UNSPECIFIED = 0;
      SCROLL_AFFECTS_SCROLL_HANDLER = 1;
      SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER = 2;
    }
    optional int32 commit_count = 1;
    optional int32 current_frame_number = 2;
    optional int32 last_frame_number_submit_performed = 3;
    optional int32 last_frame_number_draw_performed = 4;
    optional int32 last_frame_number_begin_main_frame_sent = 5;
    optional bool did_draw = 6;
    optional bool did_send_begin_main_frame_for_current_frame = 7;
    optional bool did_notify_begin_main_frame_not_expected_until = 8;
    optional bool did_notify_begin_main_frame_not_expected_soon = 9;
    optional bool wants_begin_main_frame_not_expected = 10;
    optional bool did_commit_during_frame = 11;
    optional bool did_invalidate_layer_tree_frame_sink = 12;
    optional bool did_perform_impl_side_invalidaion = 13;
    optional bool did_prepare_tiles = 14;
    optional int32 consecutive_checkerboard_animations = 15;
    optional int32 pending_submit_frames = 16;
    optional int32 submit_frames_with_current_layer_tree_frame_sink = 17;
    optional bool needs_redraw = 18;
    optional bool needs_prepare_tiles = 19;
    optional bool needs_begin_main_frame = 20;
    optional bool needs_one_begin_impl_frame = 21;
    optional bool visible = 22;
    optional bool begin_frame_source_paused = 23;
    optional bool can_draw = 24;
    optional bool resourceless_draw = 25;
    optional bool has_pending_tree = 26;
    optional bool pending_tree_is_ready_for_activation = 27;
    optional bool active_tree_needs_first_draw = 28;
    optional bool active_tree_is_ready_to_draw = 29;
    optional bool did_create_and_initialize_first_layer_tree_frame_sink = 30;
    optional TreePriority tree_priority = 31;
    optional ScrollHandlerState scroll_handler_state = 32;
    optional bool critical_begin_main_frame_to_activate_is_fast = 33;
    optional bool main_thread_missed_last_deadline = 34;
    optional bool video_needs_begin_frames = 36;
    optional bool defer_begin_main_frame = 37;
    optional bool last_commit_had_no_updates = 38;
    optional bool did_draw_in_last_frame = 39;
    optional bool did_submit_in_last_frame = 40;
    optional bool needs_impl_side_invalidation = 41;
    optional bool current_pending_tree_is_impl_side = 42;
    optional bool previous_pending_tree_was_impl_side = 43;
    optional bool processing_animation_worklets_for_active_tree = 44;
    optional bool processing_animation_worklets_for_pending_tree = 45;
    optional bool processing_paint_worklets_for_pending_tree = 46;
    optional bool should_warm_up = 47;

    reserved 35;
  }
  optional MinorStateV2 minor_state = 2;
}

// Next id: 13
message BeginFrameArgsV2 {
  // JSON format has a "type" field that was always just "BeginFrameArgs" we
  // drop this in the proto representation, and instead make the JSON format
  // "subtype" field become the type field.
  enum BeginFrameArgsType {
    BEGIN_FRAME_ARGS_TYPE_UNSPECIFIED = 0;
    BEGIN_FRAME_ARGS_TYPE_INVALID = 1;
    BEGIN_FRAME_ARGS_TYPE_NORMAL = 2;
    BEGIN_FRAME_ARGS_TYPE_MISSED = 3;
  }
  optional BeginFrameArgsType type = 1;
  optional uint64 source_id = 2;
  optional uint64 sequence_number = 3;
  optional int64 frame_time_us = 4;
  optional int64 deadline_us = 5;
  optional int64 interval_delta_us = 6;
  optional bool on_critical_path = 7;
  optional bool animate_only = 8;
  oneof created_from {
    // The interned SourceLocation.
    uint64 source_location_iid = 9;
    // The SourceLocation that this args was created from.
    // TODO(nuskos): Eventually we will support interning inside of
    // TypedArgument TraceEvents and then we shouldn't need this SourceLocation
    // since we can emit it as part of the InternedData message. When we can
    // remove this |source_location|.
    SourceLocation source_location = 10;
  }
  optional int64 frames_throttled_since_last = 11;
  optional int64 unthrottled_interval_delta_us = 12;
}

// Next id: 7
message BeginImplFrameArgsV2 {
  optional int64 updated_at_us = 1;
  optional int64 finished_at_us = 2;
  enum State {
    BEGIN_FRAME_FINISHED = 0;
    BEGIN_FRAME_USING = 1;
  }
  optional State state = 3;
  oneof args {
    // Only set if |state| is BEGIN_FRAME_FINISHED.
    BeginFrameArgsV2 current_args = 4;
    // Only set if |state| is BEGIN_FRAME_USING.
    BeginFrameArgsV2 last_args = 5;
  }
  message TimestampsInUs {
    optional int64 interval_delta = 1;
    optional int64 now_to_deadline_delta = 2;
    optional int64 frame_time_to_now_delta = 3;
    optional int64 frame_time_to_deadline_delta = 4;
    optional int64 now = 5;
    optional int64 frame_time = 6;
    optional int64 deadline = 7;
  }
  optional TimestampsInUs timestamps_in_us = 6;
}

message BeginFrameObserverStateV2 {
  optional int64 dropped_begin_frame_args = 1;
  optional BeginFrameArgsV2 last_begin_frame_args = 2;
}

message BeginFrameSourceStateV2 {
  optional uint32 source_id = 1;
  optional bool paused = 2;
  optional uint32 num_observers = 3;
  optional BeginFrameArgsV2 last_begin_frame_args = 4;
}

message CompositorTimingHistoryV2 {
  optional int64 begin_main_frame_queue_critical_estimate_delta_us = 1;
  optional int64 begin_main_frame_queue_not_critical_estimate_delta_us = 2;
  optional int64 begin_main_frame_start_to_ready_to_commit_estimate_delta_us =
      3;
  optional int64 commit_to_ready_to_activate_estimate_delta_us = 4;
  optional int64 prepare_tiles_estimate_delta_us = 5;
  optional int64 activate_estimate_delta_us = 6;
  optional int64 draw_estimate_delta_us = 7;
}

message WebViewStartup {
  optional bool from_ui_thread = 1 [deprecated = true];
  // This enum must be kept in sync with WebViewChromiumAwInit.CallSite
  // LINT.IfChange(WebViewStartup)
  enum CallSite {
    GET_AW_TRACING_CONTROLLER = 0;
    GET_AW_PROXY_CONTROLLER = 1;
    // This entry should no longer be used. This was a catch all for all methods
    // in the WebView instance but we now have different callsites for each
    // method.
    WEBVIEW_INSTANCE = 2;
    // This entry should no longer be used. This was a catch all for all static
    // methods but we now have different callsites for each method.
    GET_STATICS = 3;
    GET_DEFAULT_GEOLOCATION_PERMISSIONS = 4;
    GET_DEFAULT_SERVICE_WORKER_CONTROLLER = 5;
    GET_WEB_ICON_DATABASE = 6;
    GET_DEFAULT_WEB_STORAGE = 7;
    GET_DEFAULT_WEBVIEW_DATABASE = 8;
    GET_TRACING_CONTROLLER = 9;
    ASYNC_WEBVIEW_STARTUP = 10;
    WEBVIEW_INSTANCE_OVERLAY_HORIZONTAL_SCROLLBAR = 11;
    WEBVIEW_INSTANCE_OVERLAY_VERTICAL_SCROLLBAR = 12;
    WEBVIEW_INSTANCE_GET_CERTIFICATE = 13;
    WEBVIEW_INSTANCE_GET_HTTP_AUTH_USERNAME_PASSWORD = 14;
    WEBVIEW_INSTANCE_SAVE_STATE = 15;
    WEBVIEW_INSTANCE_RESTORE_STATE = 16;
    WEBVIEW_INSTANCE_LOAD_URL = 17;
    WEBVIEW_INSTANCE_POST_URL = 18;
    WEBVIEW_INSTANCE_LOAD_DATA = 19;
    WEBVIEW_INSTANCE_LOAD_DATA_WITH_BASE_URL = 20;
    WEBVIEW_INSTANCE_EVALUATE_JAVASCRIPT = 21;
    WEBVIEW_INSTANCE_CAN_GO_BACK = 22;
    WEBVIEW_INSTANCE_CAN_GO_FORWARD = 23;
    WEBVIEW_INSTANCE_CAN_GO_BACK_OR_FORWARD = 24;
    WEBVIEW_INSTANCE_IS_PAUSED = 25;
    WEBVIEW_INSTANCE_COPY_BACK_FORWARD_LIST = 26;
    WEBVIEW_INSTANCE_SHOW_FIND_DIALOG = 27;
    WEBVIEW_INSTANCE_SET_WEBVIEW_CLIENT = 28;
    WEBVIEW_INSTANCE_SET_WEBCHROME_CLIENT = 29;
    WEBVIEW_INSTANCE_CREATE_WEBMESSAGE_CHANNEL = 30;
    WEBVIEW_INSTANCE_GET_ZOOM_CONTROLS = 31;
    WEBVIEW_INSTANCE_ZOOM_IN = 32;
    WEBVIEW_INSTANCE_ZOOM_OUT = 33;
    WEBVIEW_INSTANCE_ZOOM_BY = 34;
    WEBVIEW_INSTANCE_SET_RENDERER_PRIORITY_POLICY = 35;
    WEBVIEW_INSTANCE_GET_RENDERER_REQUESTED_PRIORITY = 36;
    WEBVIEW_INSTANCE_GET_RENDERER_PRIORITY_WAIVED_WHEN_NOT_VISIBLE = 37;
    WEBVIEW_INSTANCE_SET_TEXT_CLASSIFIER = 38;
    WEBVIEW_INSTANCE_GET_TEXT_CLASSIFIER = 39;
    WEBVIEW_INSTANCE_AUTOFILL = 40;
    WEBVIEW_INSTANCE_ON_PROVIDE_AUTOFILL_VIRTUAL_STRUCTURE = 41;
    WEBVIEW_INSTANCE_ON_PROVIDE_CONTENT_CAPTURE_STRUCTURE = 42;
    WEBVIEW_INSTANCE_SHOULD_DELAY_CHILD_PRESSED_STATE = 43;
    WEBVIEW_INSTANCE_GET_ACCESSIBILITY_NODE_PROVIDER = 44;
    WEBVIEW_INSTANCE_ON_PROVIDE_VIRTUAL_STRUCTURE = 45;
    WEBVIEW_INSTANCE_PERFORM_ACCESSIBILITY_ACTION = 46;
    WEBVIEW_INSTANCE_ON_DRAW = 47;
    WEBVIEW_INSTANCE_SET_LAYOUT_PARAMS = 48;
    WEBVIEW_INSTANCE_ON_DRAG_EVENT = 49;
    WEBVIEW_INSTANCE_ON_CREATE_INPUT_CONNECTION = 50;
    WEBVIEW_INSTANCE_ON_KEY_MULTIPLE = 51;
    WEBVIEW_INSTANCE_ON_KEY_DOWN = 52;
    WEBVIEW_INSTANCE_ON_KEY_UP = 53;
    WEBVIEW_INSTANCE_ON_ATTACHED_TO_WINDOW = 54;
    WEBVIEW_INSTANCE_DISPATCH_KEY_EVENT = 55;
    WEBVIEW_INSTANCE_ON_TOUCH_EVENT = 56;
    WEBVIEW_INSTANCE_ON_HOVER_EVENT = 57;
    WEBVIEW_INSTANCE_ON_GENERIC_MOTION_EVENT = 58;
    WEBVIEW_INSTANCE_REQUEST_FOCUS = 59;
    WEBVIEW_INSTANCE_ON_MEASURE = 60;
    WEBVIEW_INSTANCE_REQUEST_CHILD_RECTANGLE_ON_SCREEN = 61;
    WEBVIEW_INSTANCE_SET_BACKGROUND_COLOR = 62;
    WEBVIEW_INSTANCE_ON_START_TEMPORARY_DETACH = 63;
    WEBVIEW_INSTANCE_ON_FINISH_TEMPORARY_DETACH = 64;
    WEBVIEW_INSTANCE_ON_CHECK_IS_TEXT_EDITOR = 65;
    WEBVIEW_INSTANCE_ON_APPLY_WINDOW_INSETS = 66;
    WEBVIEW_INSTANCE_ON_RESOLVE_POINTER_ICON = 67;
    WEBVIEW_INSTANCE_COMPUTE_HORIZONTAL_SCROLL_RANGE = 68;
    WEBVIEW_INSTANCE_COMPUTE_HORIZONTAL_SCROLL_OFFSET = 69;
    WEBVIEW_INSTANCE_COMPUTE_VERTICAL_SCROLL_RANGE = 70;
    WEBVIEW_INSTANCE_COMPUTE_VERTICAL_SCROLL_OFFSET = 71;
    WEBVIEW_INSTANCE_COMPUTE_VERTICAL_SCROLL_EXTENT = 72;
    WEBVIEW_INSTANCE_COMPUTE_SCROLL = 73;
    WEBVIEW_INSTANCE_CREATE_PRINT_DOCUMENT_ADAPTER = 74;
    WEBVIEW_INSTANCE_EXTRACT_SMART_CLIP_DATA = 75;
    WEBVIEW_INSTANCE_SET_SMART_CLIP_RESULT_HANDLER = 76;
    WEBVIEW_INSTANCE_GET_RENDER_PROCESS = 77;
    WEBVIEW_INSTANCE_GET_WEBVIEW_RENDERER_CLIENT_ADAPTER = 78;
    WEBVIEW_INSTANCE_PAGE_UP = 79;
    WEBVIEW_INSTANCE_PAGE_DOWN = 80;
    WEBVIEW_INSTANCE_LOAD_URL_ADDITIONAL_HEADERS = 81;
    WEBVIEW_INSTANCE_INIT = 82;
    WEBVIEW_INSTANCE_CAPTURE_PICTURE = 83;
    WEBVIEW_INSTANCE_GET_SCALE = 84;
    WEBVIEW_INSTANCE_SET_INITIAL_SCALE = 85;
    WEBVIEW_INSTANCE_GET_HIT_TEST_RESULT = 86;
    WEBVIEW_INSTANCE_GET_URL = 87;
    WEBVIEW_INSTANCE_GET_ORIGINAL_URL = 88;
    WEBVIEW_INSTANCE_GET_TITLE = 89;
    WEBVIEW_INSTANCE_GET_FAVICON = 90;
    STATIC_FIND_ADDRESS = 91;
    STATIC_GET_DEFAULT_USER_AGENT = 92;
    STATIC_SET_WEB_CONTENTS_DEBUGGING_ENABLED = 93;
    STATIC_CLEAR_CLIENT_CERT_PREFERENCES = 94;
    STATIC_FREE_MEMORY_FOR_TESTS = 95;
    STATIC_ENABLE_SLOW_WHOLE_DOCUMENT_DRAW = 96;
    STATIC_PARSE_FILE_CHOOSER_RESULT = 97;
    STATIC_INIT_SAFE_BROWSING = 98;
    STATIC_SET_SAFE_BROWSING_ALLOWLIST = 99;
    STATIC_GET_SAFE_BROWSING_PRIVACY_POLICY_URL = 100;
    STATIC_IS_MULTI_PROCESS_ENABLED = 101;
    STATIC_GET_VARIATIONS_HEADER = 102;
    reserved 103, 104;
    reserved "STATIC_SET_DEFAULT_TRAFFIC_STATS_TAG", "STATIC_SET_DEFAULT_TRAFFIC_STATS_UID";
    STATIC_SET_RENDERER_LIBRARY_PREFETCH_MODE = 105;
    STATIC_GET_RENDERER_LIBRARY_PREFETCH_MODE = 106;
    GET_DEFAULT_COOKIE_MANAGER = 107;
    GET_PROFILE_STORE = 108;
    WEBVIEW_INSTANCE_GET_SETTINGS = 109;
    WEBVIEW_INSTANCE_GET_AW_CONTENTS = 110;
    // Remember to update WebViewStartupCallSite in enums.xml when adding new
    // values here.
  }
  // LINT.ThenChange(//android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumAwInit.java:CallSite)

  // LINT.IfChange(WebViewChromiumStartupMode)
  enum StartupMode {
    FULLY_SYNC = 0;
    FULLY_ASYNC = 1;
    PARTIAL_ASYNC_THEN_SYNC = 2;
    ASYNC_BUT_FULLY_SYNC = 3;
  }
  // LINT.ThenChange(//tools/metrics/histograms/metadata/android/enums.xml:WebViewChromiumStartupMode)

  optional CallSite start_call_site = 2;
  optional CallSite finish_call_site = 3;
  optional StartupMode startup_mode = 4;
}

message AnimationFrameTimingInfo {
  optional int64 blocking_duration_ms = 1;
  optional int64 duration_ms = 2;
  optional int64 num_scripts = 3;
  // Id for the BeginFrame, which triggered this animation frame.
  optional BeginFrameId begin_frame_id = 4;
}

message AnimationFrameScriptTimingInfo {
  optional int64 style_duration_ms = 1;
  optional int64 layout_duration_ms = 2;
  optional int64 pause_duration_ms = 3;
  optional string class_like_name = 4;
  optional string property_like_name = 5;
  optional string source_location_url = 6;
  optional string source_location_function_name = 7;
  optional int64 source_location_char_position = 8;
  enum InvokerType {
    UNDEFINED = 0;
    CLASSIC_SCRIPT = 1;
    MODULE_SCRIPT = 2;
    USER_CALLBACK = 3;
    EVENT_HANDLER = 4;
    PROMISE_RESOLVE = 5;
    PROMISE_REJECT = 6;
  }
  optional InvokerType invoker_type = 9;
  enum ThirdPartyTechnology {
    UNSPECIFIED = 0;
    NONE = 1;
    WORD_PRESS = 2;
    GOOGLE_ANALYTICS = 3;
    GOOGLE_FONT_API = 4;
    GOOGLE_TAG_MANAGER = 5;
    GOOGLE_MAPS = 6;
    META_PIXEL = 7;
    YOUTUBE = 8;
    ADOBE_ANALYTICS = 9;
    TIKTOK_PIXEL = 10;
    HOTJAR = 11;
    GOOGLE_ADSENSE = 12;
    GOOGLE_PUBLISHER_TAG = 13;
    GOOGLE_ADS_LIBRARIES = 14;
    FUNDING_CHOICES = 15;
    ELEMENTOR = 16;
    SLIDER_REVOLUTION = 17;
  }
  optional ThirdPartyTechnology third_party_technology = 10;
}

message BeginFrameId {
  optional uint64 source_id = 1;
  optional uint64 sequence_number = 2;
}

message MainFramePipeline {
  enum Step {
    UNKNOWN = 0;
    SEND_BEGIN_MAIN_FRAME = 1;
    BEGIN_MAIN_FRAME = 2;
    ABORTED_ON_MAIN = 3;
    COMMIT_ON_MAIN = 4;
    READY_TO_COMMIT_ON_IMPL = 5;
    COMMIT_ON_IMPL = 6;
    COMMIT_COMPLETE = 7;
    READY_TO_ACTIVATE = 8;
    ACTIVATE = 9;
    DRAW = 10;
    UPDATE_DISPLAY_TREE = 11;
  }

  // Id connecting the steps of the pipeline together.
  optional uint64 main_frame_id = 1;
  optional Step step = 2;

  // Id for the BeginFrame, which triggered this main frame.
  // Set for the SEND_BEGIN_MAIN_FRAME step.
  optional BeginFrameId begin_frame_id = 3;

  // If the step is ABORTED_ON_MAIN, this field will contain the reason.
  enum AbortedOnMainReason {
    ABORTED_MAIN_REASON_UNKNOWN = 0;
    NOT_VISIBLE = 1;
    DEFERRED_UPDATE = 2;
    DEFERRED_COMMIT_ABORTED = 3;
    NO_UPDATE = 4;
  }
  optional AbortedOnMainReason aborted_on_main_reason = 4;

  // Id of the last begin frame id issued by renderer compositor by the time
  // this main frame is drawn for the first time.
  // The difference between `begin_frame_id` and
  // `last_begin_frame_id_during_first_draw` can be used to reason about the
  // main frame latency. Set for the first DRAW step.
  optional BeginFrameId last_begin_frame_id_during_first_draw = 5;
}

message CurrentTask {
  // t1 - t0, where t1 is the start timestamp of this slice and t0 is the start
  // timestamp of the task containing this slice.
  optional uint64 event_offset_from_task_start_time_us = 1;

  // Timestamp in microseconds of the start of the task containing this slice.
  optional uint64 task_start_time_us = 2;

  // t1 - t0, where t1 is the start timestamp of this slice and t0 is the
  // timestamp of the time when the task containing this slice
  // was queued.
  optional uint64 task_queueing_time_us = 3;

  // Timestamp in microseconds of the time when the task containing
  // this slice was queued.
  optional uint64 task_queued_time_us = 4;
}

message ChromeLatencyInfo2 {
  optional int64 trace_id = 1;

  // NEXT ID: 16
  // All step are optional but the enum is ordered (not by number) below in the
  // order we expect them to appear if they are emitted in trace in a blocking
  // fashion.
  enum Step {
    STEP_UNSPECIFIED = 0;
    // Emitted on the browser main thread.
    STEP_SEND_INPUT_EVENT_UI = 3;
    // The browser main thread sends a
    // blink.mojom.WidgetInputHandler::DispatchEvent Mojo message to the
    // renderer's compositor.
    STEP_SEND_DISPATCH_EVENT_MOJO_MESSAGE = 15;
    // Happens on the renderer's compositor.
    STEP_HANDLE_INPUT_EVENT_IMPL = 5;
    STEP_RESAMPLE_SCROLL_EVENTS = 14;
    STEP_DID_HANDLE_INPUT_AND_OVERSCROLL = 8;
    // Occurs on the Renderer's main thread.
    STEP_HANDLE_INPUT_EVENT_MAIN = 4;
    STEP_MAIN_THREAD_SCROLL_UPDATE = 2;
    STEP_HANDLE_INPUT_EVENT_MAIN_COMMIT = 1;
    // Could be emitted on both the renderer's main OR compositor.
    STEP_HANDLED_INPUT_EVENT_MAIN_OR_IMPL = 9;
    // Optionally sometimes HANDLED_INPUT_EVENT_MAIN_OR_IMPL will proxy to the
    // renderer's compositor and this will be emitted.
    STEP_HANDLED_INPUT_EVENT_IMPL = 10;
    // Occurs on Browser Main.
    STEP_TOUCH_EVENT_HANDLED = 12;
    // Occurs on Browser Main.
    STEP_GESTURE_EVENT_HANDLED = 13;
    // Renderer's compositor.
    STEP_SWAP_BUFFERS = 6 [deprecated = true];
    // Happens on the VizCompositor in the GPU process.
    STEP_DRAW_AND_SWAP = 7 [deprecated = true];
    // Happens on the GPU main thread after the swap has completed.
    STEP_FINISHED_SWAP_BUFFERS = 11 [deprecated = true];
    // See above for NEXT ID, enum steps are not ordered by tag number.
  };

  optional Step step = 2;
  optional int32 frame_tree_node_id = 3;

  // This enum is a copy of LatencyComponentType enum in Chrome, located in
  // ui/latency/latency_info.h, modulo added UNKNOWN value per protobuf
  // practices.
  enum LatencyComponentType {
    COMPONENT_UNSPECIFIED = 0;
    COMPONENT_INPUT_EVENT_LATENCY_BEGIN_RWH = 1;
    COMPONENT_INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL = 2;
    COMPONENT_INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL = 3;
    COMPONENT_INPUT_EVENT_LATENCY_ORIGINAL = 4;
    COMPONENT_INPUT_EVENT_LATENCY_UI = 5;
    COMPONENT_INPUT_EVENT_LATENCY_RENDERER_MAIN = 6;
    COMPONENT_INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN = 7;
    COMPONENT_INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL = 8;
    COMPONENT_INPUT_EVENT_LATENCY_SCROLL_UPDATE_LAST_EVENT = 9;
    COMPONENT_INPUT_EVENT_LATENCY_ACK_RWH = 10;
    COMPONENT_INPUT_EVENT_LATENCY_RENDERER_SWAP = 11;
    COMPONENT_DISPLAY_COMPOSITOR_RECEIVED_FRAME = 12;
    COMPONENT_INPUT_EVENT_GPU_SWAP_BUFFER = 13;
    COMPONENT_INPUT_EVENT_LATENCY_FRAME_SWAP = 14;
  }

  message ComponentInfo {
    optional LatencyComponentType component_type = 1;

    // Microsecond timestamp in CLOCK_MONOTONIC domain
    optional uint64 time_us = 2;
  };

  repeated ComponentInfo component_info = 4;
  optional bool is_coalesced = 5;
  optional int64 gesture_scroll_id = 6;
  optional int64 touch_id = 7;

  // Must be kept in sync with blink::mojom::EventType.
  // All values are incremented by one for consistency with other proto enums.
  enum InputType {
    UNDEFINED_EVENT = 0;
    MOUSE_DOWN_EVENT = 1;
    MOUSE_UP_EVENT = 2;
    MOUSE_MOVE_EVENT = 3;
    MOUSE_ENTER_EVENT = 4;
    MOUSE_LEAVE_EVENT = 5;
    CONTEXT_MENU_EVENT = 6;

    MOUSE_WHEEL_EVENT = 7;

    RAW_KEY_DOWN_EVENT = 8;
    KEY_DOWN_EVENT = 9;
    KEY_UP_EVENT = 10;
    CHAR_EVENT = 11;

    GESTURE_SCROLL_BEGIN_EVENT = 12;
    GESTURE_SCROLL_END_EVENT = 13;
    GESTURE_SCROLL_UPDATE_EVENT = 14;
    GESTURE_FLING_START_EVENT = 15;
    GESTURE_FLING_CANCEL_EVENT = 16;
    GESTURE_PINCH_BEGIN_EVENT = 17;
    GESTURE_PINCH_END_EVENT = 18;
    GESTURE_PINCH_UPDATE_EVENT = 19;

    GESTURE_BEGIN_EVENT = 20;

    GESTURE_TAP_DOWN_EVENT = 21;
    GESTURE_SHOW_PRESS_EVENT = 22;
    GESTURE_TAP_EVENT = 23;
    GESTURE_TAP_CANCEL_EVENT = 24;
    GESTURE_SHORT_PRESS_EVENT = 25;
    GESTURE_LONG_PRESS_EVENT = 26;
    GESTURE_LONG_TAP_EVENT = 27;
    GESTURE_TWO_FINGER_TAP_EVENT = 28;
    GESTURE_TAP_UNCONFIRMED_EVENT = 29;

    GESTURE_DOUBLE_TAP_EVENT = 30;
    GESTURE_END_EVENT = 31;

    TOUCH_START_EVENT = 32;
    TOUCH_MOVE_EVENT = 33;
    TOUCH_END_EVENT = 34;
    TOUCH_CANCEL_EVENT = 35;
    TOUCH_SCROLL_STARTED_EVENT = 36;

    POINTER_DOWN_EVENT = 37;
    POINTER_UP_EVENT = 38;
    POINTER_MOVE_EVENT = 39;
    POINTER_RAW_UPDATE_EVENT = 40;
    POINTER_CANCEL_EVENT = 41;
    POINTER_CAUSED_UA_ACTION_EVENT = 42;
  }

  // The type of input corresponding to this `ChromeLatencyInfo`.
  optional InputType input_type = 8;

  // Intended to mirror `blink::mojom::InputEventResultState`.
  enum InputResultState {
    UNKNOWN = 0;
    CONSUMED = 1;
    NOT_CONSUMED = 2;
    NO_CONSUMER_EXISTS = 3;
    IGNORED = 4;
    SET_NON_BLOCKING = 5;
    SET_NON_BLOCKING_DUE_TO_FLING = 6;
  }

  // If applicable, the result of handling the input corresponding to this
  // `ChromeLatencyInfo`.
  optional InputResultState input_result_state = 9;

  // `trace_id` values corresponding to inputs that were coalesced/combined into
  // the input for this `ChromeLatencyInfo`.
  repeated int64 coalesced_trace_ids = 10;
}

message EventTiming {
  optional bool cancelable = 1;
  optional string frame = 2;
  optional uint32 interaction_id = 3;
  optional uint32 interaction_offset = 4;
  optional int64 node_id = 5;
  optional int64 key_code = 6;
  optional int32 pointer_id = 7;
  optional uint64 fallback_time_us = 8;
  enum EventType {
    UNDEFINED = 0;
    AUX_CLICK_EVENT = 1;
    CLICK_EVENT = 2;
    CONTEXT_MENU_EVENT = 3;
    DOUBLE_CLICK_EVENT = 4;
    MOUSE_DOWN_EVENT = 5;
    MOUSE_ENTER_EVENT = 6;
    MOUSE_LEAVE_EVENT = 7;
    MOUSE_OUT_EVENT = 9;
    MOUSE_OVER_EVENT = 10;
    MOUSE_UP_EVENT = 11;
    POINTER_OVER_EVENT = 12;
    POINTER_ENTER_EVENT = 13;
    POINTER_DOWN_EVENT = 14;
    POINTER_UP_EVENT = 15;
    POINTER_CANCEL_EVENT = 16;
    POINTER_OUT_EVENT = 17;
    POINTER_LEAVE_EVENT = 18;
    GOT_POINTER_CAPTURE_EVENT = 19;
    LOST_POINTER_CAPTURE_EVENT = 20;
    TOUCH_START_EVENT = 21;
    TOUCH_END_EVENT = 22;
    TOUCH_CANCEL_EVENT = 23;
    KEY_DOWN_EVENT = 24;
    KEY_PRESS_EVENT = 25;
    KEY_UP_EVENT = 26;
    BEFORE_INPUT_EVENT = 27;
    INPUT_EVENT = 28;
    COMPOSITION_START_EVENT = 29;
    COMPOSITION_UPDATE_EVENT = 30;
    COMPOSITION_END_EVENT = 31;
    DRAG_START_EVENT = 32;
    DRAG_END_EVENT = 33;
    DRAG_ENTER_EVENT = 34;
    DRAG_LEAVE_EVENT = 35;
    DRAG_OVER_EVENT = 36;
    DROP_EVENT = 37;
    NAVIGATE_EVENT = 38;
    POPSTATE_EVENT = 39;
    HASHCHANGE_EVENT = 40;
  }
  optional EventType type = 9;
}

// Frame information provided by Android's Choreographer.
// See
// https://developer.android.com/ndk/reference/group/choreographer#achoreographerframecallbackdata.
// Next ID: 5
message AndroidChoreographerFrameCallbackData {
  // The time in microseconds at which the frame started being rendered.
  // See
  // https://developer.android.com/ndk/reference/group/choreographer#achoreographerframecallbackdata_getframetimenanos.
  optional int64 frame_time_us = 1;

  message FrameTimeline {
    // The token used by the platform to identify the frame timeline.
    // See
    // https://developer.android.com/ndk/reference/group/choreographer#achoreographerframecallbackdata_getframetimelinevsyncid.
    optional int64 vsync_id = 1;

    // The difference in microseconds between:
    // (A) the time at which the frame needs to be ready by in order to be
    //     presented on time and
    // (B) the time at which the frame started being rendered (frame_time_us).
    // See
    // https://developer.android.com/ndk/reference/group/choreographer#achoreographerframecallbackdata_getframetimelinedeadlinenanos.
    optional int64 latch_delta_us = 2;

    // The difference in microseconds between:
    // (A) the time at which the frame is expected to be presented and
    // (B) the time at which the frame started being rendered (frame_time_us).
    // See
    // https://developer.android.com/ndk/reference/group/choreographer#achoreographerframecallbackdata_getframetimelineexpectedpresentationtimenanos.
    optional int64 present_delta_us = 3;
  }

  // Possible frame timelines.
  // See
  // https://developer.android.com/ndk/reference/group/choreographer#achoreographerframecallbackdata_getframetimelineslength.
  repeated FrameTimeline frame_timeline = 2;

  // The index (into frame_timeline) of the platform-preferred frame timeline.
  // See
  // https://developer.android.com/ndk/reference/group/choreographer#achoreographerframecallbackdata_getpreferredframetimelineindex.
  optional int64 preferred_frame_timeline_index = 3;

  // The chrome-preferred frame timeline.
  optional FrameTimeline chrome_preferred_frame_timeline = 4;
}

message ChromeFrameReporter2 {
  enum State {
    // The frame did not have any updates to present.
    STATE_NO_UPDATE_DESIRED = 0;

    // The frame presented all the desired updates (i.e. any updates requested
    // from both the compositor thread and main-threads were handled).
    STATE_PRESENTED_ALL = 1;

    // The frame was presented with some updates, but also missed some updates
    // (e.g. missed updates from the main-thread, but included updates from the
    // compositor thread).
    STATE_PRESENTED_PARTIAL = 2;

    // The frame was dropped, i.e. some updates were desired for the frame, but
    // was not presented.
    STATE_DROPPED = 3;
  };

  optional State state = 1;

  enum FrameDropReason {
    REASON_UNSPECIFIED = 0;

    // Frame was dropped by the display-compositor.
    // The display-compositor may drop a frame some times (e.g. the frame missed
    // the deadline, or was blocked on surface-sync, etc.)
    REASON_DISPLAY_COMPOSITOR = 1;

    // Frame was dropped because of the main-thread.
    // The main-thread may cause a frame to be dropped, e.g. if the main-thread
    // is running expensive javascript, or doing a lot of layout updates, etc.
    REASON_MAIN_THREAD = 2;

    // Frame was dropped by the client compositor.
    // The client compositor can drop some frames too (e.g. attempting to
    // recover latency, missing the deadline, etc.).
    REASON_CLIENT_COMPOSITOR = 3;
  };

  // The reason is set only if |state| is not |STATE_UPDATED_ALL|.
  optional FrameDropReason reason = 2;

  optional uint64 frame_source = 3;
  optional uint64 frame_sequence = 4;

  // If this is a dropped frame (i.e. if |state| is set to |STATE_DROPPED| or
  // |STATE_PRESENTED_PARTIAL|), then indicates whether this frame impacts
  // smoothness.
  optional bool affects_smoothness = 5;

  enum ScrollState {
    SCROLL_NONE = 0;
    SCROLL_MAIN_THREAD = 1;
    SCROLL_COMPOSITOR_THREAD = 2;
    SCROLL_RASTER = 3;

    // Used when it can't be determined whether a scroll is in progress or not.
    SCROLL_UNKNOWN = 4;
  }

  // The type of active scroll.
  optional ScrollState scroll_state = 6;

  // If any main thread animation is active during this frame.
  optional bool has_main_animation = 7;
  // If any compositor thread animation is active during this frame.
  optional bool has_compositor_animation = 8;
  // If any touch-driven UX (not scroll) is active during this frame.
  optional bool has_smooth_input_main = 9;

  // Whether the frame contained any missing content (i.e. whether there was
  // checkerboarding in the frame).  If has_missing_content,
  // checkerboarded_needs_raster and checkerboarded_needs_record all have
  // values, has_missing_content should equal checkerboarded_needs_raster ||
  // checkerboarded_needs_record.
  optional bool has_missing_content = 10;

  // The id of layer_tree_host that the frame has been produced for.
  optional uint64 layer_tree_host_id = 11;

  // If total latency of PipelineReporter exceeds a certain limit.
  optional bool has_high_latency = 12;

  enum FrameType {
    FORKED = 0;
    BACKFILL = 1;
  }

  // Indicate if the frame is "FORKED" (i.e. a PipelineReporter event starts at
  // the same frame sequence as another PipelineReporter) or "BACKFILL"
  // (i.e. dropped frames when there are no partial compositor updates).
  optional FrameType frame_type = 13;

  // The breakdown stage of PipelineReporter that is most likely accountable for
  // high latency.
  repeated string high_latency_contribution_stage = 14;

  // Whether the frame contained any content that is not fully rastered.
  optional bool checkerboarded_needs_raster = 15;

  // Whether the frame contained any content that is not fully recorded.
  optional bool checkerboarded_needs_record = 16;

  // viz::BeginFrameArgs.trace_id of the frame (before surface aggregation). See
  // also ChromeTrackEvent.EventLatency.surface_frame_trace_id.
  optional int64 surface_frame_trace_id = 17;

  // gfx::PresentationFeedback.display_trace_id of the frame (after surface
  // aggregation). See also ChromeTrackEvent.EventLatency.display_trace_id.
  optional int64 display_trace_id = 18;
}

message InputTransferHandler {
  // The values in this enum are incremented by one compared to histograms enum
  // to follow proto guidelines to leave 0 for unknown or unset values.
  // LINT.IfChange(TransferInputToVizResult)
  enum TransferInputToVizResult {
    // We don't expect this to be present in traces.
    UNKNOWN = 0;
    SUCCESSFULLY_TRANSFERRED = 1;
    INPUT_TRANSFER_HANDLER_NOT_FOUND_IN_MAP = 2;
    NON_FINGER_TOOL_TYPE = 3;
    VIZ_INITIALIZATION_NOT_COMPLETE = 4;
    SELECTION_HANDLES_ACTIVE = 5;
    CAN_TRIGGER_BACK_GESTURE = 6;
    IME_IS_ACTIVE = 7;
    REQUESTED_BY_EMBEDDER = 8;
    SYSTEM_SERVER_DID_NOT_TRANSFER = 9;
    BROWSER_TOKEN_CHANGED = 10;
    MULTIPLE_BROWSER_WINDOWS_OPEN = 11;
    DOWN_TIME_AFTER_EVENT_TIME = 12;
    SEQUENCE_TRANSFERRED_BACK_FROM_VIZ = 13;
    WEB_CONTENTS_IGNORING_INPUT_EVENTS = 14;
    RIR_DELEGATE_CONNECTION_NOT_SETUP = 15;
    SHARED_MEMORY_UNAVAILABLE = 16;
    POSITIVE_EVENT_AND_DOWN_TIME_DELTA = 17;
    XR_IS_ACTIVE = 18;
    HAS_ACTIVE_TOUCH_INTERCEPTORS = 19;
  };
  // LINT.ThenChange(//tools/metrics/histograms/metadata/android/enums.xml:TransferInputToVizResult)
  optional TransferInputToVizResult transfer_result = 1;

  // LINT.IfChange(InputOnVizSequenceDroppedReason)
  enum InputOnVizSequenceDroppedReason {
    UNKNOWN_BROWSER_DROPPED_REASON = 0;
    ACTIVE_SEQ_ON_VIZ_ABNORMAL_DOWN_TIME = 1;
    FAILED_TO_TRANSFER_POTENTIAL_POINTER = 2;
    ANDROID_OS_TRANSFERRED_A_NEW_SEQUENCE = 3;
  };
  // LINT.ThenChange(
  //     //tools/metrics/histograms/metadata/android/enums.xml:InputOnVizSequenceDroppedReason,
  //     //content/browser/renderer_host/input/input_transfer_handler_android.h:InputOnVizSequenceDroppedReason
  // )

  optional InputOnVizSequenceDroppedReason browser_sequence_dropped_reason = 2;

  // LINT.IfChange(VizSequenceDroppedReason)
  enum VizSequenceDroppedReason {
    UNKNOWN_VIZ_DROPPED_REASON = 0;
    OLDER_SEQUENCE_IN_QUEUE = 1;
  };
  // LINT.ThenChange(
  //    //tools/metrics/histograms/metadata/android/enums.xml:VizSequenceDroppedReason,
  //    //components/viz/service/input/android_state_transfer_handler.cc:VizSequenceDroppedReason
  // )

  optional VizSequenceDroppedReason viz_sequence_dropped_reason = 3;

  message TopControlsOffset {
    // The offset of top controls as per the metadata from last drawn frame.
    optional float viz_y_offset_px = 1;
    // The offset that sent over from Browser as part of state transfer.
    optional float browser_y_offset_px = 2;
  }
  optional TopControlsOffset top_controls_offset = 4;
};

message ResponseInfo {
  // The HTTP response code. Will be left empty if the response code is unknown.
  optional int64 response_code = 1;

  // Whether the response was served from the HTTP cache.
  optional bool was_http_cache = 2;
};

message MemoryDumpProvider {
  // The name of the MemoryDumpProvider object, from the static list in
  // `kMemoryDumpProviderNameAllowList` (see
  // https://source.chromium.org/chromium/chromium/src/+/main:out/android-Debug/gen/base/trace_event/memory_dump_provider_name_variants.h).
  // The provider name is validated against the static list at compile time, at
  // https://source.chromium.org/chromium/chromium/src/+/main:base/trace_event/memory_dump_provider.h;l=65;drc=d36832392d30b9cbbd3a6ae8a37e11b92853f041.
  optional string name = 1;
};

// Information about `viz::FrameIntervalDecider`.
message FrameIntervalDecider {
  // LINT.IfChange(FrameIntervalClass)
  enum FrameIntervalClass {
    FRAME_INTERVAL_CLASS_UNSPECIFIED = 0;
    FRAME_INTERVAL_CLASS_BOOST = 1;
    FRAME_INTERVAL_CLASS_DEFAULT = 2;
  }
  // LINT.ThenChange(//components/viz/service/display/frame_interval_matchers.h:FrameIntervalClass)

  // LINT.IfChange(ResultIntervalType)
  enum ResultIntervalType {
    RESULT_INTERVAL_TYPE_UNSPECIFIED = 0;
    RESULT_INTERVAL_TYPE_EXACT = 1;
    RESULT_INTERVAL_TYPE_AT_LEAST = 2;
  }
  // LINT.ThenChange(//components/viz/service/display/frame_interval_matchers.h:ResultIntervalType)

  message ResultInterval {
    // The frame interval duration in microseconds.
    optional int64 interval_us = 1;
    optional ResultIntervalType type = 2;
  }

  // The ideal frame interval the display should use, as decided by the decider.
  message Result {
    oneof result {
      FrameIntervalClass frame_interval_class = 1;
      ResultInterval result_interval = 2;
    }
  }

  optional Result result = 1;

  // LINT.IfChange(FrameIntervalMatcherType)
  enum FrameIntervalMatcherType {
    MATCHER_TYPE_UNSPECIFIED = 0;
    MATCHER_TYPE_NONE = 1;
    MATCHER_TYPE_INPUT_BOOST = 2;
    MATCHER_TYPE_ONLY_VIDEO = 3;
    MATCHER_TYPE_VIDEO_CONFERENCE = 4;
    MATCHER_TYPE_ONLY_ANIMATING_IMAGE = 5;
    MATCHER_TYPE_ONLY_SCROLL_BAR_FADE_OUT = 6;
    MATCHER_TYPE_USER_INPUT_BOOST = 7;
    MATCHER_TYPE_SLOW_SCROLL_THROTTLE = 8;
  }
  // LINT.ThenChange(//components/viz/service/display/frame_interval_matchers.h:FrameIntervalMatcherType)

  // The type of the `viz::FrameIntervalMatcher` on which the decider based
  // its decision.
  optional FrameIntervalMatcherType matcher_type = 2;
}

message ChromeAccessibilityWinNotifyWinEvent {
  // The DWORD `event` parameter to ::NotifyWinEvent(). See
  // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-notifywinevent
  // One of the following constants:
  // https://learn.microsoft.com/en-us/windows/win32/winauto/event-constants
  optional uint32 native_event = 1;
}

message ChromeTrackEvent {
  reserved 1045;

  // Extension range for Chrome: 1000-1999
  // Next ID: 1083
  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 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;

    optional EventForwarder event_forwarder = 1059;

    optional TouchDispositionGestureFilter touch_disposition_gesture_filter =
        1060;

    optional ViewClassName view_class_name = 1061;

    optional ChromeCompositorSchedulerStateV2 cc_scheduler_state = 1062;

    optional WebViewStartup webview_startup = 1063;

    optional AnimationFrameTimingInfo animation_frame_timing_info = 1064;

    optional AnimationFrameScriptTimingInfo animation_frame_script_timing_info =
        1065;

    optional ScrollMetrics scroll_metrics = 1066 [deprecated = true];

    optional MainFramePipeline main_frame_pipeline = 1067;

    optional ChromeLatencyInfo2 chrome_latency_info = 1068;

    optional EventTiming event_timing = 1069;

    optional AndroidChoreographerFrameCallbackData
        android_choreographer_frame_callback_data = 1070;

    optional CurrentTask current_task = 1071;

    optional WebExposedIsolationInfo web_exposed_isolation_info = 1072;

    optional UrlInfo url_info = 1073;

    optional BeginFrameId begin_frame_id = 1074;

    // Older versions of Chrome set TrackEvent.chrome_frame_reporter, which is
    // now deprecated, instead.
    optional ChromeFrameReporter2 frame_reporter = 1075;

    optional InputTransferHandler input_transfer_handler = 1076;

    optional ResponseInfo response_info = 1077;

    optional EventLatency.ScrollJankV4Result scroll_jank_v4 = 1078;

    // Identifies the MemoryDumpProvider object that runs in the scope of a
    // trace event, to identify which objects cause delays in a trace.
    optional MemoryDumpProvider memory_dump_provider = 1079;

    optional ChromeAccessibilityWinNotifyWinEvent
        chrome_accessibility_win_notify_win_event = 1080;

    optional FrameIntervalDecider frame_interval_decider = 1081;

    optional BeginFrameArgsV2 begin_frame_args = 1082;
  }
}
