// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module device.mojom;
import "mojo/public/mojom/base/unguessable_token.mojom";
import "services/device/public/mojom/pressure_update.mojom";
// PressureManager.AddClient()'s return type.
enum PressureManagerAddClientResult {
kNotSupported,
kOk,
};
struct VirtualPressureSourceMetadata {
// Whether a virtual pressure source should provide samples or report itself
// as not available.
bool available = true;
};
// This interface is used to subscribe to notification about OnPressureUpdated.
//
// This interface is implemented by PressureManagerImpl in services/device.
// PressureObserverManager in Blink uses this interface to make a
// PressureClient subscribe to notification about OnPressureUpdated.
interface PressureManager {
// Creates a new virtual pressure source of type |source| handled by |token|.
// Callers are responsible for ensuring that |token| does not contain a
// pressure source of type |source|. If it does, a bad message will be
// reported.
AddVirtualPressureSource(
mojo_base.mojom.UnguessableToken token, PressureSource source,
VirtualPressureSourceMetadata metadata) => ();
// Removes a virtual pressure source identified by |token| and |source|. Does
// nothing if one does not exist.
RemoveVirtualPressureSource(
mojo_base.mojom.UnguessableToken token, PressureSource source) => ();
// Sends state update and own contribution estimate update for a virtual
// pressure source corresponding to |token| and |source|.
// Does nothing if |token| does not contain a pressure source of type
// |source|.
UpdateVirtualPressureSourceData(
mojo_base.mojom.UnguessableToken token, PressureSource source,
PressureState state, double own_contribution_estimate) => ();
// Add a client that will be notified when a new PressureUpdate for `source`
// is obtained.
//
// |token| can be used to identify a virtual pressure source created with a
// call to AddVirtualPressureSource().
AddClient(PressureSource source, mojo_base.mojom.UnguessableToken? token,
pending_associated_remote<device.mojom.PressureClient> client) =>
(PressureManagerAddClientResult result);
};
// Interface that client of the PressureManager interface must
// implement to receive PressureUpdate.
//
// This interface is implemented by PressureObserverManager in Blink.
// PressureManagerImpl uses this interface to deliver PressureUpdate to
// its client.
interface PressureClient {
// Interface used to deliver PressureUpdate.
OnPressureUpdated(PressureUpdate update);
};