Index: content/browser/device_orientation/data_fetcher_impl_android.h |
diff --git a/content/browser/device_orientation/data_fetcher_impl_android.h b/content/browser/device_orientation/data_fetcher_impl_android.h |
index 4f431e0da117ab2b64d52c7b1c038dad3c86fba4..8ca78aaf1498d99d9a6272fabaeddd87aa6fbc9d 100644 |
--- a/content/browser/device_orientation/data_fetcher_impl_android.h |
+++ b/content/browser/device_orientation/data_fetcher_impl_android.h |
@@ -10,9 +10,9 @@ |
#include "base/synchronization/lock.h" |
#include "content/browser/device_orientation/data_fetcher.h" |
#include "content/browser/device_orientation/device_data.h" |
+#include "content/common/device_motion_hardware_buffer.h" |
namespace content { |
- |
class Orientation; |
// Android implementation of DeviceOrientation API. |
@@ -23,10 +23,15 @@ class Orientation; |
// previous value if any). Chrome calls GetDeviceData() which reads the most |
// recent value. Repeated calls to GetDeviceData() will return the same value. |
+// TODO(timvolodine): Move this class implementation to |
+// data_fetcher_shared_memory_android.cc, once Device Orientation switches to |
+// shared memory implementation. |
class DataFetcherImplAndroid : public DataFetcher { |
public: |
// Must be called at startup, before Create(). |
- static void Init(JNIEnv* env); |
+ static void Register(JNIEnv* env); |
+ |
+ static DataFetcherImplAndroid* instance(); |
// Factory function. We'll listen for events for the lifetime of this object. |
// Returns NULL on error. |
@@ -47,18 +52,35 @@ class DataFetcherImplAndroid : public DataFetcher { |
// Implementation of DataFetcher. |
virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; |
- private: |
+ // Implementation of the new API using shared memory. |
bulach
2013/07/09 09:03:29
nit: just the name the base class, "new" will get
timvolodine
2013/07/09 18:59:56
Done.
|
+ |
+ virtual bool NeedsPolling() { return false; } |
bulach
2013/07/09 09:03:29
nit: better move the implementation to the .cc fil
timvolodine
2013/07/09 18:59:56
Done.
|
+ virtual bool FetchDeviceMotionDataIntoBuffer(); |
+ virtual bool StartFetchingDeviceMotionData( |
+ DeviceMotionHardwareBuffer* buffer); |
+ virtual void StopFetchingDeviceMotionData(); |
+ |
+ protected: |
DataFetcherImplAndroid(); |
const Orientation* GetOrientation(); |
// Wrappers for JNI methods. |
// TODO(timvolodine): move the DeviceData::Type enum to the service class |
// once it is implemented. |
- bool Start(DeviceData::Type event_type, int rate_in_milliseconds); |
- void Stop(DeviceData::Type event_type); |
+ virtual bool Start(DeviceData::Type event_type, int rate_in_milliseconds); |
+ virtual void Stop(DeviceData::Type event_type); |
virtual int GetNumberActiveDeviceMotionSensors(); |
+ void CheckBufferReadyToRead(); |
+ void SetBufferReadyStatus(bool ready); |
+ private: |
+ enum { |
+ DATA_ACCELERATION = 0, |
bulach
2013/07/09 09:03:29
nit: I guess this would be clearer as RECEIVED_MOT
timvolodine
2013/07/09 18:59:56
Done.
|
+ DATA_ACCELERATION_INCLUDING_GRAVITY = 1, |
+ DATA_ROTATION_RATE = 2, |
+ DATA_MAX = 3, |
+ }; |
// Value returned by GetDeviceData. |
scoped_refptr<Orientation> current_orientation_; |
@@ -68,6 +90,10 @@ class DataFetcherImplAndroid : public DataFetcher { |
// The Java provider of orientation info. |
base::android::ScopedJavaGlobalRef<jobject> device_orientation_; |
+ int number_active_device_motion_sensors_; |
+ int received_motion_data_[DATA_MAX]; |
+ DeviceMotionHardwareBuffer* device_motion_buffer_; |
+ bool is_buffer_ready_; |
DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); |
}; |