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_PLATFORM_SENSOR_WIN_H_ |
| 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_WIN_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "device/generic_sensor/platform_sensor.h" |
| 10 #include "device/generic_sensor/platform_sensor_reader_win.h" |
| 11 |
| 12 namespace base { |
| 13 class SingleThreadTaskRunner; |
| 14 } |
| 15 |
| 16 namespace device { |
| 17 |
| 18 class PlatformSensorReaderWin; |
| 19 |
| 20 // Implementation of PlatformSensor interface for Windows platform. Instance |
| 21 // of PlatformSensorWin is bound to IPC thread where PlatformSensorProvider is |
| 22 // running and communication with Windows platform sensor is done through |
| 23 // PlatformSensorReaderWin |sensor_reader_| interface which is bound to sensor |
| 24 // thread and communicates with PlatformSensorWin using |
| 25 // PlatformSensorReaderWin::Client interface. The error and data change events |
| 26 // are forwarded to IPC task runner. |
| 27 class PlatformSensorWin final : public PlatformSensor, |
| 28 public PlatformSensorReaderWin::Client { |
| 29 public: |
| 30 PlatformSensorWin( |
| 31 mojom::SensorType type, |
| 32 mojo::ScopedSharedBufferMapping mapping, |
| 33 PlatformSensorProvider* provider, |
| 34 scoped_refptr<base::SingleThreadTaskRunner> sensor_thread_runner, |
| 35 std::unique_ptr<PlatformSensorReaderWin> sensor_reader); |
| 36 |
| 37 PlatformSensorConfiguration GetDefaultConfiguration() override; |
| 38 mojom::ReportingMode GetReportingMode() override; |
| 39 |
| 40 // PlatformSensorReaderWin::Client interface implementation. |
| 41 void OnReadingUpdated(const SensorReading& reading) override; |
| 42 void OnSensorError() override; |
| 43 |
| 44 protected: |
| 45 ~PlatformSensorWin() override; |
| 46 // PlatformSensor interface implementation. |
| 47 bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
| 48 void StopSensor() override; |
| 49 bool CheckSensorConfiguration( |
| 50 const PlatformSensorConfiguration& configuration) override; |
| 51 |
| 52 private: |
| 53 scoped_refptr<base::SingleThreadTaskRunner> sensor_thread_runner_; |
| 54 std::unique_ptr<PlatformSensorReaderWin> sensor_reader_; |
| 55 base::WeakPtrFactory<PlatformSensorWin> weak_factory_; |
| 56 DISALLOW_COPY_AND_ASSIGN(PlatformSensorWin); |
| 57 }; |
| 58 |
| 59 } // namespace device |
| 60 |
| 61 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_WIN_H_ |
OLD | NEW |