| 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 "device/sensors/data_fetcher_shared_memory.h" | 5 #include "device/sensors/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> |
| 11 #include <objbase.h> | 11 #include <objbase.h> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/win/iunknown_impl.h" | 16 #include "base/win/iunknown_impl.h" |
| 17 #include "base/win/windows_version.h" | |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 const double kMeanGravity = 9.80665; | 20 const double kMeanGravity = 9.80665; |
| 22 | 21 |
| 23 } // namespace | 22 } // namespace |
| 24 | 23 |
| 25 namespace device { | 24 namespace device { |
| 26 | 25 |
| 27 class DataFetcherSharedMemory::SensorEventSink | 26 class DataFetcherSharedMemory::SensorEventSink |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 default: | 305 default: |
| 307 NOTREACHED(); | 306 NOTREACHED(); |
| 308 } | 307 } |
| 309 return false; | 308 return false; |
| 310 } | 309 } |
| 311 | 310 |
| 312 bool DataFetcherSharedMemory::RegisterForSensor( | 311 bool DataFetcherSharedMemory::RegisterForSensor( |
| 313 REFSENSOR_TYPE_ID sensor_type, | 312 REFSENSOR_TYPE_ID sensor_type, |
| 314 ISensor** sensor, | 313 ISensor** sensor, |
| 315 scoped_refptr<SensorEventSink> event_sink) { | 314 scoped_refptr<SensorEventSink> event_sink) { |
| 316 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 317 return false; | |
| 318 | |
| 319 base::win::ScopedComPtr<ISensorManager> sensor_manager; | 315 base::win::ScopedComPtr<ISensorManager> sensor_manager; |
| 320 HRESULT hr = ::CoCreateInstance(CLSID_SensorManager, nullptr, CLSCTX_ALL, | 316 HRESULT hr = ::CoCreateInstance(CLSID_SensorManager, nullptr, CLSCTX_ALL, |
| 321 IID_PPV_ARGS(&sensor_manager)); | 317 IID_PPV_ARGS(&sensor_manager)); |
| 322 if (FAILED(hr) || !sensor_manager.Get()) | 318 if (FAILED(hr) || !sensor_manager.Get()) |
| 323 return false; | 319 return false; |
| 324 | 320 |
| 325 base::win::ScopedComPtr<ISensorCollection> sensor_collection; | 321 base::win::ScopedComPtr<ISensorCollection> sensor_collection; |
| 326 hr = sensor_manager->GetSensorsByType(sensor_type, | 322 hr = sensor_manager->GetSensorsByType(sensor_type, |
| 327 sensor_collection.GetAddressOf()); | 323 sensor_collection.GetAddressOf()); |
| 328 | 324 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 motion_buffer_->data.all_available_sensors_are_active = enabled; | 412 motion_buffer_->data.all_available_sensors_are_active = enabled; |
| 417 motion_buffer_->seqlock.WriteEnd(); | 413 motion_buffer_->seqlock.WriteEnd(); |
| 418 } | 414 } |
| 419 break; | 415 break; |
| 420 default: | 416 default: |
| 421 NOTREACHED(); | 417 NOTREACHED(); |
| 422 } | 418 } |
| 423 } | 419 } |
| 424 | 420 |
| 425 } // namespace device | 421 } // namespace device |
| OLD | NEW |