OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef DEVICE_SENSORS_PLATFORM_SENSOR_PROVIDER_H_ | |
6 #define DEVICE_SENSORS_PLATFORM_SENSOR_PROVIDER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 | |
10 #include "base/threading/non_thread_safe.h" | |
11 #include "device/generic_sensor/platform_sensor.h" | |
12 | |
13 namespace device { | |
14 | |
15 // Base class that defines factory methods for PlatformSensor creation. | |
16 class PlatformSensorProvider : public base::NonThreadSafe { | |
17 public: | |
18 static PlatformSensorProvider* Create(uint64_t shared_buffer_size); | |
19 | |
20 // Creates new instance of PlatformSensor. | |
21 scoped_refptr<PlatformSensor> CreateSensor(mojom::SensorType type, | |
22 uint64_t size, | |
23 uint64_t offset); | |
24 | |
25 // Gets previously created instance of PlatformSensor by sensor type |type|. | |
26 scoped_refptr<PlatformSensor> GetSensor(mojom::SensorType type); | |
27 | |
28 // Shared buffer getters. | |
29 mojo::ScopedSharedBufferHandle GetClonedSharedBufferHandle(); | |
Reilly Grant (use Gerrit)
2016/08/11 20:59:37
CloneSharedBufferHandle() would be a shorter/clear
Mikhail
2016/08/12 10:21:48
Done.
| |
30 | |
31 protected: | |
32 explicit PlatformSensorProvider(uint64_t shared_buffer_size); | |
33 virtual ~PlatformSensorProvider(); | |
34 | |
35 // Method that must be implemented by platform specific classes. | |
36 virtual scoped_refptr<PlatformSensor> CreateSensor( | |
37 mojom::SensorType type, | |
38 mojo::ScopedSharedBufferMapping mapping, | |
39 uint64_t buffer_size) = 0; | |
Reilly Grant (use Gerrit)
2016/08/11 20:59:37
This overload is definitely confusing. Please name
Mikhail
2016/08/12 10:21:48
Done.
| |
40 | |
41 private: | |
42 bool CreateSharedBufferIfNeeded(); | |
43 | |
44 friend class PlatformSensor; // To call RemoveSensor(); | |
Reilly Grant (use Gerrit)
2016/08/11 20:59:37
Move this line to the top of the private: section.
Mikhail
2016/08/12 10:21:48
Done.
| |
45 void RemoveSensor(mojom::SensorType type); | |
46 | |
47 private: | |
48 using SensorMap = std::map<mojom::SensorType, PlatformSensor*>; | |
Reilly Grant (use Gerrit)
2016/08/11 20:59:37
This typedef is used only once here. Don't worry a
Mikhail
2016/08/12 10:21:48
Done.
| |
49 SensorMap sensor_map_; | |
50 mojo::ScopedSharedBufferHandle shared_buffer_handle_; | |
51 uint64_t shared_buffer_size_; | |
52 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProvider); | |
53 }; | |
54 | |
55 } // namespace device | |
56 | |
57 #endif // DEVICE_SENSORS_PLATFORM_SENSOR_PROVIDER_H_ | |
OLD | NEW |