Chromium Code Reviews| Index: content/browser/device_orientation/data_fetcher_impl_android.cc |
| diff --git a/content/browser/device_orientation/data_fetcher_impl_android.cc b/content/browser/device_orientation/data_fetcher_impl_android.cc |
| index 287b63a1db9c36a59db6164419d3faaa4567c9e7..55e72cfe13bf56545fb0403feafe7e8709aa2b10 100644 |
| --- a/content/browser/device_orientation/data_fetcher_impl_android.cc |
| +++ b/content/browser/device_orientation/data_fetcher_impl_android.cc |
| @@ -7,7 +7,7 @@ |
| #include "base/android/jni_android.h" |
| #include "base/logging.h" |
| #include "content/browser/device_orientation/orientation.h" |
| -#include "jni/DeviceOrientation_jni.h" |
| +#include "jni/DeviceMotionAndOrientation_jni.h" |
| using base::android::AttachCurrentThread; |
| @@ -23,7 +23,7 @@ const int kPeriodInMilliseconds = 100; |
| DataFetcherImplAndroid::DataFetcherImplAndroid() { |
| device_orientation_.Reset( |
| - Java_DeviceOrientation_getInstance(AttachCurrentThread())); |
| + Java_DeviceMotionAndOrientation_getInstance(AttachCurrentThread())); |
| } |
| void DataFetcherImplAndroid::Init(JNIEnv* env) { |
| @@ -31,9 +31,11 @@ void DataFetcherImplAndroid::Init(JNIEnv* env) { |
| DCHECK(result); |
| } |
| +// TODO(timvolodine): Modify this method to be able to distinguish |
| +// device motion from orientation. |
| DataFetcher* DataFetcherImplAndroid::Create() { |
| scoped_ptr<DataFetcherImplAndroid> fetcher(new DataFetcherImplAndroid); |
| - if (fetcher->Start(kPeriodInMilliseconds)) |
| + if (fetcher->Start(DeviceData::kTypeOrientation, kPeriodInMilliseconds)) |
| return fetcher.release(); |
| LOG(ERROR) << "DataFetcherImplAndroid::Start failed!"; |
| @@ -41,7 +43,9 @@ DataFetcher* DataFetcherImplAndroid::Create() { |
| } |
| DataFetcherImplAndroid::~DataFetcherImplAndroid() { |
| - Stop(); |
| + // TODO(timvolodine): Support device motion as well. Only stop |
| + // the active event type(s). |
| + Stop(DeviceData::kTypeOrientation); |
| } |
| const DeviceData* DataFetcherImplAndroid::GetDeviceData( |
| @@ -76,17 +80,36 @@ void DataFetcherImplAndroid::GotOrientation( |
| next_orientation_ = orientation; |
| } |
| -bool DataFetcherImplAndroid::Start(int rate_in_milliseconds) { |
| +void DataFetcherImplAndroid::GotAcceleration( |
| + JNIEnv*, jobject, double x, double y, double z) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +void DataFetcherImplAndroid::GotAccelerationIncludingGravity( |
| + JNIEnv*, jobject, double x, double y, double z) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +void DataFetcherImplAndroid::GotRotationRate( |
| + JNIEnv*, jobject, double alpha, double beta, double gamma) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +bool DataFetcherImplAndroid::Start(DeviceData::Type event_type, |
| + int rate_in_milliseconds) { |
| DCHECK(!device_orientation_.is_null()); |
| - return Java_DeviceOrientation_start(AttachCurrentThread(), |
| + return Java_DeviceMotionAndOrientation_start(AttachCurrentThread(), |
|
bulach
2013/03/19 15:22:36
nit: preferred way for callers is to move the firs
timvolodine
2013/03/19 16:50:08
Done.
|
| device_orientation_.obj(), |
| reinterpret_cast<jint>(this), |
| + static_cast<jint>(event_type), |
| rate_in_milliseconds); |
| } |
| -void DataFetcherImplAndroid::Stop() { |
| +void DataFetcherImplAndroid::Stop(DeviceData::Type event_type) { |
| DCHECK(!device_orientation_.is_null()); |
| - Java_DeviceOrientation_stop(AttachCurrentThread(), device_orientation_.obj()); |
| + Java_DeviceMotionAndOrientation_stop(AttachCurrentThread(), |
| + device_orientation_.obj(), |
|
bulach
2013/03/19 15:22:36
nit: as above..
timvolodine
2013/03/19 16:50:08
Done.
|
| + static_cast<jint>(event_type)); |
| } |
| } // namespace content |