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..dd7884e840c1bae8c813b3e916267e62f32d19aa 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,11 +24,14 @@ 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); |
+ static DataFetcherImplAndroid* instance(); |
+ |
// Factory function. We'll listen for events for the lifetime of this object. |
// Returns NULL on error. |
static DataFetcher* Create(); |
@@ -47,17 +51,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() OVERRIDE { return false; } |
+ virtual bool FetchDeviceMotionDataIntoBuffer() OVERRIDE; |
+ virtual bool StartFetchingDeviceMotionData( |
+ DeviceMotionHardwareBuffer* buffer) OVERRIDE; |
+ virtual void StopFetchingDeviceMotionData() OVERRIDE; |
+ |
+ protected: |
bulach
2013/07/04 08:23:36
why is it protected? styleguide forbids non-privat
timvolodine
2013/07/04 12:02:52
I needed a couple of methods to be protected for e
|
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(); |
// Value returned by GetDeviceData. |
scoped_refptr<Orientation> current_orientation_; |
@@ -68,6 +81,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]; |
bulach
2013/07/04 08:23:36
nit: received_motion_data.
also, I think using the
timvolodine
2013/07/04 12:02:52
Done.
|
+ DeviceMotionHardwareBuffer* device_motion_buffer_; |
+ bool is_buffer_ready_; |
DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); |
}; |