chromium/chrome/browser/resource_coordinator/lifecycle_unit_state.mojom

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

module mojom;

// Note that these states are emitted via UKMs, so the integer values should
// remain consistent.
enum LifecycleUnitState {
  // The LifecycleUnit is alive and active with no CPU throttling.
  ACTIVE = 0,
  // The LifecycleUnit is currently being CPU throttled.
  THROTTLED = 1,
  // Deprecated: The LifecycleUnit is currently transitioning to a FROZEN state.
  // PENDING_FREEZE = 2,
  // The LifecycleUnit is frozen.
  FROZEN = 3,
  // Deprecated: The LifecycleUnit is currently transitioning to a DISCARDED
  // state.
  // PENDING_DISCARD = 4,
  // The LifecycleUnit is discarded, and is consuming no system resources.
  DISCARDED = 5,
  // Deprecated: The LifecycleUnit is currently transitioning from the FROZEN
  // state to the ACTIVE state.
  // PENDING_UNFREEZE = 6,
};

// Indicates the loading state of a lifecycle unit, orthogonal to the basic
// lifecycle state. Note that these values are written to logs and histograms
// so need to remain consistent.
enum LifecycleUnitLoadingState {
  // The LifecycleUnit is not yet loaded, or loading was attempted but failed.
  UNLOADED = 0,
  // The LifecycleUnit is loading.
  LOADING = 1,
  // The LifecycleUnit is loaded.
  LOADED = 2,
};

// An enumeration of reasons why a lifecycle state change was applied. These are
// also emitted via UKM so need to remain stable.
enum LifecycleUnitStateChangeReason {
  // Policy in the browser decided to initiate the state change.
  BROWSER_INITIATED = 0,
  // Policy in the renderer decided to initiate the state change.
  RENDERER_INITIATED = 1,
  // A system wide memory pressure condition initiated the state change.
  SYSTEM_MEMORY_PRESSURE = 2,
  // Initiated by an extension.
  EXTENSION_INITIATED = 3,
  // Initiated by a user action (e.g. changing focus, clicking reload).
  USER_INITIATED = 4,
};

// An enumeration of reasons for a discard.
enum LifecycleUnitDiscardReason {
  // The discard is requested from outside of TabManager (e.g. by an extension).
  EXTERNAL = 0,
  // The discard is requested urgently by TabManager when the system is in a
  // critical condition.
  URGENT = 1,
  // The discard is requested proactively by PerformanceManager to free up
  // memory before the system is under memory pressure, such as when Memory
  // Saver Mode initiates a discard.
  PROACTIVE = 2,
  // The discard is requested by PerformanceDetectionManager because the
  // manager has detected intensive resource usage and suggests discarding
  // certain tabs in an attempt to improve resource usage.
  SUGGESTED = 3,
};