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 568fe557a7a1f69bb00ec82cf1df847c9952e8c1..8837edc5c1094bbc172816abe0fb420e6f904872 100644 |
--- a/content/browser/device_orientation/data_fetcher_impl_android.h |
+++ b/content/browser/device_orientation/data_fetcher_impl_android.h |
@@ -9,6 +9,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/synchronization/lock.h" |
#include "content/browser/device_orientation/data_fetcher.h" |
+#include "content/browser/device_orientation/data_fetcher_shared_memory.h" |
#include "content/browser/device_orientation/device_data.h" |
namespace content { |
@@ -23,7 +24,8 @@ class Orientation; |
// previous value if any). Chrome calls GetDeviceData() which reads the most |
// recent value. Repeated calls to GetDeviceData() will return the same value. |
-class DataFetcherImplAndroid : public DataFetcher { |
+class DataFetcherImplAndroid |
+ : public DataFetcher, public DataFetcherSharedMemory { |
public: |
// Must be called at startup, before Create(). |
static void Init(JNIEnv* env); |
@@ -47,15 +49,26 @@ class DataFetcherImplAndroid : public DataFetcher { |
// Implementation of DataFetcher. |
virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; |
- private: |
+ // Implementation of the new API using shared memory. |
+ |
+ virtual bool needsPolling() { return false; } |
+ virtual bool FetchDeviceMotionDataIntoBuffer(); |
+ virtual bool StartFetchingDeviceMotionData( |
+ DeviceMotionHardwareBuffer* buffer); |
+ virtual void StopFetchingDeviceMotionData(); |
+ |
+ public: |
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); |
+ |
+ void CheckBufferReadyToRead(); |
+ virtual int GetNumberActiveDeviceMotionSensors(); |
// Value returned by GetDeviceData. |
scoped_refptr<Orientation> current_orientation_; |
@@ -66,6 +79,10 @@ class DataFetcherImplAndroid : public DataFetcher { |
// The Java provider of orientation info. |
base::android::ScopedJavaGlobalRef<jobject> device_orientation_; |
+ int number_active_device_motion_sensors_; |
+ int receivedMotionData[3]; |
+ DeviceMotionHardwareBuffer* device_motion_buffer_; |
+ bool is_buffer_ready_; |
DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); |
}; |