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