chromium/content/common/agent_scheduling_group.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 content.mojom;

import "content/common/associated_interfaces.mojom";
import "content/common/frame.mojom";
import "third_party/blink/public/mojom/frame/frame.mojom";
import "third_party/blink/public/mojom/frame/frame_replication_state.mojom";
import "third_party/blink/public/mojom/frame/tree_scope_type.mojom";
import "third_party/blink/public/mojom/shared_storage/shared_storage_worklet_service.mojom";
import "third_party/blink/public/mojom/tokens/tokens.mojom";
import "third_party/blink/public/mojom/worker/worklet_global_scope_creation_params.mojom";

// Interface for general communication between the renderer process's
// AgentSchedulingGroup and the browser process's AgentSchedulingGroupHost.
// Implemented by AgentSchedulingGroupHost (in the browser process).
//
// This interface is associated with this AgentSchedulingGroup's channel.
// The renderer process retrieves it via
// AgentSchedulingGroup.BindAssociatedInterfaces(). See comments on
// AgentSchedulingGroup for more about channels.
interface AgentSchedulingGroupHost {
  // Acknowledge a RenderFrame was unloaded due to NavigationControl::Unload().
  // This is not simply a reply callback on NavigationControl::Unload() because
  // it needs to be invoked after the AssociatedReceiver (owned by RenderFrame)
  // is already destroyed. This timing is required to ensure that any scheduled
  // postMessages are dispatched prior to acknowledging the unload (which tears
  // down the browser-side RFHI by removing it from the pending delete list)
  DidUnloadRenderFrame(blink.mojom.LocalFrameToken frame_token);
};

// Interface for general communication between the browser process's
// AgentSchedulingGroupHost and the renderer process's AgentSchedulingGroup.
// Implemented by content::AgentSchedulingGroup (in the renderer process).
//
// The interface's message pipe depends on the mode that the Multiple Blink
// Isolate (MBI) feature is using (https://crbug.com/1051790).
//
// In non-kLegacy mode: there is a legacy IPC channel per AgentSchedulingGroup.
// The channel is created along with this interface, which it is associated
// with. Messages are *not* ordered with the per-process legacy IPC channel.
//
// In kLegacy mode: there is one legacy IPC channel per renderer and this
// interface is channel-associated with it. The browser process retrieves it via
// GetRemoteAssociatedInterface().
//
// See the comments for MBIMode in content/public/common/content_features.h for
// more details.
interface AgentSchedulingGroup {
  // Tells the renderer to bind the AgentSchedulingGroup's associated
  // interfaces. This includes the host remote (mojom::AgentSchedulingGroupHost)
  // as well as RouteProvider remote/receiver pair.
  // We have this as a method on this interface, as opposed to passing the
  // pending interfaces over the method that creates the AgentSchedulingGroup:
  // Renderer.CreateAgentSchedulingGroup() or
  // Renderer.CreateAgentAssociatedSchedulingGroup() (depending on the mode, see
  // the interface comments). This is because we need these interfaces to be
  // associated with the message pipe that the AgentSchedulingGroup is
  // associated with, which may be different than the message pipe that we
  // create the AgentSchedulingGroup over.
  BindAssociatedInterfaces(
    pending_associated_remote<AgentSchedulingGroupHost> remote_host,
    pending_associated_receiver<RouteProvider> route_provider_receiver);

  // Tells the renderer to create a new view.
  CreateView(CreateViewParams params);

  // Tells the renderer to create a new RenderFrame.
  CreateFrame(CreateFrameParams params);

  // Tells the renderer process to create a thread that exclusively hosts the
  // shared storage worklet service.
  CreateSharedStorageWorkletService(
      pending_receiver<blink.mojom.SharedStorageWorkletService> receiver,
      blink.mojom.WorkletGlobalScopeCreationParams global_scope_creation_params);
};