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

Unified Diff: content/browser/device_orientation/data_fetcher_impl_android.cc

Issue 12771008: Implement java-side browser sensor polling for device motion and device orientation DOM events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: taking into account the comments Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
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..413167bf0d1a9dd6aa4814d33badf168d9fc980d 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): figure out how to modify this method in case of
+// multiple event types.
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,7 @@ DataFetcher* DataFetcherImplAndroid::Create() {
}
DataFetcherImplAndroid::~DataFetcherImplAndroid() {
- Stop();
+ Stop(DeviceData::kTypeOrientation);
Peter Beverloo 2013/03/12 11:26:39 nit: add a TODO to cover that this should shut dow
timvolodine 2013/03/12 16:12:46 Done.
}
const DeviceData* DataFetcherImplAndroid::GetDeviceData(
@@ -76,17 +78,37 @@ void DataFetcherImplAndroid::GotOrientation(
next_orientation_ = orientation;
}
-bool DataFetcherImplAndroid::Start(int rate_in_milliseconds) {
+void DataFetcherImplAndroid::GotAcceleration(
+ JNIEnv*, jobject, double x, double y, double z) {
+ // TODO(timvolodine): copy into shared memory buffer
Peter Beverloo 2013/03/12 11:26:39 It's fine to get rid of the TODO now that there's
timvolodine 2013/03/12 16:12:46 Done.
+ 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(),
device_orientation_.obj(),
reinterpret_cast<jint>(this),
+ event_type,
Peter Beverloo 2013/03/12 11:26:39 nit: don't we need a cast here for strictness? Pl
timvolodine 2013/03/12 16:12:46 rate_in_milliseconds below does not use any casts,
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(),
+ event_type);
Peter Beverloo 2013/03/12 11:26:39 nit: dito.
timvolodine 2013/03/12 16:12:46 Done.
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698