| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ | |
| 6 #define DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/single_thread_task_runner.h" | |
| 10 #include "device/generic_sensor/generic_sensor_export.h" | |
| 11 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h" | |
| 12 | |
| 13 namespace device { | |
| 14 | |
| 15 class PlatformSensorProvider; | |
| 16 class PlatformSensor; | |
| 17 | |
| 18 // Implementation of SensorProvider mojo interface. | |
| 19 // Uses PlatformSensorProvider singleton to create platform specific instances | |
| 20 // of PlatformSensor which are used by SensorImpl. | |
| 21 class DEVICE_GENERIC_SENSOR_EXPORT SensorProviderImpl final | |
| 22 : public mojom::SensorProvider { | |
| 23 public: | |
| 24 static void Create( | |
| 25 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, | |
| 26 mojom::SensorProviderRequest request); | |
| 27 | |
| 28 ~SensorProviderImpl() override; | |
| 29 | |
| 30 private: | |
| 31 explicit SensorProviderImpl(PlatformSensorProvider* provider); | |
| 32 | |
| 33 // SensorProvider implementation. | |
| 34 void GetSensor(mojom::SensorType type, | |
| 35 mojom::SensorRequest sensor_request, | |
| 36 const GetSensorCallback& callback) override; | |
| 37 | |
| 38 // Helper callback method to return created sensors. | |
| 39 void SensorCreated(mojom::SensorType type, | |
| 40 mojo::ScopedSharedBufferHandle cloned_handle, | |
| 41 mojom::SensorRequest sensor_request, | |
| 42 const GetSensorCallback& callback, | |
| 43 scoped_refptr<PlatformSensor> sensor); | |
| 44 | |
| 45 PlatformSensorProvider* provider_; | |
| 46 base::WeakPtrFactory<SensorProviderImpl> weak_ptr_factory_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(SensorProviderImpl); | |
| 49 }; | |
| 50 | |
| 51 } // namespace device | |
| 52 | |
| 53 #endif // DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ | |
| OLD | NEW |