#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "services/device/generic_sensor/platform_sensor_provider.h"
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "build/build_config.h"
#include "services/device/public/cpp/generic_sensor/sensor_reading_shared_buffer.h"
#include "services/device/public/mojom/sensor_provider.mojom.h"
#if BUILDFLAG(IS_MAC)
#include "services/device/generic_sensor/platform_sensor_provider_mac.h"
#elif BUILDFLAG(IS_ANDROID)
#include "services/device/generic_sensor/platform_sensor_provider_android.h"
#elif BUILDFLAG(IS_WIN)
#include "base/win/windows_version.h"
#include "build/build_config.h"
#include "services/device/generic_sensor/platform_sensor_provider_win.h"
#include "services/device/generic_sensor/platform_sensor_provider_winrt.h"
#elif BUILDFLAG(IS_CHROMEOS)
#include "services/device/generic_sensor/platform_sensor_provider_chromeos.h"
#elif BUILDFLAG(IS_LINUX) && defined(USE_UDEV)
#include "services/device/generic_sensor/platform_sensor_provider_linux.h"
#endif
namespace device {
namespace {
constexpr uint64_t kReadingBufferSize = …;
constexpr uint64_t kSharedBufferSizeInBytes = …;
}
PlatformSensorProvider::PlatformSensorProvider() = default;
PlatformSensorProvider::~PlatformSensorProvider() { … }
std::unique_ptr<PlatformSensorProvider> PlatformSensorProvider::Create() { … }
void PlatformSensorProvider::CreateSensor(mojom::SensorType type,
CreateSensorCallback callback) { … }
scoped_refptr<PlatformSensor> PlatformSensorProvider::GetSensor(
mojom::SensorType type) { … }
bool PlatformSensorProvider::CreateSharedBufferIfNeeded() { … }
void PlatformSensorProvider::FreeResourcesIfNeeded() { … }
void PlatformSensorProvider::RemoveSensor(mojom::SensorType type,
PlatformSensor* sensor) { … }
base::ReadOnlySharedMemoryRegion
PlatformSensorProvider::CloneSharedMemoryRegion() { … }
void PlatformSensorProvider::NotifySensorCreated(
mojom::SensorType type,
scoped_refptr<PlatformSensor> sensor) { … }
std::vector<mojom::SensorType>
PlatformSensorProvider::GetPendingRequestTypes() { … }
SensorReadingSharedBuffer*
PlatformSensorProvider::GetSensorReadingSharedBufferForType(
mojom::SensorType type) { … }
#if BUILDFLAG(IS_WIN)
bool PlatformSensorProvider::UseWindowsWinrt() {
return base::win::GetVersion() >= base::win::Version::WIN10_19H1;
}
#endif
}