OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "data_fetcher_shared_memory.h" | 5 #include "data_fetcher_shared_memory.h" |
6 | 6 |
7 #include <GuidDef.h> | 7 #include <GuidDef.h> |
8 #include <InitGuid.h> | 8 #include <InitGuid.h> |
9 #include <PortableDeviceTypes.h> | 9 #include <PortableDeviceTypes.h> |
10 #include <Sensors.h> | 10 #include <Sensors.h> |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 class DataFetcherSharedMemory::SensorEventSink | 26 class DataFetcherSharedMemory::SensorEventSink |
27 : public ISensorEvents, public base::win::IUnknownImpl { | 27 : public ISensorEvents, public base::win::IUnknownImpl { |
28 public: | 28 public: |
29 SensorEventSink() {} | 29 SensorEventSink() {} |
30 virtual ~SensorEventSink() {} | 30 virtual ~SensorEventSink() {} |
31 | 31 |
32 // IUnknown interface | 32 // IUnknown interface |
33 virtual ULONG STDMETHODCALLTYPE AddRef() OVERRIDE { | 33 virtual ULONG STDMETHODCALLTYPE AddRef() override { |
34 return IUnknownImpl::AddRef(); | 34 return IUnknownImpl::AddRef(); |
35 } | 35 } |
36 | 36 |
37 virtual ULONG STDMETHODCALLTYPE Release() OVERRIDE { | 37 virtual ULONG STDMETHODCALLTYPE Release() override { |
38 return IUnknownImpl::Release(); | 38 return IUnknownImpl::Release(); |
39 } | 39 } |
40 | 40 |
41 virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppv) OVERRIDE { | 41 virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppv) override { |
42 if (riid == __uuidof(ISensorEvents)) { | 42 if (riid == __uuidof(ISensorEvents)) { |
43 *ppv = static_cast<ISensorEvents*>(this); | 43 *ppv = static_cast<ISensorEvents*>(this); |
44 AddRef(); | 44 AddRef(); |
45 return S_OK; | 45 return S_OK; |
46 } | 46 } |
47 return IUnknownImpl::QueryInterface(riid, ppv); | 47 return IUnknownImpl::QueryInterface(riid, ppv); |
48 } | 48 } |
49 | 49 |
50 // ISensorEvents interface | 50 // ISensorEvents interface |
51 STDMETHODIMP OnEvent(ISensor* sensor, | 51 STDMETHODIMP OnEvent(ISensor* sensor, |
52 REFGUID event_id, | 52 REFGUID event_id, |
53 IPortableDeviceValues* event_data) OVERRIDE { | 53 IPortableDeviceValues* event_data) override { |
54 return S_OK; | 54 return S_OK; |
55 } | 55 } |
56 | 56 |
57 STDMETHODIMP OnLeave(REFSENSOR_ID sensor_id) OVERRIDE { | 57 STDMETHODIMP OnLeave(REFSENSOR_ID sensor_id) override { |
58 return S_OK; | 58 return S_OK; |
59 } | 59 } |
60 | 60 |
61 STDMETHODIMP OnStateChanged(ISensor* sensor, SensorState state) OVERRIDE { | 61 STDMETHODIMP OnStateChanged(ISensor* sensor, SensorState state) override { |
62 return S_OK; | 62 return S_OK; |
63 } | 63 } |
64 | 64 |
65 STDMETHODIMP OnDataUpdated(ISensor* sensor, | 65 STDMETHODIMP OnDataUpdated(ISensor* sensor, |
66 ISensorDataReport* new_data) OVERRIDE { | 66 ISensorDataReport* new_data) override { |
67 if (NULL == new_data || NULL == sensor) | 67 if (NULL == new_data || NULL == sensor) |
68 return E_INVALIDARG; | 68 return E_INVALIDARG; |
69 return UpdateSharedMemoryBuffer(sensor, new_data) ? S_OK : E_FAIL; | 69 return UpdateSharedMemoryBuffer(sensor, new_data) ? S_OK : E_FAIL; |
70 } | 70 } |
71 | 71 |
72 protected: | 72 protected: |
73 virtual bool UpdateSharedMemoryBuffer( | 73 virtual bool UpdateSharedMemoryBuffer( |
74 ISensor* sensor, ISensorDataReport* new_data) = 0; | 74 ISensor* sensor, ISensorDataReport* new_data) = 0; |
75 | 75 |
76 void GetSensorValue(REFPROPERTYKEY property, ISensorDataReport* new_data, | 76 void GetSensorValue(REFPROPERTYKEY property, ISensorDataReport* new_data, |
(...skipping 18 matching lines...) Expand all Loading... |
95 | 95 |
96 class DataFetcherSharedMemory::SensorEventSinkOrientation | 96 class DataFetcherSharedMemory::SensorEventSinkOrientation |
97 : public DataFetcherSharedMemory::SensorEventSink { | 97 : public DataFetcherSharedMemory::SensorEventSink { |
98 public: | 98 public: |
99 explicit SensorEventSinkOrientation( | 99 explicit SensorEventSinkOrientation( |
100 DeviceOrientationHardwareBuffer* const buffer) : buffer_(buffer) {} | 100 DeviceOrientationHardwareBuffer* const buffer) : buffer_(buffer) {} |
101 virtual ~SensorEventSinkOrientation() {} | 101 virtual ~SensorEventSinkOrientation() {} |
102 | 102 |
103 protected: | 103 protected: |
104 virtual bool UpdateSharedMemoryBuffer( | 104 virtual bool UpdateSharedMemoryBuffer( |
105 ISensor* sensor, ISensorDataReport* new_data) OVERRIDE { | 105 ISensor* sensor, ISensorDataReport* new_data) override { |
106 double alpha, beta, gamma; | 106 double alpha, beta, gamma; |
107 bool has_alpha, has_beta, has_gamma; | 107 bool has_alpha, has_beta, has_gamma; |
108 | 108 |
109 GetSensorValue(SENSOR_DATA_TYPE_TILT_X_DEGREES, new_data, &alpha, | 109 GetSensorValue(SENSOR_DATA_TYPE_TILT_X_DEGREES, new_data, &alpha, |
110 &has_alpha); | 110 &has_alpha); |
111 GetSensorValue(SENSOR_DATA_TYPE_TILT_Y_DEGREES, new_data, &beta, | 111 GetSensorValue(SENSOR_DATA_TYPE_TILT_Y_DEGREES, new_data, &beta, |
112 &has_beta); | 112 &has_beta); |
113 GetSensorValue(SENSOR_DATA_TYPE_TILT_Z_DEGREES, new_data, &gamma, | 113 GetSensorValue(SENSOR_DATA_TYPE_TILT_Z_DEGREES, new_data, &gamma, |
114 &has_gamma); | 114 &has_gamma); |
115 | 115 |
(...skipping 22 matching lines...) Expand all Loading... |
138 | 138 |
139 class DataFetcherSharedMemory::SensorEventSinkMotion | 139 class DataFetcherSharedMemory::SensorEventSinkMotion |
140 : public DataFetcherSharedMemory::SensorEventSink { | 140 : public DataFetcherSharedMemory::SensorEventSink { |
141 public: | 141 public: |
142 explicit SensorEventSinkMotion(DeviceMotionHardwareBuffer* const buffer) | 142 explicit SensorEventSinkMotion(DeviceMotionHardwareBuffer* const buffer) |
143 : buffer_(buffer) {} | 143 : buffer_(buffer) {} |
144 virtual ~SensorEventSinkMotion() {} | 144 virtual ~SensorEventSinkMotion() {} |
145 | 145 |
146 protected: | 146 protected: |
147 virtual bool UpdateSharedMemoryBuffer( | 147 virtual bool UpdateSharedMemoryBuffer( |
148 ISensor* sensor, ISensorDataReport* new_data) OVERRIDE { | 148 ISensor* sensor, ISensorDataReport* new_data) override { |
149 | 149 |
150 SENSOR_TYPE_ID sensor_type = GUID_NULL; | 150 SENSOR_TYPE_ID sensor_type = GUID_NULL; |
151 if (!SUCCEEDED(sensor->GetType(&sensor_type))) | 151 if (!SUCCEEDED(sensor->GetType(&sensor_type))) |
152 return false; | 152 return false; |
153 | 153 |
154 if (IsEqualIID(sensor_type, SENSOR_TYPE_ACCELEROMETER_3D)) { | 154 if (IsEqualIID(sensor_type, SENSOR_TYPE_ACCELEROMETER_3D)) { |
155 double acceleration_including_gravity_x; | 155 double acceleration_including_gravity_x; |
156 double acceleration_including_gravity_y; | 156 double acceleration_including_gravity_y; |
157 double acceleration_including_gravity_z; | 157 double acceleration_including_gravity_z; |
158 bool has_acceleration_including_gravity_x; | 158 bool has_acceleration_including_gravity_x; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 motion_buffer_->data.allAvailableSensorsAreActive = enabled; | 391 motion_buffer_->data.allAvailableSensorsAreActive = enabled; |
392 motion_buffer_->seqlock.WriteEnd(); | 392 motion_buffer_->seqlock.WriteEnd(); |
393 } | 393 } |
394 break; | 394 break; |
395 default: | 395 default: |
396 NOTREACHED(); | 396 NOTREACHED(); |
397 } | 397 } |
398 } | 398 } |
399 | 399 |
400 } // namespace content | 400 } // namespace content |
OLD | NEW |