chromium/services/device/generic_sensor/virtual_platform_sensor.h

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

#ifndef SERVICES_DEVICE_GENERIC_SENSOR_VIRTUAL_PLATFORM_SENSOR_H_
#define SERVICES_DEVICE_GENERIC_SENSOR_VIRTUAL_PLATFORM_SENSOR_H_

#include <optional>

#include "base/memory/weak_ptr.h"
#include "services/device/generic_sensor/platform_sensor.h"
#include "services/device/public/cpp/generic_sensor/platform_sensor_configuration.h"
#include "services/device/public/cpp/generic_sensor/sensor_reading.h"
#include "services/device/public/mojom/sensor.mojom-shared.h"
#include "services/device/public/mojom/sensor_provider.mojom.h"

namespace device {

// OS-agnostic PlatformSensor implementation used in (web) tests. New instances
// are created by VirtualPlatformSensorProvider via GetSensor() calls.
//
// A VirtualPlatformSensor respects two invariants when it comes to readings
// added in the constructor or with AddReading():
// 1. Once a reading is set, it will remain set until it is replaced with
//    another reading.
// 2. Said reading will be added to the shared buffer (which may choose to
//    ignore it) and, on success, clients will be notified whenever the sensor
//    is activated (i.e. StartSensor() is called).
class VirtualPlatformSensor : public PlatformSensor {};

}  // namespace device

#endif  // SERVICES_DEVICE_GENERIC_SENSOR_VIRTUAL_PLATFORM_SENSOR_H_