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_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_WIN_H_ | |
6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_WIN_H_ | |
7 | |
8 #include <SensorsApi.h> | |
9 | |
10 #include "base/win/scoped_comptr.h" | |
11 #include "device/generic_sensor/generic_sensor_export.h" | |
12 #include "device/generic_sensor/platform_sensor_provider.h" | |
13 | |
14 namespace base { | |
15 template <typename T> | |
16 struct DefaultSingletonTraits; | |
17 class Thread; | |
18 } | |
19 | |
20 namespace device { | |
21 | |
22 class PlatformSensorReaderWin; | |
23 | |
24 // Implementation of PlatformSensorProvider for Windows platform. | |
25 // PlatformSensorProviderWin is responsible for following tasks: | |
26 // - Starts sensor thread and stops it when there are no active sensors. | |
27 // - Initialises ISensorManager and creates sensor reader on sensor thread. | |
28 // - Constructs PlatformSensorWin on IPC thread and returns it to requester. | |
29 class DEVICE_GENERIC_SENSOR_EXPORT PlatformSensorProviderWin final | |
30 : public PlatformSensorProvider { | |
31 public: | |
32 static PlatformSensorProviderWin* GetInstance(); | |
33 | |
34 // Overrides ISensorManager COM interface provided by the system, used | |
35 // only for testing purposes. | |
36 void SetSensorManagerForTesing( | |
Lei Zhang
2016/10/29 05:10:42
type: ForTesting
shalamov
2016/10/31 13:12:57
Done.
| |
37 base::win::ScopedComPtr<ISensorManager> sensor_manager); | |
38 | |
39 protected: | |
40 ~PlatformSensorProviderWin() override; | |
41 | |
42 // PlatformSensorProvider interface implementation. | |
43 void AllSensorsRemoved() override; | |
44 void CreateSensorInternal(mojom::SensorType type, | |
45 mojo::ScopedSharedBufferMapping mapping, | |
46 const CreateSensorCallback& callback) override; | |
47 | |
48 private: | |
49 PlatformSensorProviderWin(); | |
Lei Zhang
2016/10/29 05:10:42
separate the ctor for the rest.
shalamov
2016/10/31 13:12:57
Done.
| |
50 bool InitializeSensorManager(); | |
51 bool StartSensorThread(); | |
52 void StopSensorThread(); | |
53 std::unique_ptr<PlatformSensorReaderWin> CreateSensorReader( | |
54 mojom::SensorType type); | |
55 void SensorReaderCreated( | |
56 mojom::SensorType type, | |
57 mojo::ScopedSharedBufferMapping mapping, | |
58 const CreateSensorCallback& callback, | |
59 std::unique_ptr<PlatformSensorReaderWin> sensor_reader); | |
60 | |
61 private: | |
62 friend struct base::DefaultSingletonTraits<PlatformSensorProviderWin>; | |
63 | |
64 base::win::ScopedComPtr<ISensorManager> sensor_manager_; | |
65 std::unique_ptr<base::Thread> sensor_thread_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderWin); | |
68 }; | |
69 | |
70 } // namespace device | |
71 | |
72 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_WIN_H_ | |
OLD | NEW |