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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "device/sensors/public/cpp/device_light_hardware_buffer.h" | |
9 #include "device/sensors/public/cpp/device_motion_hardware_buffer.h" | 8 #include "device/sensors/public/cpp/device_motion_hardware_buffer.h" |
10 #include "device/sensors/public/cpp/device_orientation_hardware_buffer.h" | 9 #include "device/sensors/public/cpp/device_orientation_hardware_buffer.h" |
11 #include "device/sensors/sensor_manager_android.h" | 10 #include "device/sensors/sensor_manager_android.h" |
12 | 11 |
13 namespace device { | 12 namespace device { |
14 | 13 |
15 DataFetcherSharedMemory::DataFetcherSharedMemory() {} | 14 DataFetcherSharedMemory::DataFetcherSharedMemory() {} |
16 | 15 |
17 DataFetcherSharedMemory::~DataFetcherSharedMemory() {} | 16 DataFetcherSharedMemory::~DataFetcherSharedMemory() {} |
18 | 17 |
19 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { | 18 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { |
20 DCHECK(buffer); | 19 DCHECK(buffer); |
21 | 20 |
22 switch (consumer_type) { | 21 switch (consumer_type) { |
23 case CONSUMER_TYPE_MOTION: | 22 case CONSUMER_TYPE_MOTION: |
24 SensorManagerAndroid::GetInstance()->StartFetchingDeviceMotionData( | 23 SensorManagerAndroid::GetInstance()->StartFetchingDeviceMotionData( |
25 static_cast<DeviceMotionHardwareBuffer*>(buffer)); | 24 static_cast<DeviceMotionHardwareBuffer*>(buffer)); |
26 return true; | 25 return true; |
27 case CONSUMER_TYPE_ORIENTATION: | 26 case CONSUMER_TYPE_ORIENTATION: |
28 SensorManagerAndroid::GetInstance()->StartFetchingDeviceOrientationData( | 27 SensorManagerAndroid::GetInstance()->StartFetchingDeviceOrientationData( |
29 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); | 28 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); |
30 return true; | 29 return true; |
31 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: | 30 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: |
32 SensorManagerAndroid::GetInstance() | 31 SensorManagerAndroid::GetInstance() |
33 ->StartFetchingDeviceOrientationAbsoluteData( | 32 ->StartFetchingDeviceOrientationAbsoluteData( |
34 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); | 33 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); |
35 return true; | 34 return true; |
36 case CONSUMER_TYPE_LIGHT: | |
37 SensorManagerAndroid::GetInstance()->StartFetchingDeviceLightData( | |
38 static_cast<DeviceLightHardwareBuffer*>(buffer)); | |
39 return true; | |
40 default: | 35 default: |
41 NOTREACHED(); | 36 NOTREACHED(); |
42 } | 37 } |
43 return false; | 38 return false; |
44 } | 39 } |
45 | 40 |
46 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { | 41 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { |
47 switch (consumer_type) { | 42 switch (consumer_type) { |
48 case CONSUMER_TYPE_MOTION: | 43 case CONSUMER_TYPE_MOTION: |
49 SensorManagerAndroid::GetInstance()->StopFetchingDeviceMotionData(); | 44 SensorManagerAndroid::GetInstance()->StopFetchingDeviceMotionData(); |
50 return true; | 45 return true; |
51 case CONSUMER_TYPE_ORIENTATION: | 46 case CONSUMER_TYPE_ORIENTATION: |
52 SensorManagerAndroid::GetInstance()->StopFetchingDeviceOrientationData(); | 47 SensorManagerAndroid::GetInstance()->StopFetchingDeviceOrientationData(); |
53 return true; | 48 return true; |
54 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: | 49 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: |
55 SensorManagerAndroid::GetInstance() | 50 SensorManagerAndroid::GetInstance() |
56 ->StopFetchingDeviceOrientationAbsoluteData(); | 51 ->StopFetchingDeviceOrientationAbsoluteData(); |
57 return true; | 52 return true; |
58 case CONSUMER_TYPE_LIGHT: | |
59 SensorManagerAndroid::GetInstance()->StopFetchingDeviceLightData(); | |
60 return true; | |
61 default: | 53 default: |
62 NOTREACHED(); | 54 NOTREACHED(); |
63 } | 55 } |
64 return false; | 56 return false; |
65 } | 57 } |
66 | 58 |
67 void DataFetcherSharedMemory::Shutdown() { | 59 void DataFetcherSharedMemory::Shutdown() { |
68 DataFetcherSharedMemoryBase::Shutdown(); | 60 DataFetcherSharedMemoryBase::Shutdown(); |
69 SensorManagerAndroid::GetInstance()->Shutdown(); | 61 SensorManagerAndroid::GetInstance()->Shutdown(); |
70 } | 62 } |
71 | 63 |
72 } // namespace device | 64 } // namespace device |
OLD | NEW |