Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ |
| 6 #define CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ | 6 #define CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 // Factory function. We'll listen for events for the lifetime of this object. | 31 // Factory function. We'll listen for events for the lifetime of this object. |
| 32 // Returns NULL on error. | 32 // Returns NULL on error. |
| 33 static DataFetcher* Create(); | 33 static DataFetcher* Create(); |
| 34 | 34 |
| 35 virtual ~DataFetcherImplAndroid(); | 35 virtual ~DataFetcherImplAndroid(); |
| 36 | 36 |
| 37 // Called from Java via JNI. | 37 // Called from Java via JNI. |
| 38 void GotOrientation(JNIEnv*, jobject, | 38 void GotOrientation(JNIEnv*, jobject, |
| 39 double alpha, double beta, double gamma); | 39 double alpha, double beta, double gamma); |
| 40 | 40 |
| 41 void GotAcceleration(JNIEnv*, jobject, | |
|
Peter Beverloo
2013/03/11 17:57:25
For clarity, I'd prefer to either remove the empty
timvolodine1
2013/03/12 11:18:06
Done.
| |
| 42 double x, double y, double z); | |
|
Peter Beverloo
2013/03/11 17:57:25
nit: indent should be equal to JNIEnv* on line 41.
timvolodine1
2013/03/12 11:18:06
Done.
| |
| 43 | |
| 44 void GotAccelerationIncludingGravity(JNIEnv*, jobject, | |
| 45 double x, double y, double z); | |
|
Peter Beverloo
2013/03/11 17:57:25
nit: indent should be equal to JNIEnv* on line 45.
timvolodine1
2013/03/12 11:18:06
Done.
| |
| 46 | |
| 47 void GotRotationRate(JNIEnv*, jobject, | |
| 48 double alpha, double beta, double gamma); | |
|
Peter Beverloo
2013/03/11 17:57:25
nit: indent should be equal to JNIEnv* on line 47.
timvolodine1
2013/03/12 11:18:06
Done.
| |
| 49 | |
| 41 // Implementation of DataFetcher. | 50 // Implementation of DataFetcher. |
| 42 virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; | 51 virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; |
| 43 | 52 |
| 44 private: | 53 private: |
| 45 DataFetcherImplAndroid(); | 54 DataFetcherImplAndroid(); |
| 46 const Orientation* GetOrientation(); | 55 const Orientation* GetOrientation(); |
| 47 | 56 |
| 48 // Wrappers for JNI methods. | 57 // Wrappers for JNI methods. |
| 49 bool Start(int rate_in_milliseconds); | 58 bool Start(int rate_in_milliseconds); |
| 59 bool Start(int spec_event_type, int rate_in_milliseconds); | |
|
Peter Beverloo
2013/03/11 17:57:25
I'm not fond of having an int as the parameter, it
Peter Beverloo
2013/03/11 17:57:25
naming nit: I don't like "spec_event_type", as the
Miguel Garcia
2013/03/11 18:25:50
Yeah let's with an enum on C++ on Java we should k
timvolodine1
2013/03/12 11:18:06
Done.
timvolodine1
2013/03/12 11:18:06
Done.
timvolodine1
2013/03/12 11:18:06
Done.
| |
| 60 | |
| 50 void Stop(); | 61 void Stop(); |
|
Miguel Garcia
2013/03/11 18:25:50
I am not too fond on method overrides, but if deem
timvolodine1
2013/03/12 11:18:06
Done.
| |
| 62 void Stop(int spec_event_type); | |
| 51 | 63 |
| 52 // Value returned by GetDeviceData. | 64 // Value returned by GetDeviceData. |
| 53 scoped_refptr<Orientation> current_orientation_; | 65 scoped_refptr<Orientation> current_orientation_; |
| 54 | 66 |
| 55 // 1-element buffer, written by GotOrientation, read by GetDeviceData. | 67 // 1-element buffer, written by GotOrientation, read by GetDeviceData. |
| 56 base::Lock next_orientation_lock_; | 68 base::Lock next_orientation_lock_; |
| 57 scoped_refptr<Orientation> next_orientation_; | 69 scoped_refptr<Orientation> next_orientation_; |
| 58 | 70 |
| 59 // The Java provider of orientation info. | 71 // The Java provider of orientation info. |
| 60 base::android::ScopedJavaGlobalRef<jobject> device_orientation_; | 72 base::android::ScopedJavaGlobalRef<jobject> device_orientation_; |
| 61 | 73 |
| 62 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); | 74 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); |
| 63 }; | 75 }; |
| 64 | 76 |
| 65 } // namespace content | 77 } // namespace content |
| 66 | 78 |
| 67 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ | 79 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ |
| OLD | NEW |