Android: rename DataFetcherImplAndroid -> SensorManagerAndroid.

Renamed all occurences of DataFetcherImplAndroid to SensorManagerAndroid
to better reflect current implementation of Device Motion/Orientation.
Also the relevant tests and files have been renamed in this patch.

BUG=334342

Review URL: https://codereview.chromium.org/137853006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251367 0039d316-1c4b-4281-b951-d872f2087c98
parent c62ed3ea
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "content/browser/android/surface_texture_peer_browser_impl.h" #include "content/browser/android/surface_texture_peer_browser_impl.h"
#include "content/browser/android/tracing_controller_android.h" #include "content/browser/android/tracing_controller_android.h"
#include "content/browser/android/web_contents_observer_android.h" #include "content/browser/android/web_contents_observer_android.h"
#include "content/browser/device_orientation/data_fetcher_impl_android.h" #include "content/browser/device_orientation/sensor_manager_android.h"
#include "content/browser/frame_host/navigation_controller_android.h" #include "content/browser/frame_host/navigation_controller_android.h"
#include "content/browser/geolocation/location_api_adapter_android.h" #include "content/browser/geolocation/location_api_adapter_android.h"
#include "content/browser/media/android/media_drm_credential_manager.h" #include "content/browser/media/android/media_drm_credential_manager.h"
...@@ -51,7 +51,6 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = { ...@@ -51,7 +51,6 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
content::ContentViewRenderView::RegisterContentViewRenderView}, content::ContentViewRenderView::RegisterContentViewRenderView},
{"ContentVideoView", content::ContentVideoView::RegisterContentVideoView}, {"ContentVideoView", content::ContentVideoView::RegisterContentVideoView},
{"ContentViewCore", content::RegisterContentViewCore}, {"ContentViewCore", content::RegisterContentViewCore},
{"DataFetcherImplAndroid", content::DataFetcherImplAndroid::Register},
{"DateTimePickerAndroid", content::RegisterDateTimeChooserAndroid}, {"DateTimePickerAndroid", content::RegisterDateTimeChooserAndroid},
{"DownloadControllerAndroidImpl", {"DownloadControllerAndroidImpl",
content::DownloadControllerAndroidImpl::RegisterDownloadController}, content::DownloadControllerAndroidImpl::RegisterDownloadController},
...@@ -69,6 +68,7 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = { ...@@ -69,6 +68,7 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
content::NavigationControllerAndroid::Register}, content::NavigationControllerAndroid::Register},
{"PowerSaveBlock", content::RegisterPowerSaveBlocker}, {"PowerSaveBlock", content::RegisterPowerSaveBlocker},
{"RegisterImeAdapter", content::RegisterImeAdapter}, {"RegisterImeAdapter", content::RegisterImeAdapter},
{"SensorManagerAndroid", content::SensorManagerAndroid::Register},
{"SpeechRecognizerImplAndroid", {"SpeechRecognizerImplAndroid",
content::SpeechRecognizerImplAndroid::RegisterSpeechRecognizer}, content::SpeechRecognizerImplAndroid::RegisterSpeechRecognizer},
{"TouchEventSynthesizer", {"TouchEventSynthesizer",
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "content/browser/device_orientation/data_fetcher_shared_memory.h" #include "content/browser/device_orientation/data_fetcher_shared_memory.h"
#include "base/logging.h" #include "base/logging.h"
#include "content/browser/device_orientation/data_fetcher_impl_android.h" #include "content/browser/device_orientation/sensor_manager_android.h"
#include "content/common/device_orientation/device_motion_hardware_buffer.h" #include "content/common/device_orientation/device_motion_hardware_buffer.h"
#include "content/common/device_orientation/device_orientation_hardware_buffer.h" #include "content/common/device_orientation/device_orientation_hardware_buffer.h"
...@@ -22,11 +22,11 @@ bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { ...@@ -22,11 +22,11 @@ bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
switch (consumer_type) { switch (consumer_type) {
case CONSUMER_TYPE_MOTION: case CONSUMER_TYPE_MOTION:
return DataFetcherImplAndroid::GetInstance()-> return SensorManagerAndroid::GetInstance()->
StartFetchingDeviceMotionData( StartFetchingDeviceMotionData(
static_cast<DeviceMotionHardwareBuffer*>(buffer)); static_cast<DeviceMotionHardwareBuffer*>(buffer));
case CONSUMER_TYPE_ORIENTATION: case CONSUMER_TYPE_ORIENTATION:
return DataFetcherImplAndroid::GetInstance()-> return SensorManagerAndroid::GetInstance()->
StartFetchingDeviceOrientationData( StartFetchingDeviceOrientationData(
static_cast<DeviceOrientationHardwareBuffer*>(buffer)); static_cast<DeviceOrientationHardwareBuffer*>(buffer));
default: default:
...@@ -38,11 +38,10 @@ bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { ...@@ -38,11 +38,10 @@ bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) {
switch (consumer_type) { switch (consumer_type) {
case CONSUMER_TYPE_MOTION: case CONSUMER_TYPE_MOTION:
DataFetcherImplAndroid::GetInstance()->StopFetchingDeviceMotionData(); SensorManagerAndroid::GetInstance()->StopFetchingDeviceMotionData();
return true; return true;
case CONSUMER_TYPE_ORIENTATION: case CONSUMER_TYPE_ORIENTATION:
DataFetcherImplAndroid::GetInstance()-> SensorManagerAndroid::GetInstance()->StopFetchingDeviceOrientationData();
StopFetchingDeviceOrientationData();
return true; return true;
default: default:
NOTREACHED(); NOTREACHED();
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/device_orientation/data_fetcher_impl_android.h" #include "content/browser/device_orientation/sensor_manager_android.h"
#include <string.h> #include <string.h>
...@@ -24,7 +24,7 @@ static void updateRotationVectorHistogram(bool value) { ...@@ -24,7 +24,7 @@ static void updateRotationVectorHistogram(bool value) {
namespace content { namespace content {
DataFetcherImplAndroid::DataFetcherImplAndroid() SensorManagerAndroid::SensorManagerAndroid()
: number_active_device_motion_sensors_(0), : number_active_device_motion_sensors_(0),
device_motion_buffer_(NULL), device_motion_buffer_(NULL),
device_orientation_buffer_(NULL), device_orientation_buffer_(NULL),
...@@ -35,19 +35,19 @@ DataFetcherImplAndroid::DataFetcherImplAndroid() ...@@ -35,19 +35,19 @@ DataFetcherImplAndroid::DataFetcherImplAndroid()
Java_DeviceMotionAndOrientation_getInstance(AttachCurrentThread())); Java_DeviceMotionAndOrientation_getInstance(AttachCurrentThread()));
} }
DataFetcherImplAndroid::~DataFetcherImplAndroid() { SensorManagerAndroid::~SensorManagerAndroid() {
} }
bool DataFetcherImplAndroid::Register(JNIEnv* env) { bool SensorManagerAndroid::Register(JNIEnv* env) {
return RegisterNativesImpl(env); return RegisterNativesImpl(env);
} }
DataFetcherImplAndroid* DataFetcherImplAndroid::GetInstance() { SensorManagerAndroid* SensorManagerAndroid::GetInstance() {
return Singleton<DataFetcherImplAndroid, return Singleton<SensorManagerAndroid,
LeakySingletonTraits<DataFetcherImplAndroid> >::get(); LeakySingletonTraits<SensorManagerAndroid> >::get();
} }
void DataFetcherImplAndroid::GotOrientation( void SensorManagerAndroid::GotOrientation(
JNIEnv*, jobject, double alpha, double beta, double gamma) { JNIEnv*, jobject, double alpha, double beta, double gamma) {
base::AutoLock autolock(orientation_buffer_lock_); base::AutoLock autolock(orientation_buffer_lock_);
...@@ -69,7 +69,7 @@ void DataFetcherImplAndroid::GotOrientation( ...@@ -69,7 +69,7 @@ void DataFetcherImplAndroid::GotOrientation(
} }
} }
void DataFetcherImplAndroid::GotAcceleration( void SensorManagerAndroid::GotAcceleration(
JNIEnv*, jobject, double x, double y, double z) { JNIEnv*, jobject, double x, double y, double z) {
base::AutoLock autolock(motion_buffer_lock_); base::AutoLock autolock(motion_buffer_lock_);
...@@ -91,7 +91,7 @@ void DataFetcherImplAndroid::GotAcceleration( ...@@ -91,7 +91,7 @@ void DataFetcherImplAndroid::GotAcceleration(
} }
} }
void DataFetcherImplAndroid::GotAccelerationIncludingGravity( void SensorManagerAndroid::GotAccelerationIncludingGravity(
JNIEnv*, jobject, double x, double y, double z) { JNIEnv*, jobject, double x, double y, double z) {
base::AutoLock autolock(motion_buffer_lock_); base::AutoLock autolock(motion_buffer_lock_);
...@@ -113,7 +113,7 @@ void DataFetcherImplAndroid::GotAccelerationIncludingGravity( ...@@ -113,7 +113,7 @@ void DataFetcherImplAndroid::GotAccelerationIncludingGravity(
} }
} }
void DataFetcherImplAndroid::GotRotationRate( void SensorManagerAndroid::GotRotationRate(
JNIEnv*, jobject, double alpha, double beta, double gamma) { JNIEnv*, jobject, double alpha, double beta, double gamma) {
base::AutoLock autolock(motion_buffer_lock_); base::AutoLock autolock(motion_buffer_lock_);
...@@ -135,7 +135,7 @@ void DataFetcherImplAndroid::GotRotationRate( ...@@ -135,7 +135,7 @@ void DataFetcherImplAndroid::GotRotationRate(
} }
} }
bool DataFetcherImplAndroid::Start(EventType event_type) { bool SensorManagerAndroid::Start(EventType event_type) {
DCHECK(!device_orientation_.is_null()); DCHECK(!device_orientation_.is_null());
return Java_DeviceMotionAndOrientation_start( return Java_DeviceMotionAndOrientation_start(
AttachCurrentThread(), device_orientation_.obj(), AttachCurrentThread(), device_orientation_.obj(),
...@@ -143,14 +143,14 @@ bool DataFetcherImplAndroid::Start(EventType event_type) { ...@@ -143,14 +143,14 @@ bool DataFetcherImplAndroid::Start(EventType event_type) {
kInertialSensorIntervalMillis); kInertialSensorIntervalMillis);
} }
void DataFetcherImplAndroid::Stop(EventType event_type) { void SensorManagerAndroid::Stop(EventType event_type) {
DCHECK(!device_orientation_.is_null()); DCHECK(!device_orientation_.is_null());
Java_DeviceMotionAndOrientation_stop( Java_DeviceMotionAndOrientation_stop(
AttachCurrentThread(), device_orientation_.obj(), AttachCurrentThread(), device_orientation_.obj(),
static_cast<jint>(event_type)); static_cast<jint>(event_type));
} }
int DataFetcherImplAndroid::GetNumberActiveDeviceMotionSensors() { int SensorManagerAndroid::GetNumberActiveDeviceMotionSensors() {
DCHECK(!device_orientation_.is_null()); DCHECK(!device_orientation_.is_null());
return Java_DeviceMotionAndOrientation_getNumberActiveDeviceMotionSensors( return Java_DeviceMotionAndOrientation_getNumberActiveDeviceMotionSensors(
AttachCurrentThread(), device_orientation_.obj()); AttachCurrentThread(), device_orientation_.obj());
...@@ -161,7 +161,7 @@ int DataFetcherImplAndroid::GetNumberActiveDeviceMotionSensors() { ...@@ -161,7 +161,7 @@ int DataFetcherImplAndroid::GetNumberActiveDeviceMotionSensors() {
// --- Device Motion // --- Device Motion
bool DataFetcherImplAndroid::StartFetchingDeviceMotionData( bool SensorManagerAndroid::StartFetchingDeviceMotionData(
DeviceMotionHardwareBuffer* buffer) { DeviceMotionHardwareBuffer* buffer) {
DCHECK(buffer); DCHECK(buffer);
{ {
...@@ -182,7 +182,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceMotionData( ...@@ -182,7 +182,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceMotionData(
return success; return success;
} }
void DataFetcherImplAndroid::StopFetchingDeviceMotionData() { void SensorManagerAndroid::StopFetchingDeviceMotionData() {
Stop(kTypeMotion); Stop(kTypeMotion);
{ {
base::AutoLock autolock(motion_buffer_lock_); base::AutoLock autolock(motion_buffer_lock_);
...@@ -193,7 +193,7 @@ void DataFetcherImplAndroid::StopFetchingDeviceMotionData() { ...@@ -193,7 +193,7 @@ void DataFetcherImplAndroid::StopFetchingDeviceMotionData() {
} }
} }
void DataFetcherImplAndroid::CheckMotionBufferReadyToRead() { void SensorManagerAndroid::CheckMotionBufferReadyToRead() {
if (received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] + if (received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] +
received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] + received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] +
received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] == received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] ==
...@@ -214,14 +214,14 @@ void DataFetcherImplAndroid::CheckMotionBufferReadyToRead() { ...@@ -214,14 +214,14 @@ void DataFetcherImplAndroid::CheckMotionBufferReadyToRead() {
} }
} }
void DataFetcherImplAndroid::SetMotionBufferReadyStatus(bool ready) { void SensorManagerAndroid::SetMotionBufferReadyStatus(bool ready) {
device_motion_buffer_->seqlock.WriteBegin(); device_motion_buffer_->seqlock.WriteBegin();
device_motion_buffer_->data.allAvailableSensorsAreActive = ready; device_motion_buffer_->data.allAvailableSensorsAreActive = ready;
device_motion_buffer_->seqlock.WriteEnd(); device_motion_buffer_->seqlock.WriteEnd();
is_motion_buffer_ready_ = ready; is_motion_buffer_ready_ = ready;
} }
void DataFetcherImplAndroid::ClearInternalMotionBuffers() { void SensorManagerAndroid::ClearInternalMotionBuffers() {
memset(received_motion_data_, 0, sizeof(received_motion_data_)); memset(received_motion_data_, 0, sizeof(received_motion_data_));
number_active_device_motion_sensors_ = 0; number_active_device_motion_sensors_ = 0;
SetMotionBufferReadyStatus(false); SetMotionBufferReadyStatus(false);
...@@ -229,7 +229,7 @@ void DataFetcherImplAndroid::ClearInternalMotionBuffers() { ...@@ -229,7 +229,7 @@ void DataFetcherImplAndroid::ClearInternalMotionBuffers() {
// --- Device Orientation // --- Device Orientation
void DataFetcherImplAndroid::SetOrientationBufferReadyStatus(bool ready) { void SensorManagerAndroid::SetOrientationBufferReadyStatus(bool ready) {
device_orientation_buffer_->seqlock.WriteBegin(); device_orientation_buffer_->seqlock.WriteBegin();
device_orientation_buffer_->data.absolute = ready; device_orientation_buffer_->data.absolute = ready;
device_orientation_buffer_->data.hasAbsolute = ready; device_orientation_buffer_->data.hasAbsolute = ready;
...@@ -238,7 +238,7 @@ void DataFetcherImplAndroid::SetOrientationBufferReadyStatus(bool ready) { ...@@ -238,7 +238,7 @@ void DataFetcherImplAndroid::SetOrientationBufferReadyStatus(bool ready) {
is_orientation_buffer_ready_ = ready; is_orientation_buffer_ready_ = ready;
} }
bool DataFetcherImplAndroid::StartFetchingDeviceOrientationData( bool SensorManagerAndroid::StartFetchingDeviceOrientationData(
DeviceOrientationHardwareBuffer* buffer) { DeviceOrientationHardwareBuffer* buffer) {
DCHECK(buffer); DCHECK(buffer);
{ {
...@@ -260,7 +260,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceOrientationData( ...@@ -260,7 +260,7 @@ bool DataFetcherImplAndroid::StartFetchingDeviceOrientationData(
return success; return success;
} }
void DataFetcherImplAndroid::StopFetchingDeviceOrientationData() { void SensorManagerAndroid::StopFetchingDeviceOrientationData() {
Stop(kTypeOrientation); Stop(kTypeOrientation);
{ {
base::AutoLock autolock(orientation_buffer_lock_); base::AutoLock autolock(orientation_buffer_lock_);
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_SENSOR_MANAGER_ANDROID_H_
#define CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ #define CHROME_BROWSER_DEVICE_ORIENTATION_SENSOR_MANAGER_ANDROID_H_
#include "base/android/scoped_java_ref.h" #include "base/android/scoped_java_ref.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -21,16 +21,13 @@ namespace content { ...@@ -21,16 +21,13 @@ namespace content {
// Android's SensorManager has a push API, so when Got*() methods are called // Android's SensorManager has a push API, so when Got*() methods are called
// by the system the browser process puts the received data into a shared // by the system the browser process puts the received data into a shared
// memory buffer, which is read by the renderer processes. // memory buffer, which is read by the renderer processes.
// class CONTENT_EXPORT SensorManagerAndroid {
// TODO(timvolodine): rename this class to SensorManagerAndroid.
class CONTENT_EXPORT DataFetcherImplAndroid {
public: public:
// Must be called at startup, before GetInstance(). // Must be called at startup, before GetInstance().
static bool Register(JNIEnv* env); static bool Register(JNIEnv* env);
// Needs to be thread-safe, because accessed from different threads. // Needs to be thread-safe, because accessed from different threads.
static DataFetcherImplAndroid* GetInstance(); static SensorManagerAndroid* GetInstance();
// Called from Java via JNI. // Called from Java via JNI.
void GotOrientation(JNIEnv*, jobject, void GotOrientation(JNIEnv*, jobject,
...@@ -59,15 +56,15 @@ class CONTENT_EXPORT DataFetcherImplAndroid { ...@@ -59,15 +56,15 @@ class CONTENT_EXPORT DataFetcherImplAndroid {
kTypeMotion = 1 kTypeMotion = 1
}; };
DataFetcherImplAndroid(); SensorManagerAndroid();
virtual ~DataFetcherImplAndroid(); virtual ~SensorManagerAndroid();
virtual bool Start(EventType event_type); virtual bool Start(EventType event_type);
virtual void Stop(EventType event_type); virtual void Stop(EventType event_type);
virtual int GetNumberActiveDeviceMotionSensors(); virtual int GetNumberActiveDeviceMotionSensors();
private: private:
friend struct DefaultSingletonTraits<DataFetcherImplAndroid>; friend struct DefaultSingletonTraits<SensorManagerAndroid>;
enum { enum {
RECEIVED_MOTION_DATA_ACCELERATION = 0, RECEIVED_MOTION_DATA_ACCELERATION = 0,
...@@ -94,9 +91,9 @@ class CONTENT_EXPORT DataFetcherImplAndroid { ...@@ -94,9 +91,9 @@ class CONTENT_EXPORT DataFetcherImplAndroid {
base::Lock motion_buffer_lock_; base::Lock motion_buffer_lock_;
base::Lock orientation_buffer_lock_; base::Lock orientation_buffer_lock_;
DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); DISALLOW_COPY_AND_ASSIGN(SensorManagerAndroid);
}; };
} // namespace content } // namespace content
#endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ #endif // CHROME_BROWSER_DEVICE_ORIENTATION_SENSOR_MANAGER_ANDROID_H_
// Copyright 2013 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/device_orientation/data_fetcher_impl_android.h" #include "content/browser/device_orientation/sensor_manager_android.h"
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -14,10 +14,10 @@ namespace content { ...@@ -14,10 +14,10 @@ namespace content {
namespace { namespace {
class FakeDataFetcherImplAndroid : public DataFetcherImplAndroid { class FakeSensorManagerAndroid : public SensorManagerAndroid {
public: public:
FakeDataFetcherImplAndroid() { } FakeSensorManagerAndroid() { }
virtual ~FakeDataFetcherImplAndroid() { } virtual ~FakeSensorManagerAndroid() { }
virtual int GetNumberActiveDeviceMotionSensors() OVERRIDE { virtual int GetNumberActiveDeviceMotionSensors() OVERRIDE {
return number_active_sensors_; return number_active_sensors_;
...@@ -39,9 +39,9 @@ class FakeDataFetcherImplAndroid : public DataFetcherImplAndroid { ...@@ -39,9 +39,9 @@ class FakeDataFetcherImplAndroid : public DataFetcherImplAndroid {
int number_active_sensors_; int number_active_sensors_;
}; };
class AndroidDataFetcherTest : public testing::Test { class AndroidSensorManagerTest : public testing::Test {
protected: protected:
AndroidDataFetcherTest() { AndroidSensorManagerTest() {
motion_buffer_.reset(new DeviceMotionHardwareBuffer); motion_buffer_.reset(new DeviceMotionHardwareBuffer);
orientation_buffer_.reset(new DeviceOrientationHardwareBuffer); orientation_buffer_.reset(new DeviceOrientationHardwareBuffer);
} }
...@@ -50,15 +50,15 @@ class AndroidDataFetcherTest : public testing::Test { ...@@ -50,15 +50,15 @@ class AndroidDataFetcherTest : public testing::Test {
scoped_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_; scoped_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_;
}; };
TEST_F(AndroidDataFetcherTest, ThreeDeviceMotionSensorsActive) { TEST_F(AndroidSensorManagerTest, ThreeDeviceMotionSensorsActive) {
FakeDataFetcherImplAndroid::Register(base::android::AttachCurrentThread()); FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread());
FakeDataFetcherImplAndroid fetcher; FakeSensorManagerAndroid sensorManager;
fetcher.SetNumberActiveDeviceMotionSensors(3); sensorManager.SetNumberActiveDeviceMotionSensors(3);
fetcher.StartFetchingDeviceMotionData(motion_buffer_.get()); sensorManager.StartFetchingDeviceMotionData(motion_buffer_.get());
ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive);
fetcher.GotAcceleration(0, 0, 1, 2, 3); sensorManager.GotAcceleration(0, 0, 1, 2, 3);
ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive);
ASSERT_EQ(1, motion_buffer_->data.accelerationX); ASSERT_EQ(1, motion_buffer_->data.accelerationX);
ASSERT_TRUE(motion_buffer_->data.hasAccelerationX); ASSERT_TRUE(motion_buffer_->data.hasAccelerationX);
...@@ -67,7 +67,7 @@ TEST_F(AndroidDataFetcherTest, ThreeDeviceMotionSensorsActive) { ...@@ -67,7 +67,7 @@ TEST_F(AndroidDataFetcherTest, ThreeDeviceMotionSensorsActive) {
ASSERT_EQ(3, motion_buffer_->data.accelerationZ); ASSERT_EQ(3, motion_buffer_->data.accelerationZ);
ASSERT_TRUE(motion_buffer_->data.hasAccelerationZ); ASSERT_TRUE(motion_buffer_->data.hasAccelerationZ);
fetcher.GotAccelerationIncludingGravity(0, 0, 4, 5, 6); sensorManager.GotAccelerationIncludingGravity(0, 0, 4, 5, 6);
ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive);
ASSERT_EQ(4, motion_buffer_->data.accelerationIncludingGravityX); ASSERT_EQ(4, motion_buffer_->data.accelerationIncludingGravityX);
ASSERT_TRUE(motion_buffer_->data.hasAccelerationIncludingGravityX); ASSERT_TRUE(motion_buffer_->data.hasAccelerationIncludingGravityX);
...@@ -76,7 +76,7 @@ TEST_F(AndroidDataFetcherTest, ThreeDeviceMotionSensorsActive) { ...@@ -76,7 +76,7 @@ TEST_F(AndroidDataFetcherTest, ThreeDeviceMotionSensorsActive) {
ASSERT_EQ(6, motion_buffer_->data.accelerationIncludingGravityZ); ASSERT_EQ(6, motion_buffer_->data.accelerationIncludingGravityZ);
ASSERT_TRUE(motion_buffer_->data.hasAccelerationIncludingGravityZ); ASSERT_TRUE(motion_buffer_->data.hasAccelerationIncludingGravityZ);
fetcher.GotRotationRate(0, 0, 7, 8, 9); sensorManager.GotRotationRate(0, 0, 7, 8, 9);
ASSERT_TRUE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_TRUE(motion_buffer_->data.allAvailableSensorsAreActive);
ASSERT_EQ(7, motion_buffer_->data.rotationRateAlpha); ASSERT_EQ(7, motion_buffer_->data.rotationRateAlpha);
ASSERT_TRUE(motion_buffer_->data.hasRotationRateAlpha); ASSERT_TRUE(motion_buffer_->data.hasRotationRateAlpha);
...@@ -86,50 +86,50 @@ TEST_F(AndroidDataFetcherTest, ThreeDeviceMotionSensorsActive) { ...@@ -86,50 +86,50 @@ TEST_F(AndroidDataFetcherTest, ThreeDeviceMotionSensorsActive) {
ASSERT_TRUE(motion_buffer_->data.hasRotationRateGamma); ASSERT_TRUE(motion_buffer_->data.hasRotationRateGamma);
ASSERT_EQ(kInertialSensorIntervalMillis, motion_buffer_->data.interval); ASSERT_EQ(kInertialSensorIntervalMillis, motion_buffer_->data.interval);
fetcher.StopFetchingDeviceMotionData(); sensorManager.StopFetchingDeviceMotionData();
ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive);
} }
TEST_F(AndroidDataFetcherTest, TwoDeviceMotionSensorsActive) { TEST_F(AndroidSensorManagerTest, TwoDeviceMotionSensorsActive) {
FakeDataFetcherImplAndroid::Register(base::android::AttachCurrentThread()); FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread());
FakeDataFetcherImplAndroid fetcher; FakeSensorManagerAndroid sensorManager;
fetcher.SetNumberActiveDeviceMotionSensors(2); sensorManager.SetNumberActiveDeviceMotionSensors(2);
fetcher.StartFetchingDeviceMotionData(motion_buffer_.get()); sensorManager.StartFetchingDeviceMotionData(motion_buffer_.get());
ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive);
fetcher.GotAcceleration(0, 0, 1, 2, 3); sensorManager.GotAcceleration(0, 0, 1, 2, 3);
ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive);
fetcher.GotAccelerationIncludingGravity(0, 0, 1, 2, 3); sensorManager.GotAccelerationIncludingGravity(0, 0, 1, 2, 3);
ASSERT_TRUE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_TRUE(motion_buffer_->data.allAvailableSensorsAreActive);
ASSERT_EQ(kInertialSensorIntervalMillis, motion_buffer_->data.interval); ASSERT_EQ(kInertialSensorIntervalMillis, motion_buffer_->data.interval);
fetcher.StopFetchingDeviceMotionData(); sensorManager.StopFetchingDeviceMotionData();
ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive);
} }
TEST_F(AndroidDataFetcherTest, ZeroDeviceMotionSensorsActive) { TEST_F(AndroidSensorManagerTest, ZeroDeviceMotionSensorsActive) {
FakeDataFetcherImplAndroid::Register(base::android::AttachCurrentThread()); FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread());
FakeDataFetcherImplAndroid fetcher; FakeSensorManagerAndroid sensorManager;
fetcher.SetNumberActiveDeviceMotionSensors(0); sensorManager.SetNumberActiveDeviceMotionSensors(0);
fetcher.StartFetchingDeviceMotionData(motion_buffer_.get()); sensorManager.StartFetchingDeviceMotionData(motion_buffer_.get());
ASSERT_TRUE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_TRUE(motion_buffer_->data.allAvailableSensorsAreActive);
ASSERT_EQ(kInertialSensorIntervalMillis, motion_buffer_->data.interval); ASSERT_EQ(kInertialSensorIntervalMillis, motion_buffer_->data.interval);
fetcher.StopFetchingDeviceMotionData(); sensorManager.StopFetchingDeviceMotionData();
ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive);
} }
TEST_F(AndroidDataFetcherTest, DeviceOrientationSensorsActive) { TEST_F(AndroidSensorManagerTest, DeviceOrientationSensorsActive) {
FakeDataFetcherImplAndroid::Register(base::android::AttachCurrentThread()); FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread());
FakeDataFetcherImplAndroid fetcher; FakeSensorManagerAndroid sensorManager;
fetcher.StartFetchingDeviceOrientationData(orientation_buffer_.get()); sensorManager.StartFetchingDeviceOrientationData(orientation_buffer_.get());
ASSERT_FALSE(orientation_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(orientation_buffer_->data.allAvailableSensorsAreActive);
fetcher.GotOrientation(0, 0, 1, 2, 3); sensorManager.GotOrientation(0, 0, 1, 2, 3);
ASSERT_TRUE(orientation_buffer_->data.allAvailableSensorsAreActive); ASSERT_TRUE(orientation_buffer_->data.allAvailableSensorsAreActive);
ASSERT_EQ(1, orientation_buffer_->data.alpha); ASSERT_EQ(1, orientation_buffer_->data.alpha);
ASSERT_TRUE(orientation_buffer_->data.hasAlpha); ASSERT_TRUE(orientation_buffer_->data.hasAlpha);
...@@ -138,7 +138,7 @@ TEST_F(AndroidDataFetcherTest, DeviceOrientationSensorsActive) { ...@@ -138,7 +138,7 @@ TEST_F(AndroidDataFetcherTest, DeviceOrientationSensorsActive) {
ASSERT_EQ(3, orientation_buffer_->data.gamma); ASSERT_EQ(3, orientation_buffer_->data.gamma);
ASSERT_TRUE(orientation_buffer_->data.hasGamma); ASSERT_TRUE(orientation_buffer_->data.hasGamma);
fetcher.StopFetchingDeviceOrientationData(); sensorManager.StopFetchingDeviceOrientationData();
ASSERT_FALSE(orientation_buffer_->data.allAvailableSensorsAreActive); ASSERT_FALSE(orientation_buffer_->data.allAvailableSensorsAreActive);
} }
......
...@@ -400,8 +400,6 @@ ...@@ -400,8 +400,6 @@
'browser/device_monitor_mac.mm', 'browser/device_monitor_mac.mm',
'browser/device_monitor_udev.cc', 'browser/device_monitor_udev.cc',
'browser/device_monitor_udev.h', 'browser/device_monitor_udev.h',
'browser/device_orientation/data_fetcher_impl_android.cc',
'browser/device_orientation/data_fetcher_impl_android.h',
'browser/device_orientation/data_fetcher_shared_memory.h', 'browser/device_orientation/data_fetcher_shared_memory.h',
'browser/device_orientation/data_fetcher_shared_memory_android.cc', 'browser/device_orientation/data_fetcher_shared_memory_android.cc',
'browser/device_orientation/data_fetcher_shared_memory_base.cc', 'browser/device_orientation/data_fetcher_shared_memory_base.cc',
...@@ -416,6 +414,8 @@ ...@@ -416,6 +414,8 @@
'browser/device_orientation/device_orientation_message_filter.cc', 'browser/device_orientation/device_orientation_message_filter.cc',
'browser/device_orientation/device_orientation_message_filter.h', 'browser/device_orientation/device_orientation_message_filter.h',
'browser/device_orientation/inertial_sensor_consts.h', 'browser/device_orientation/inertial_sensor_consts.h',
'browser/device_orientation/sensor_manager_android.cc',
'browser/device_orientation/sensor_manager_android.h',
'browser/dom_storage/dom_storage_area.cc', 'browser/dom_storage/dom_storage_area.cc',
'browser/dom_storage/dom_storage_area.h', 'browser/dom_storage/dom_storage_area.h',
'browser/dom_storage/dom_storage_context_impl.cc', 'browser/dom_storage/dom_storage_context_impl.cc',
......
...@@ -347,8 +347,8 @@ ...@@ -347,8 +347,8 @@
'browser/child_process_security_policy_unittest.cc', 'browser/child_process_security_policy_unittest.cc',
'browser/compositor/software_browser_compositor_output_surface_unittest.cc', 'browser/compositor/software_browser_compositor_output_surface_unittest.cc',
'browser/compositor/software_output_device_ozone_unittest.cc', 'browser/compositor/software_output_device_ozone_unittest.cc',
'browser/device_orientation/data_fetcher_impl_android_unittest.cc',
'browser/device_orientation/data_fetcher_shared_memory_base_unittest.cc', 'browser/device_orientation/data_fetcher_shared_memory_base_unittest.cc',
'browser/device_orientation/sensor_manager_android_unittest.cc',
'browser/devtools/devtools_http_handler_unittest.cc', 'browser/devtools/devtools_http_handler_unittest.cc',
'browser/devtools/devtools_manager_unittest.cc', 'browser/devtools/devtools_manager_unittest.cc',
'browser/dom_storage/dom_storage_area_unittest.cc', 'browser/dom_storage/dom_storage_area_unittest.cc',
......
...@@ -58,7 +58,7 @@ class DeviceMotionAndOrientation implements SensorEventListener { ...@@ -58,7 +58,7 @@ class DeviceMotionAndOrientation implements SensorEventListener {
/** /**
* constants for using in JNI calls, also see * constants for using in JNI calls, also see
* content/browser/device_orientation/data_fetcher_impl_android.cc * content/browser/device_orientation/sensor_manager_android.cc
*/ */
static final int DEVICE_ORIENTATION = 0; static final int DEVICE_ORIENTATION = 0;
static final int DEVICE_MOTION = 1; static final int DEVICE_MOTION = 1;
...@@ -439,35 +439,35 @@ class DeviceMotionAndOrientation implements SensorEventListener { ...@@ -439,35 +439,35 @@ class DeviceMotionAndOrientation implements SensorEventListener {
/** /**
* Native JNI calls, * Native JNI calls,
* see content/browser/device_orientation/data_fetcher_impl_android.cc * see content/browser/device_orientation/sensor_manager_android.cc
*/ */
/** /**
* Orientation of the device with respect to its reference frame. * Orientation of the device with respect to its reference frame.
*/ */
private native void nativeGotOrientation( private native void nativeGotOrientation(
long nativeDataFetcherImplAndroid, long nativeSensorManagerAndroid,
double alpha, double beta, double gamma); double alpha, double beta, double gamma);
/** /**
* Linear acceleration without gravity of the device with respect to its body frame. * Linear acceleration without gravity of the device with respect to its body frame.
*/ */
private native void nativeGotAcceleration( private native void nativeGotAcceleration(
long nativeDataFetcherImplAndroid, long nativeSensorManagerAndroid,
double x, double y, double z); double x, double y, double z);
/** /**
* Acceleration including gravity of the device with respect to its body frame. * Acceleration including gravity of the device with respect to its body frame.
*/ */
private native void nativeGotAccelerationIncludingGravity( private native void nativeGotAccelerationIncludingGravity(
long nativeDataFetcherImplAndroid, long nativeSensorManagerAndroid,
double x, double y, double z); double x, double y, double z);
/** /**
* Rotation rate of the device with respect to its body frame. * Rotation rate of the device with respect to its body frame.
*/ */
private native void nativeGotRotationRate( private native void nativeGotRotationRate(
long nativeDataFetcherImplAndroid, long nativeSensorManagerAndroid,
double alpha, double beta, double gamma); double alpha, double beta, double gamma);
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment