#include "services/device/generic_sensor/sensor_provider_impl.h"
#include <memory>
#include <utility>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/device/generic_sensor/platform_sensor_provider.h"
#include "services/device/generic_sensor/sensor_impl.h"
#include "services/device/generic_sensor/virtual_platform_sensor.h"
#include "services/device/generic_sensor/virtual_platform_sensor_provider.h"
#include "services/device/public/cpp/device_features.h"
#include "services/device/public/cpp/generic_sensor/sensor_reading_shared_buffer.h"
#include "services/device/public/cpp/generic_sensor/sensor_traits.h"
namespace device {
namespace {
bool IsExtraSensorClass(mojom::SensorType type) { … }
}
SensorProviderImpl::SensorProviderImpl(
std::unique_ptr<PlatformSensorProvider> provider)
: … { … }
SensorProviderImpl::~SensorProviderImpl() = default;
void SensorProviderImpl::Bind(
mojo::PendingReceiver<mojom::SensorProvider> receiver) { … }
void SensorProviderImpl::OnReceiverDisconnected() { … }
void SensorProviderImpl::GetSensor(mojom::SensorType type,
GetSensorCallback callback) { … }
void SensorProviderImpl::SensorCreated(
base::ReadOnlySharedMemoryRegion cloned_region,
GetSensorCallback callback,
scoped_refptr<PlatformSensor> sensor) { … }
void SensorProviderImpl::CreateVirtualSensor(
mojom::SensorType type,
mojom::VirtualSensorMetadataPtr metadata,
CreateVirtualSensorCallback callback) { … }
void SensorProviderImpl::UpdateVirtualSensor(
mojom::SensorType type,
const SensorReading& reading,
UpdateVirtualSensorCallback callback) { … }
void SensorProviderImpl::RemoveVirtualSensor(
mojom::SensorType type,
RemoveVirtualSensorCallback callback) { … }
void SensorProviderImpl::GetVirtualSensorInformation(
mojom::SensorType type,
GetVirtualSensorInformationCallback callback) { … }
size_t SensorProviderImpl::GetVirtualProviderCountForTesting() const { … }
const VirtualPlatformSensorProvider*
SensorProviderImpl::GetLastVirtualSensorProviderForTesting() const { … }
}