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