// Copyright 2016 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/messaging/cloneable_message.mojom";
// A pair of BroadcastChannelClient interfaces is used to represent a connection
// to a particular channel. One client is implemented in the browser, for
// messages sent from the renderer to the browser, and one client is implemented
// in the renderer for messages from the browser to the renderer.
interface BroadcastChannelClient {
// Messages are passed as CloneableMessage, which contains a
// SerializedScriptValue.
OnMessage(blink.mojom.CloneableMessage message);
};
// This interface is used to set up connections to broadcast channels. All
// connections to channels made from the same event loop should be made
// either through the same BroadcastChannelProvider connection or through
// associated interface connections to ensure correct ordering of messages.
//
// Typically the browser will have one instance of a BroadcastChannelProvider
// per host (RenderFrameHost, ServiceWorkerHost, etc.) that receives the
// `ConnectToChannel` messages from the renderer and passes them to a
// singleton BroadcastChannelService owned by the storage partition.
// The BroadcastChannelService instance will then forward messages received on
// a particular connection to all other connections in the same storage
// partition with the same name (partitioned by StorageKey).
interface BroadcastChannelProvider {
// Connect to the channel identified by the `name`. Messages can
// be sent to the channel using `connection`, and messages to the channel
// will be received by `client`. Partitioning of channels will be done by
// StorageKey, which will be inferred from the Mojo receiver binding.
ConnectToChannel(
string name,
pending_associated_remote<BroadcastChannelClient> client,
pending_associated_receiver<BroadcastChannelClient> connection);
};