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

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

Issue 18572014: Implement Android shared memory data fetcher for Device Motion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renderer-sync-12June-tryASYNC-2-bis-tryRebase-6
Patch Set: added OWNERS file Created 7 years, 6 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.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);
};

Powered by Google App Engine
This is Rietveld 408576698