chromium/mojo/public/interfaces/bindings/interface_control_messages.mojom

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

[JavaPackage="org.chromium.mojo.bindings.interfacecontrol"]
module mojo.interface_control;

// For each user-defined interface, some control functions are provided by the
// interface endpoints at both sides.

////////////////////////////////////////////////////////////////////////////////
// Run@0xFFFFFFFF(RunInput input) => (RunOutput? output);
//
// This control function runs the input command. If the command is not
// supported, |output| is set to null; otherwise |output| stores the result,
// whose type depends on the input.

const uint32 kRunMessageId = 0xFFFFFFFF;

struct RunMessageParams {
  RunInput input;
};
union RunInput {
  QueryVersion query_version;
  FlushForTesting flush_for_testing;
};

struct RunResponseMessageParams {
  RunOutput? output;
};
union RunOutput {
  QueryVersionResult query_version_result;
};

// Queries the max supported version of the user-defined interface.
// Sent by the interface client side.
struct QueryVersion {
};
struct QueryVersionResult {
  uint32 version;
};

// Sent by either side of the interface.
struct FlushForTesting {
};

////////////////////////////////////////////////////////////////////////////////
// RunOrClosePipe@0xFFFFFFFE(RunOrClosePipeInput input);
//
// This control function runs the input command. If the operation fails or the
// command is not supported, the message pipe is closed.

const uint32 kRunOrClosePipeMessageId = 0xFFFFFFFE;

struct RunOrClosePipeMessageParams {
  RunOrClosePipeInput input;
};
union RunOrClosePipeInput {
  RequireVersion require_version;
  EnableIdleTracking enable_idle_tracking;
  MessageAck message_ack;
  NotifyIdle notify_idle;
};

// If the specified version of the user-defined interface is not supported, the
// function fails and the pipe is closed.
// Sent by the interface client side.
struct RequireVersion {
  uint32 version;
};

// Sent by a remote caller endpoint to a receiving endpoint to enable idle state
// tracking. Once a receiving endpoint receives this message, it will begin
// acknowledging all received interface messages with a MessageAck, and may send
// arbitrarily many NotifyIdle messages any time it believes itself to have been
// idle for a continuous period at least as long as |timeout_in_microseconds|.
struct EnableIdleTracking {
  // NOTE: It would be nice to use mojo_base.mojom.TimeDelta here, but currently
  // that results in a tricky dependency cycle for JS bindings.
  int64 timeout_in_microseconds;
};

// Sent by a receiving endpoint to its client to acknowledge message receipt.
// Should only be sent by endpoints which have previously received an
// EnableIdleTracking message.
struct MessageAck {};

// Sent by a receiving endpoint to its client to indicate that the receiver is
// currently idle. Should only be sent by endpoints which have previously
// received and EnableIdleTracking message.
struct NotifyIdle {};