Index: device/device_sensors/sensor_manager_android.cc |
diff --git a/content/browser/device_sensors/sensor_manager_android.cc b/device/device_sensors/sensor_manager_android.cc |
similarity index 84% |
rename from content/browser/device_sensors/sensor_manager_android.cc |
rename to device/device_sensors/sensor_manager_android.cc |
index f63e45a91ffa16af1a793d70664bce5c71dd3a73..bafec3e2529594c07a40a06317e02b2b5506913d 100644 |
--- a/content/browser/device_sensors/sensor_manager_android.cc |
+++ b/device/device_sensors/sensor_manager_android.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/browser/device_sensors/sensor_manager_android.h" |
+#include "device/device_sensors/sensor_manager_android.h" |
#include <string.h> |
@@ -10,9 +10,9 @@ |
#include "base/bind.h" |
#include "base/memory/singleton.h" |
#include "base/metrics/histogram.h" |
-#include "content/browser/device_sensors/inertial_sensor_consts.h" |
-#include "content/public/browser/browser_thread.h" |
-#include "jni/DeviceSensors_jni.h" |
+#include "device/device_sensors/inertial_sensor_consts.h" |
+//#include "content/public/browser/browser_thread.h" |
+//#include "jni/DeviceSensors_jni.h" |
using base::android::AttachCurrentThread; |
@@ -27,8 +27,7 @@ enum OrientationSensorType { |
void UpdateDeviceOrientationHistogram(OrientationSensorType type) { |
UMA_HISTOGRAM_ENUMERATION("InertialSensor.DeviceOrientationSensorAndroid", |
- type, |
- ORIENTATION_SENSOR_MAX); |
+ type, ORIENTATION_SENSOR_MAX); |
} |
} // namespace |
@@ -59,11 +58,14 @@ bool SensorManagerAndroid::Register(JNIEnv* env) { |
SensorManagerAndroid* SensorManagerAndroid::GetInstance() { |
return Singleton<SensorManagerAndroid, |
- LeakySingletonTraits<SensorManagerAndroid> >::get(); |
+ LeakySingletonTraits<SensorManagerAndroid>>::get(); |
} |
-void SensorManagerAndroid::GotOrientation( |
- JNIEnv*, jobject, double alpha, double beta, double gamma) { |
+void SensorManagerAndroid::GotOrientation(JNIEnv*, |
+ jobject, |
+ double alpha, |
+ double beta, |
+ double gamma) { |
base::AutoLock autolock(orientation_buffer_lock_); |
if (!device_orientation_buffer_) |
@@ -81,12 +83,16 @@ void SensorManagerAndroid::GotOrientation( |
if (!is_orientation_buffer_ready_) { |
SetOrientationBufferReadyStatus(true); |
UpdateDeviceOrientationHistogram(is_using_backup_sensors_for_orientation_ |
- ? ACCELEROMETER_MAGNETIC : ROTATION_VECTOR); |
+ ? ACCELEROMETER_MAGNETIC |
+ : ROTATION_VECTOR); |
} |
} |
-void SensorManagerAndroid::GotAcceleration( |
- JNIEnv*, jobject, double x, double y, double z) { |
+void SensorManagerAndroid::GotAcceleration(JNIEnv*, |
+ jobject, |
+ double x, |
+ double y, |
+ double z) { |
base::AutoLock autolock(motion_buffer_lock_); |
if (!device_motion_buffer_) |
@@ -107,8 +113,11 @@ void SensorManagerAndroid::GotAcceleration( |
} |
} |
-void SensorManagerAndroid::GotAccelerationIncludingGravity( |
- JNIEnv*, jobject, double x, double y, double z) { |
+void SensorManagerAndroid::GotAccelerationIncludingGravity(JNIEnv*, |
+ jobject, |
+ double x, |
+ double y, |
+ double z) { |
base::AutoLock autolock(motion_buffer_lock_); |
if (!device_motion_buffer_) |
@@ -129,8 +138,11 @@ void SensorManagerAndroid::GotAccelerationIncludingGravity( |
} |
} |
-void SensorManagerAndroid::GotRotationRate( |
- JNIEnv*, jobject, double alpha, double beta, double gamma) { |
+void SensorManagerAndroid::GotRotationRate(JNIEnv*, |
+ jobject, |
+ double alpha, |
+ double beta, |
+ double gamma) { |
base::AutoLock autolock(motion_buffer_lock_); |
if (!device_motion_buffer_) |
@@ -167,8 +179,7 @@ bool SensorManagerAndroid::Start(EventType event_type) { |
int rate_in_microseconds = (event_type == kTypeLight) |
? kLightSensorIntervalMicroseconds |
: kInertialSensorIntervalMicroseconds; |
- return Java_DeviceSensors_start(AttachCurrentThread(), |
- device_sensors_.obj(), |
+ return Java_DeviceSensors_start(AttachCurrentThread(), device_sensors_.obj(), |
reinterpret_cast<intptr_t>(this), |
static_cast<jint>(event_type), |
rate_in_microseconds); |
@@ -176,8 +187,7 @@ bool SensorManagerAndroid::Start(EventType event_type) { |
void SensorManagerAndroid::Stop(EventType event_type) { |
DCHECK(!device_sensors_.is_null()); |
- Java_DeviceSensors_stop(AttachCurrentThread(), |
- device_sensors_.obj(), |
+ Java_DeviceSensors_stop(AttachCurrentThread(), device_sensors_.obj(), |
static_cast<jint>(event_type)); |
} |
@@ -205,8 +215,7 @@ bool SensorManagerAndroid::StartFetchingDeviceLightData( |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
base::Bind(&SensorManagerAndroid::StartFetchingLightDataOnUI, |
- base::Unretained(this), |
- buffer)); |
+ base::Unretained(this), buffer)); |
} |
return true; |
} |
@@ -273,8 +282,7 @@ bool SensorManagerAndroid::StartFetchingDeviceMotionData( |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
base::Bind(&SensorManagerAndroid::StartFetchingMotionDataOnUI, |
- base::Unretained(this), |
- buffer)); |
+ base::Unretained(this), buffer)); |
} |
return true; |
} |
@@ -332,8 +340,9 @@ void SensorManagerAndroid::StopFetchingMotionDataOnUI() { |
void SensorManagerAndroid::CheckMotionBufferReadyToRead() { |
if (received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] + |
- received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] + |
- received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] == |
+ received_motion_data_ |
+ [RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] + |
+ received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] == |
number_active_device_motion_sensors_) { |
device_motion_buffer_->seqlock.WriteBegin(); |
device_motion_buffer_->data.interval = |
@@ -341,13 +350,15 @@ void SensorManagerAndroid::CheckMotionBufferReadyToRead() { |
device_motion_buffer_->seqlock.WriteEnd(); |
SetMotionBufferReadyStatus(true); |
- UMA_HISTOGRAM_BOOLEAN("InertialSensor.AccelerometerAndroidAvailable", |
+ UMA_HISTOGRAM_BOOLEAN( |
+ "InertialSensor.AccelerometerAndroidAvailable", |
received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] > 0); |
UMA_HISTOGRAM_BOOLEAN( |
"InertialSensor.AccelerometerIncGravityAndroidAvailable", |
- received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] |
- > 0); |
- UMA_HISTOGRAM_BOOLEAN("InertialSensor.GyroscopeAndroidAvailable", |
+ received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] > |
+ 0); |
+ UMA_HISTOGRAM_BOOLEAN( |
+ "InertialSensor.GyroscopeAndroidAvailable", |
received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] > 0); |
} |
} |
@@ -384,8 +395,7 @@ bool SensorManagerAndroid::StartFetchingDeviceOrientationData( |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
base::Bind(&SensorManagerAndroid::StartFetchingOrientationDataOnUI, |
- base::Unretained(this), |
- buffer)); |
+ base::Unretained(this), buffer)); |
} |
return true; |
} |