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_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_ |
| 6 #define DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_ |
| 7 |
| 8 #include <IOKit/IOKitLib.h> |
| 9 |
| 10 #include "base/mac/scoped_ioobject.h" |
| 11 #include "device/generic_sensor/platform_sensor.h" |
| 12 |
| 13 namespace base { |
| 14 class SingleThreadTaskRunner; |
| 15 } |
| 16 |
| 17 namespace device { |
| 18 |
| 19 class PlatformSensorAmbientLightMac : public PlatformSensor { |
| 20 public: |
| 21 PlatformSensorAmbientLightMac( |
| 22 mojom::SensorType type, |
| 23 mojo::ScopedSharedBufferMapping mapping, |
| 24 uint64_t buffer_size, |
| 25 PlatformSensorProvider* provider, |
| 26 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| 27 |
| 28 mojom::ReportingMode GetReportingMode() override; |
| 29 bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
| 30 void StopSensor() override; |
| 31 |
| 32 protected: |
| 33 ~PlatformSensorAmbientLightMac() override; |
| 34 bool CheckSensorConfiguration( |
| 35 const PlatformSensorConfiguration& configuration) override; |
| 36 PlatformSensorConfiguration GetDefaultConfiguration() override; |
| 37 void UpdateReading(uint64_t lux_values[2]); |
| 38 |
| 39 private: |
| 40 static void IOServiceCallback(void* context, |
| 41 io_service_t service, |
| 42 natural_t message_type, |
| 43 void*); |
| 44 base::mac::ScopedIOObject<io_service_t> light_sensor_service_; |
| 45 IONotificationPortRef light_sensor_port_; |
| 46 io_object_t light_sensor_object_; |
| 47 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 48 double current_lux_; |
| 49 DISALLOW_COPY_AND_ASSIGN(PlatformSensorAmbientLightMac); |
| 50 }; |
| 51 |
| 52 } // namespace device |
| 53 |
| 54 #endif // DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_ |
OLD | NEW |