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_PLATFORM_SENSOR_PROVIDER_BASE_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ |
6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ | 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 | 9 |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // Gets previously created instance of PlatformSensor by sensor type |type|. | 28 // Gets previously created instance of PlatformSensor by sensor type |type|. |
29 scoped_refptr<PlatformSensor> GetSensor(mojom::SensorType type); | 29 scoped_refptr<PlatformSensor> GetSensor(mojom::SensorType type); |
30 | 30 |
31 // Shared buffer getters. | 31 // Shared buffer getters. |
32 mojo::ScopedSharedBufferHandle CloneSharedBufferHandle(); | 32 mojo::ScopedSharedBufferHandle CloneSharedBufferHandle(); |
33 | 33 |
34 // Returns 'true' if some of sensor instances produced by this provider are | 34 // Returns 'true' if some of sensor instances produced by this provider are |
35 // alive; 'false' otherwise. | 35 // alive; 'false' otherwise. |
36 bool HasSensors() const; | 36 bool HasSensors() const; |
37 | 37 |
38 // Implementations might want to override this in order to be able | |
39 // to read from sensor files. For example, linux does so. | |
40 virtual void SetFileTaskRunner( | |
41 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) {} | |
42 | |
43 protected: | 38 protected: |
44 PlatformSensorProviderBase(); | 39 PlatformSensorProviderBase(); |
45 virtual ~PlatformSensorProviderBase(); | 40 virtual ~PlatformSensorProviderBase(); |
46 | 41 |
47 // Method that must be implemented by platform specific classes. | 42 // Method that must be implemented by platform specific classes. |
48 virtual void CreateSensorInternal(mojom::SensorType type, | 43 virtual void CreateSensorInternal(mojom::SensorType type, |
49 mojo::ScopedSharedBufferMapping mapping, | 44 mojo::ScopedSharedBufferMapping mapping, |
50 const CreateSensorCallback& callback) = 0; | 45 const CreateSensorCallback& callback) = 0; |
51 | 46 |
52 // Implementations might override this method to free resources when there | 47 // Implementations might override this method to free resources when there |
(...skipping 14 matching lines...) Expand all Loading... |
67 std::map<mojom::SensorType, PlatformSensor*> sensor_map_; | 62 std::map<mojom::SensorType, PlatformSensor*> sensor_map_; |
68 std::map<mojom::SensorType, CallbackQueue> requests_map_; | 63 std::map<mojom::SensorType, CallbackQueue> requests_map_; |
69 mojo::ScopedSharedBufferHandle shared_buffer_handle_; | 64 mojo::ScopedSharedBufferHandle shared_buffer_handle_; |
70 | 65 |
71 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderBase); | 66 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderBase); |
72 }; | 67 }; |
73 | 68 |
74 } // namespace device | 69 } // namespace device |
75 | 70 |
76 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ | 71 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ |
OLD | NEW |