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

Side by Side Diff: content/browser/device_sensors/data_fetcher_shared_memory_android.cc

Issue 292693004: [DeviceLight] Browser+java part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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
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 "content/browser/device_sensors/data_fetcher_shared_memory.h" 5 #include "content/browser/device_sensors/data_fetcher_shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/device_sensors/sensor_manager_android.h" 8 #include "content/browser/device_sensors/sensor_manager_android.h"
9 #include "content/common/device_sensors/device_light_hardware_buffer.h"
9 #include "content/common/device_sensors/device_motion_hardware_buffer.h" 10 #include "content/common/device_sensors/device_motion_hardware_buffer.h"
10 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" 11 #include "content/common/device_sensors/device_orientation_hardware_buffer.h"
11 12
12 namespace content { 13 namespace content {
13 14
14 DataFetcherSharedMemory::DataFetcherSharedMemory() { 15 DataFetcherSharedMemory::DataFetcherSharedMemory() {
15 } 16 }
16 17
17 DataFetcherSharedMemory::~DataFetcherSharedMemory() { 18 DataFetcherSharedMemory::~DataFetcherSharedMemory() {
18 } 19 }
19 20
20 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { 21 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
21 DCHECK(buffer); 22 DCHECK(buffer);
22 23
23 switch (consumer_type) { 24 switch (consumer_type) {
24 case CONSUMER_TYPE_MOTION: 25 case CONSUMER_TYPE_MOTION:
25 return SensorManagerAndroid::GetInstance()-> 26 return SensorManagerAndroid::GetInstance()->
26 StartFetchingDeviceMotionData( 27 StartFetchingDeviceMotionData(
27 static_cast<DeviceMotionHardwareBuffer*>(buffer)); 28 static_cast<DeviceMotionHardwareBuffer*>(buffer));
28 case CONSUMER_TYPE_ORIENTATION: 29 case CONSUMER_TYPE_ORIENTATION:
29 return SensorManagerAndroid::GetInstance()-> 30 return SensorManagerAndroid::GetInstance()->
30 StartFetchingDeviceOrientationData( 31 StartFetchingDeviceOrientationData(
31 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); 32 static_cast<DeviceOrientationHardwareBuffer*>(buffer));
33 case CONSUMER_TYPE_LIGHT:
34 return SensorManagerAndroid::GetInstance()->StartFetchingDeviceLightData(
35 static_cast<DeviceLightHardwareBuffer*>(buffer));
32 default: 36 default:
33 NOTREACHED(); 37 NOTREACHED();
34 } 38 }
35 return false; 39 return false;
36 } 40 }
37 41
38 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { 42 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) {
39 switch (consumer_type) { 43 switch (consumer_type) {
40 case CONSUMER_TYPE_MOTION: 44 case CONSUMER_TYPE_MOTION:
41 SensorManagerAndroid::GetInstance()->StopFetchingDeviceMotionData(); 45 SensorManagerAndroid::GetInstance()->StopFetchingDeviceMotionData();
42 return true; 46 return true;
43 case CONSUMER_TYPE_ORIENTATION: 47 case CONSUMER_TYPE_ORIENTATION:
44 SensorManagerAndroid::GetInstance()->StopFetchingDeviceOrientationData(); 48 SensorManagerAndroid::GetInstance()->StopFetchingDeviceOrientationData();
45 return true; 49 return true;
50 case CONSUMER_TYPE_LIGHT:
51 SensorManagerAndroid::GetInstance()->StopFetchingDeviceLightData();
52 return true;
46 default: 53 default:
47 NOTREACHED(); 54 NOTREACHED();
48 } 55 }
49 return false; 56 return false;
50 } 57 }
51 58
52 } // namespace content 59 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698