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

Side by Side Diff: content/browser/device_orientation/accelerometer_mac.cc

Issue 10755002: Refactors DeviceOrientation to make it more extensible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_orientation/accelerometer_mac.h" 5 #include "content/browser/device_orientation/accelerometer_mac.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/device_orientation/orientation.h" 10 #include "content/browser/device_orientation/orientation.h"
11 #include "third_party/sudden_motion_sensor/sudden_motion_sensor_mac.h" 11 #include "third_party/sudden_motion_sensor/sudden_motion_sensor_mac.h"
12 12
13 namespace device_orientation { 13 namespace device_orientation {
14 14
15 // Create a AccelerometerMac object and return NULL if no valid sensor found. 15 // Create a AccelerometerMac object and return NULL if no valid sensor found.
16 DataFetcher* AccelerometerMac::Create() { 16 DataFetcher* AccelerometerMac::Create() {
17 scoped_ptr<AccelerometerMac> accelerometer(new AccelerometerMac); 17 scoped_ptr<AccelerometerMac> accelerometer(new AccelerometerMac);
18 return accelerometer->Init() ? accelerometer.release() : NULL; 18 return accelerometer->Init() ? accelerometer.release() : NULL;
19 } 19 }
20 20
21 AccelerometerMac::~AccelerometerMac() { 21 AccelerometerMac::~AccelerometerMac() {
22 } 22 }
23 23
24 AccelerometerMac::AccelerometerMac() { 24 AccelerometerMac::AccelerometerMac() {
25 } 25 }
26 26
27 bool AccelerometerMac::GetDeviceData(DeviceData* device_data) {
28 switch (device_data->device_data_type()) {
29 case DeviceData::kDeviceOrientationData:
30 return GetOrientation(static_cast<Orientation*>(device_data));
31 default:
32 return false;
33 }
34 }
35
27 // Retrieve per-axis orientation values. 36 // Retrieve per-axis orientation values.
28 // 37 //
29 // Axes and angles are defined according to the W3C DeviceOrientation Draft. 38 // Axes and angles are defined according to the W3C DeviceOrientation Draft.
30 // See here: http://dev.w3.org/geo/api/spec-source-orientation.html 39 // See here: http://dev.w3.org/geo/api/spec-source-orientation.html
31 // 40 //
32 // Note: only beta and gamma angles are provided. Alpha is set to zero. 41 // Note: only beta and gamma angles are provided. Alpha is set to zero.
33 // 42 //
34 // Returns false in case of error. 43 // Returns false in case of error.
35 // 44 //
36 bool AccelerometerMac::GetOrientation(Orientation* orientation) { 45 bool AccelerometerMac::GetOrientation(Orientation* orientation) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 96
88 return true; 97 return true;
89 } 98 }
90 99
91 bool AccelerometerMac::Init() { 100 bool AccelerometerMac::Init() {
92 sudden_motion_sensor_.reset(SuddenMotionSensor::Create()); 101 sudden_motion_sensor_.reset(SuddenMotionSensor::Create());
93 return sudden_motion_sensor_.get() != NULL; 102 return sudden_motion_sensor_.get() != NULL;
94 } 103 }
95 104
96 } // namespace device_orientation 105 } // namespace device_orientation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698