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_READER_WIN_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_WIN_H_ |
6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_WIN_H_ | 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_WIN_H_ |
7 | 7 |
8 #include <SensorsApi.h> | 8 #include <SensorsApi.h> |
9 | 9 |
10 #include "base/win/scoped_comptr.h" | 10 #include "base/win/scoped_comptr.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 private: | 49 private: |
50 PlatformSensorReaderWin(base::win::ScopedComPtr<ISensor> sensor, | 50 PlatformSensorReaderWin(base::win::ScopedComPtr<ISensor> sensor, |
51 std::unique_ptr<ReaderInitParams> params); | 51 std::unique_ptr<ReaderInitParams> params); |
52 | 52 |
53 static base::win::ScopedComPtr<ISensor> GetSensorForType( | 53 static base::win::ScopedComPtr<ISensor> GetSensorForType( |
54 REFSENSOR_TYPE_ID sensor_type, | 54 REFSENSOR_TYPE_ID sensor_type, |
55 base::win::ScopedComPtr<ISensorManager> sensor_manager); | 55 base::win::ScopedComPtr<ISensorManager> sensor_manager); |
56 | 56 |
57 bool SetReportingInterval(const PlatformSensorConfiguration& configuration); | 57 bool SetReportingInterval(const PlatformSensorConfiguration& configuration); |
| 58 void ListenSensorEvent(); |
58 HRESULT SensorReadingChanged(ISensorDataReport& report, | 59 HRESULT SensorReadingChanged(ISensorDataReport& report, |
59 SensorReading& reading) const; | 60 SensorReading& reading) const; |
60 void SensorError(); | 61 void SensorError(); |
61 | 62 |
62 private: | 63 private: |
63 friend class EventListener; | 64 friend class EventListener; |
64 | 65 |
65 const std::unique_ptr<ReaderInitParams> init_params_; | 66 const std::unique_ptr<ReaderInitParams> init_params_; |
66 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 67 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
67 // Following class members are protected by lock, because SetClient, | 68 // Following class members are protected by lock, because SetClient, |
68 // StartSensor and StopSensor are called from another thread by | 69 // StartSensor and StopSensor are called from another thread by |
69 // PlatformSensorWin that can modify internal state of the object. | 70 // PlatformSensorWin that can modify internal state of the object. |
70 base::Lock lock_; | 71 base::Lock lock_; |
71 bool sensor_active_; | 72 bool sensor_active_; |
72 Client* client_; | 73 Client* client_; |
73 base::win::ScopedComPtr<ISensor> sensor_; | 74 base::win::ScopedComPtr<ISensor> sensor_; |
74 scoped_refptr<EventListener> event_listener_; | 75 scoped_refptr<EventListener> event_listener_; |
| 76 base::WeakPtrFactory<PlatformSensorReaderWin> weak_factory_; |
75 | 77 |
76 DISALLOW_COPY_AND_ASSIGN(PlatformSensorReaderWin); | 78 DISALLOW_COPY_AND_ASSIGN(PlatformSensorReaderWin); |
77 }; | 79 }; |
78 | 80 |
79 } // namespace device | 81 } // namespace device |
80 | 82 |
81 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_WIN_H_ | 83 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_WIN_H_ |
OLD | NEW |