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_SENSOR_SENSOR_PROVIDER_IMPL_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ |
6 #define DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ | 6 #define DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "device/generic_sensor/generic_sensor_export.h" |
9 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h" | 10 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h" |
10 | 11 |
11 namespace device { | 12 namespace device { |
12 | 13 |
13 class PlatformSensorProvider; | 14 class PlatformSensorProvider; |
14 class PlatformSensor; | 15 class PlatformSensor; |
15 | 16 |
16 // Implementation of SensorProvider mojo interface. | 17 // Implementation of SensorProvider mojo interface. |
17 // Uses PlatformSensorProvider singleton to create platform specific instances | 18 // Uses PlatformSensorProvider singleton to create platform specific instances |
18 // of PlatformSensor which are used by SensorImpl. | 19 // of PlatformSensor which are used by SensorImpl. |
19 class SensorProviderImpl final : public mojom::SensorProvider { | 20 class DEVICE_GENERIC_SENSOR_EXPORT SensorProviderImpl final |
| 21 : public mojom::SensorProvider { |
20 public: | 22 public: |
21 static void Create(mojom::SensorProviderRequest request); | 23 static void Create(mojom::SensorProviderRequest request); |
22 | 24 |
23 ~SensorProviderImpl() override; | 25 ~SensorProviderImpl() override; |
24 | 26 |
25 private: | 27 private: |
26 explicit SensorProviderImpl(PlatformSensorProvider* provider); | 28 explicit SensorProviderImpl(PlatformSensorProvider* provider); |
27 | 29 |
28 // SensorProvider implementation. | 30 // SensorProvider implementation. |
29 void GetSensor(mojom::SensorType type, | 31 void GetSensor(mojom::SensorType type, |
30 mojom::SensorRequest sensor_request, | 32 mojom::SensorRequest sensor_request, |
31 const GetSensorCallback& callback) override; | 33 const GetSensorCallback& callback) override; |
32 | 34 |
33 // Helper callback method to return created sensors. | 35 // Helper callback method to return created sensors. |
34 void SensorCreated(mojom::SensorType type, | 36 void SensorCreated(mojom::SensorType type, |
35 mojo::ScopedSharedBufferHandle cloned_handle, | 37 mojo::ScopedSharedBufferHandle cloned_handle, |
36 mojom::SensorRequest sensor_request, | 38 mojom::SensorRequest sensor_request, |
37 const GetSensorCallback& callback, | 39 const GetSensorCallback& callback, |
38 scoped_refptr<PlatformSensor> sensor); | 40 scoped_refptr<PlatformSensor> sensor); |
39 | 41 |
40 PlatformSensorProvider* provider_; | 42 PlatformSensorProvider* provider_; |
41 base::WeakPtrFactory<SensorProviderImpl> weak_ptr_factory_; | 43 base::WeakPtrFactory<SensorProviderImpl> weak_ptr_factory_; |
42 | 44 |
43 DISALLOW_COPY_AND_ASSIGN(SensorProviderImpl); | 45 DISALLOW_COPY_AND_ASSIGN(SensorProviderImpl); |
44 }; | 46 }; |
45 | 47 |
46 } // namespace device | 48 } // namespace device |
47 | 49 |
48 #endif // DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ | 50 #endif // DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ |
OLD | NEW |