| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_ | 5 #ifndef DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_ |
| 6 #define DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_ | 6 #define DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_ |
| 7 | 7 |
| 8 #include <IOKit/IOKitLib.h> | 8 #include <IOKit/IOKitLib.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_ionotificationportref.h" | 10 #include "base/mac/scoped_ionotificationportref.h" |
| 11 #include "base/mac/scoped_ioobject.h" | 11 #include "base/mac/scoped_ioobject.h" |
| 12 #include "device/generic_sensor/platform_sensor.h" | 12 #include "device/generic_sensor/platform_sensor.h" |
| 13 | 13 |
| 14 namespace device { | 14 namespace device { |
| 15 | 15 |
| 16 // Implementation of PlatformSensor for macOS to query the ambient light sensor. | 16 // Implementation of PlatformSensor for macOS to query the ambient light sensor. |
| 17 // This is a single instance object per browser process which is created by | 17 // This is a single instance object per browser process which is created by |
| 18 // The singleton PlatformSensorProviderMac. If there are no clients, this | 18 // The singleton PlatformSensorProviderMac. If there are no clients, this |
| 19 // instance is not created. | 19 // instance is not created. |
| 20 class PlatformSensorAmbientLightMac : public PlatformSensor { | 20 class PlatformSensorAmbientLightMac : public PlatformSensor { |
| 21 public: | 21 public: |
| 22 // Construct a platform sensor of |type| AMBIENT_LIGHT, given | 22 // Construct a platform sensor of AMBIENT_LIGHT, given a buffer |mapping| |
| 23 // a buffer |mapping| to write the result back. |task_runner| is | 23 // to write the result back. |
| 24 // used to post the notification that the sensor reading has changed. | 24 PlatformSensorAmbientLightMac(mojo::ScopedSharedBufferMapping mapping, |
| 25 PlatformSensorAmbientLightMac(mojom::SensorType type, | |
| 26 mojo::ScopedSharedBufferMapping mapping, | |
| 27 PlatformSensorProvider* provider); | 25 PlatformSensorProvider* provider); |
| 28 | 26 |
| 29 mojom::ReportingMode GetReportingMode() override; | 27 mojom::ReportingMode GetReportingMode() override; |
| 30 // Can only be called once, the first time or after a StopSensor call. | 28 // Can only be called once, the first time or after a StopSensor call. |
| 31 bool StartSensor(const PlatformSensorConfiguration& configuration) override; | 29 bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
| 32 void StopSensor() override; | 30 void StopSensor() override; |
| 33 | 31 |
| 34 protected: | 32 protected: |
| 35 ~PlatformSensorAmbientLightMac() override; | 33 ~PlatformSensorAmbientLightMac() override; |
| 36 bool CheckSensorConfiguration( | 34 bool CheckSensorConfiguration( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 56 // sensor is busy. | 54 // sensor is busy. |
| 57 base::mac::ScopedIOObject<io_object_t> light_sensor_busy_notification_; | 55 base::mac::ScopedIOObject<io_object_t> light_sensor_busy_notification_; |
| 58 double current_lux_; | 56 double current_lux_; |
| 59 | 57 |
| 60 DISALLOW_COPY_AND_ASSIGN(PlatformSensorAmbientLightMac); | 58 DISALLOW_COPY_AND_ASSIGN(PlatformSensorAmbientLightMac); |
| 61 }; | 59 }; |
| 62 | 60 |
| 63 } // namespace device | 61 } // namespace device |
| 64 | 62 |
| 65 #endif // DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_ | 63 #endif // DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_ |
| OLD | NEW |