| 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..56bb53364f2e12aef10b2ea3035a7b3054d3c033 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,15 +51,25 @@ 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();
|
|
|
| @@ -68,6 +82,12 @@ 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_;
|
| +
|
| + DataFetcher* data_fetcher_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid);
|
| };
|
|
|