Chromium Code Reviews| Index: content/browser/device_orientation/accelerometer_mac.cc |
| diff --git a/content/browser/device_orientation/accelerometer_mac.cc b/content/browser/device_orientation/accelerometer_mac.cc |
| index bdc42786f84fe2a0c670e6844057bab7921eef79..13401d675b4c931b8698295bbdb3e564ed451eb7 100644 |
| --- a/content/browser/device_orientation/accelerometer_mac.cc |
| +++ b/content/browser/device_orientation/accelerometer_mac.cc |
| @@ -24,6 +24,16 @@ AccelerometerMac::~AccelerometerMac() { |
| AccelerometerMac::AccelerometerMac() { |
| } |
| +DeviceData* AccelerometerMac::GetDeviceData( |
| + DeviceData::DeviceDataType device_data_type) { |
| + switch (device_data_type()) { |
|
bulach
2012/07/12 10:43:27
nit: since this is not expected to grow, it'd be c
aousterh
2012/07/12 17:13:57
Done.
|
| + case DeviceData::kDeviceOrientationData: |
| + return GetOrientation(); |
| + default: |
| + return NULL; |
| + } |
| +} |
| + |
| // Retrieve per-axis orientation values. |
| // |
| // Axes and angles are defined according to the W3C DeviceOrientation Draft. |
| @@ -33,13 +43,13 @@ AccelerometerMac::AccelerometerMac() { |
| // |
| // Returns false in case of error. |
| // |
| -bool AccelerometerMac::GetOrientation(Orientation* orientation) { |
| +Orientation* AccelerometerMac::GetOrientation() { |
| DCHECK(sudden_motion_sensor_.get()); |
| // Retrieve per-axis calibrated values. |
| float axis_value[3]; |
| if (!sudden_motion_sensor_->ReadSensorValues(axis_value)) |
| - return false; |
| + return NULL; |
| // Transform the accelerometer values to W3C draft angles. |
| // |
| @@ -63,6 +73,8 @@ bool AccelerometerMac::GetOrientation(Orientation* orientation) { |
| // |
| const double kRad2deg = 180.0 / M_PI; |
| + scoped_ptr<Orientation> orientation(new Orientation()); |
| + |
| orientation->set_beta(kRad2deg * atan2(-axis_value[1], axis_value[2])); |
| orientation->set_gamma(kRad2deg * asin(axis_value[0])); |
| // TODO(aousterh): should absolute_ be set to false here? |
| @@ -85,7 +97,7 @@ bool AccelerometerMac::GetOrientation(Orientation* orientation) { |
| DCHECK_GE(orientation->gamma(), -90.0); |
| DCHECK_LT(orientation->gamma(), 90.0); |
| - return true; |
| + return orientation.release(); |
| } |
| bool AccelerometerMac::Init() { |