chromium/third_party/blink/public/mojom/messaging/transferable_message.mojom

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

module blink.mojom;

import "third_party/blink/public/mojom/array_buffer/array_buffer_contents.mojom";
import "third_party/blink/public/mojom/blob/serialized_blob.mojom";
import "third_party/blink/public/mojom/messaging/cloneable_message.mojom";
import "third_party/blink/public/mojom/messaging/delegated_capability.mojom";
import "third_party/blink/public/mojom/messaging/message_port_descriptor.mojom";
import "third_party/blink/public/mojom/messaging/user_activation_snapshot.mojom";
import "third_party/blink/public/mojom/messaging/task_attribution_id.mojom";
import "third_party/blink/public/mojom/messaging/static_bitmap_image.mojom";

// A MessagePort is represented as a raw mojo message pipe, as such no interface
// definition exists for it here. Messages on this pipe are serialized versions
// of the TransferableMessage struct defined below.
// TODO(crbug.com/750468): Consider using an actual Mojo interface for message
// ports.

// This struct combines the cloneable part of a message with the parts of the
// message that are merely transferable. In particular that includes ports that
// are transferred. This struct is used for most postMessage style APIs,
// including messages posted on MessagePorts themselves.
struct TransferableMessage {
  CloneableMessage message;
  // Any ports being transferred as part of this message.
  array<MessagePortDescriptor> ports;
  // Channels used to transfer WHATWG streams (eg. ReadableStream).
  array<MessagePortDescriptor> stream_channels;
  // Any ArrayBuffers being transferred as part of this message.
  array<SerializedArrayBufferContents> array_buffer_contents_array;
  // Any ImageBitmaps being transferred as part of this message.
  array<SerializedStaticBitmapImage> image_bitmap_contents_array;
  // The user activation state, null if the frame isn't providing it.
  UserActivationSnapshot? user_activation;
  // What capability, if any, is delegated to the destination frame.
  DelegatedCapability delegated_capability = kNone;
  // The ID of the task initiating the message.
  TaskAttributionId? parent_task_id;
};