Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: device/sensors/data_fetcher_shared_memory_android.cc

Issue 2885203004: Refactor content/renderer/device_sensors to use device/generic_sensor instead of device/sensors (Closed)
Patch Set: updated content/renderer/BUILD.gn Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "device/sensors/data_fetcher_shared_memory.h"
6
7 #include "base/logging.h"
8 #include "device/sensors/public/cpp/device_motion_hardware_buffer.h"
9 #include "device/sensors/public/cpp/device_orientation_hardware_buffer.h"
10 #include "device/sensors/sensor_manager_android.h"
11
12 namespace device {
13
14 DataFetcherSharedMemory::DataFetcherSharedMemory() {}
15
16 DataFetcherSharedMemory::~DataFetcherSharedMemory() {}
17
18 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
19 DCHECK(buffer);
20
21 switch (consumer_type) {
22 case CONSUMER_TYPE_MOTION:
23 SensorManagerAndroid::GetInstance()->StartFetchingDeviceMotionData(
24 static_cast<DeviceMotionHardwareBuffer*>(buffer));
25 return true;
26 case CONSUMER_TYPE_ORIENTATION:
27 SensorManagerAndroid::GetInstance()->StartFetchingDeviceOrientationData(
28 static_cast<DeviceOrientationHardwareBuffer*>(buffer));
29 return true;
30 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE:
31 SensorManagerAndroid::GetInstance()
32 ->StartFetchingDeviceOrientationAbsoluteData(
33 static_cast<DeviceOrientationHardwareBuffer*>(buffer));
34 return true;
35 default:
36 NOTREACHED();
37 }
38 return false;
39 }
40
41 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) {
42 switch (consumer_type) {
43 case CONSUMER_TYPE_MOTION:
44 SensorManagerAndroid::GetInstance()->StopFetchingDeviceMotionData();
45 return true;
46 case CONSUMER_TYPE_ORIENTATION:
47 SensorManagerAndroid::GetInstance()->StopFetchingDeviceOrientationData();
48 return true;
49 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE:
50 SensorManagerAndroid::GetInstance()
51 ->StopFetchingDeviceOrientationAbsoluteData();
52 return true;
53 default:
54 NOTREACHED();
55 }
56 return false;
57 }
58
59 void DataFetcherSharedMemory::Shutdown() {
60 DataFetcherSharedMemoryBase::Shutdown();
61 SensorManagerAndroid::GetInstance()->Shutdown();
62 }
63
64 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698