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

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

Issue 10755002: Refactors DeviceOrientation to make it more extensible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Handles null device_data in observer Created 8 years, 5 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 16661b8e1e018f869a22b5bd7a997725fc5da016..ef58bb62cde91d4c8fc67dcb5e85b8909f58ee53 100644
--- a/content/browser/device_orientation/data_fetcher_impl_android.h
+++ b/content/browser/device_orientation/data_fetcher_impl_android.h
@@ -10,17 +10,19 @@
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "content/browser/device_orientation/data_fetcher.h"
-#include "content/browser/device_orientation/orientation.h"
+#include "content/browser/device_orientation/device_data.h"
namespace device_orientation {
+class Orientation;
+
// Android implementation of DeviceOrientation API.
// Android's SensorManager has a push API, whereas Chrome wants to pull data.
// To fit them together, we store incoming sensor events in a 1-element buffer.
// SensorManager calls SetOrientation() which pushes a new value (discarding the
-// previous value if any). Chrome calls GetOrientation() which reads the most
-// recent value. Repeated calls to GetOrientation() will return the same value.
+// 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 {
public:
@@ -38,19 +40,20 @@ class DataFetcherImplAndroid : public DataFetcher {
double alpha, double beta, double gamma);
// Implementation of DataFetcher.
- virtual bool GetOrientation(Orientation* orientation) OVERRIDE;
+ virtual DeviceData* GetDeviceData(DeviceData::Type device_data_type) OVERRIDE;
private:
DataFetcherImplAndroid();
+ Orientation* GetOrientation();
// Wrappers for JNI methods.
bool Start(int rate_in_milliseconds);
void Stop();
- // Value returned by GetOrientation.
+ // Value returned by GetDeviceData.
scoped_ptr<Orientation> current_orientation_;
- // 1-element buffer, written by GotOrientation, read by GetOrientation.
+ // 1-element buffer, written by GotOrientation, read by GetDeviceData.
base::Lock next_orientation_lock_;
scoped_ptr<Orientation> next_orientation_;

Powered by Google App Engine
This is Rietveld 408576698