chromium/components/performance_manager/public/mojom/v8_contexts.mojom

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

module performance_manager.mojom;

import "third_party/blink/public/mojom/tokens/tokens.mojom";

// Stores information about an iframe element from the point of view of the
// document that hosts the iframe. This is used for purely informational
// purposes in the performance.measureUserAgentSpecificMemory API to identify
// an iframe in memory usage reports.
struct IframeAttributionData {
  // The value of the "id" attribute associated with the iframe element.
  string? id;
  // The value of the "src" attribute associated with the iframe element. We
  // don't use an URL because we don't need to parse this, or otherwise use
  // it as an URL, and URL objects have a large memory footprint.
  string? src;
};

// Identifies a V8Context type. Note that this roughly corresponds to the
// world types defined in blink, but with some simplifications.
enum V8ContextWorldType {
  // The main world, corresponding to a frame / document.
  kMain,
  // Corresponds to the main world of a worker or worklet.
  kWorkerOrWorklet,
  // Corresponds to a ShadowRealm.
  kShadowRealm,
  // Corresponds to an extension. Will have a stable extension ID.
  kExtension,
  // Corresponds to a non-extension isolated world. Will have a human readable
  // name.
  kIsolated,
  // Corresponds to the devtools inspector. Will not have a human readable
  // name or a stable id.
  kInspector,
  // Corresponds to the regexp world. This world is unique in that it is per
  // v8::Isolate, and not associated with any individual execution context.
  // Will not have a human-readable name or stable id.
  kRegExp,
};

// Information describing a V8 Context. A context is a unit of accounting for
// resource usage, and corresponds to a "world" in Blink parlance.
struct V8ContextDescription {
  // The unique token that names the world.
  blink.mojom.V8ContextToken token;
  // The type of this world.
  V8ContextWorldType world_type;
  // Identifies this world. Only set for extension and isolated worlds. For
  // extension worlds this corresponds to the stable extension ID. For other
  // isolated worlds this is a human-readable description.
  string? world_name;
  // The identity of the execution context that this V8Context is associated
  // with. This is specified for all world types, except kRegExp worlds.
  blink.mojom.ExecutionContextToken? execution_context_token;
};