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" |
11 #include "device/generic_sensor/platform_sensor.h" | 11 #include "device/generic_sensor/platform_sensor.h" |
12 | 12 |
13 namespace device { | 13 namespace device { |
14 | 14 |
15 // Base class that defines factory methods for PlatformSensor creation. | 15 // Base class that defines factory methods for PlatformSensor creation. |
16 // Its implementations must be accessed via GetInstance() method. | 16 // Its implementations must be accessed via GetInstance() method. |
17 class PlatformSensorProviderBase : public base::NonThreadSafe { | 17 class PlatformSensorProviderBase : public base::NonThreadSafe { |
18 public: | 18 public: |
19 // Returns the PlatformSensorProviderBase singleton. | |
20 // Note: returns 'nullptr' if there is no available implementation for | |
21 // the current platform. | |
22 static PlatformSensorProviderBase* GetInstance(); | |
23 | |
24 // Creates new instance of PlatformSensor. | 19 // Creates new instance of PlatformSensor. |
25 scoped_refptr<PlatformSensor> CreateSensor(mojom::SensorType type, | 20 scoped_refptr<PlatformSensor> CreateSensor(mojom::SensorType type, |
26 uint64_t size, | 21 uint64_t size, |
27 uint64_t offset); | 22 uint64_t offset); |
28 | 23 |
29 // Gets previously created instance of PlatformSensor by sensor type |type|. | 24 // Gets previously created instance of PlatformSensor by sensor type |type|. |
30 scoped_refptr<PlatformSensor> GetSensor(mojom::SensorType type); | 25 scoped_refptr<PlatformSensor> GetSensor(mojom::SensorType type); |
31 | 26 |
32 // Shared buffer getters. | 27 // Shared buffer getters. |
33 mojo::ScopedSharedBufferHandle CloneSharedBufferHandle(); | 28 mojo::ScopedSharedBufferHandle CloneSharedBufferHandle(); |
(...skipping 17 matching lines...) Expand all Loading... |
51 private: | 46 private: |
52 std::map<mojom::SensorType, PlatformSensor*> sensor_map_; | 47 std::map<mojom::SensorType, PlatformSensor*> sensor_map_; |
53 mojo::ScopedSharedBufferHandle shared_buffer_handle_; | 48 mojo::ScopedSharedBufferHandle shared_buffer_handle_; |
54 | 49 |
55 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderBase); | 50 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderBase); |
56 }; | 51 }; |
57 | 52 |
58 } // namespace device | 53 } // namespace device |
59 | 54 |
60 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ | 55 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ |
OLD | NEW |