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

Side by Side Diff: content/browser/device_orientation/data_fetcher_impl_android.h

Issue 59403004: Android: remove device_data.h from browser/device_orientation/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra line Created 6 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/device_orientation/data_fetcher_impl_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "content/browser/device_orientation/device_data.h"
12 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
13 #include "content/common/device_orientation/device_motion_hardware_buffer.h" 12 #include "content/common/device_orientation/device_motion_hardware_buffer.h"
14 #include "content/common/device_orientation/device_orientation_hardware_buffer.h " 13 #include "content/common/device_orientation/device_orientation_hardware_buffer.h "
15 14
16 template<typename T> struct DefaultSingletonTraits; 15 template<typename T> struct DefaultSingletonTraits;
17 16
18 namespace content { 17 namespace content {
19 18
20 // Android implementation of Device Orientation API. 19 // Android implementation of Device Orientation API.
21 // 20 //
(...skipping 14 matching lines...) Expand all
36 // Called from Java via JNI. 35 // Called from Java via JNI.
37 void GotOrientation(JNIEnv*, jobject, 36 void GotOrientation(JNIEnv*, jobject,
38 double alpha, double beta, double gamma); 37 double alpha, double beta, double gamma);
39 void GotAcceleration(JNIEnv*, jobject, 38 void GotAcceleration(JNIEnv*, jobject,
40 double x, double y, double z); 39 double x, double y, double z);
41 void GotAccelerationIncludingGravity(JNIEnv*, jobject, 40 void GotAccelerationIncludingGravity(JNIEnv*, jobject,
42 double x, double y, double z); 41 double x, double y, double z);
43 void GotRotationRate(JNIEnv*, jobject, 42 void GotRotationRate(JNIEnv*, jobject,
44 double alpha, double beta, double gamma); 43 double alpha, double beta, double gamma);
45 44
46 virtual bool Start(DeviceData::Type event_type);
47 virtual void Stop(DeviceData::Type event_type);
48
49 // Shared memory related methods. 45 // Shared memory related methods.
50 bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer); 46 bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer);
51 void StopFetchingDeviceMotionData(); 47 void StopFetchingDeviceMotionData();
52 48
53 bool StartFetchingDeviceOrientationData( 49 bool StartFetchingDeviceOrientationData(
54 DeviceOrientationHardwareBuffer* buffer); 50 DeviceOrientationHardwareBuffer* buffer);
55 void StopFetchingDeviceOrientationData(); 51 void StopFetchingDeviceOrientationData();
56 52
57 protected: 53 protected:
54 enum EventType {
55 // These constants should match DEVICE_ORIENTATION and DEVICE_MOTION
56 // constants in content/public/android/java/src/org/chromium/content/
57 // browser/DeviceMotionAndOrientation.java
58 kTypeOrientation = 0,
59 kTypeMotion = 1
60 };
61
58 DataFetcherImplAndroid(); 62 DataFetcherImplAndroid();
59 virtual ~DataFetcherImplAndroid(); 63 virtual ~DataFetcherImplAndroid();
60 64
65 virtual bool Start(EventType event_type);
66 virtual void Stop(EventType event_type);
61 virtual int GetNumberActiveDeviceMotionSensors(); 67 virtual int GetNumberActiveDeviceMotionSensors();
62 68
63 private: 69 private:
64 friend struct DefaultSingletonTraits<DataFetcherImplAndroid>; 70 friend struct DefaultSingletonTraits<DataFetcherImplAndroid>;
65 71
66 void CheckMotionBufferReadyToRead();
67 void SetMotionBufferReadyStatus(bool ready);
68 void ClearInternalMotionBuffers();
69
70 void SetOrientationBufferReadyStatus(bool ready);
71
72 enum { 72 enum {
73 RECEIVED_MOTION_DATA_ACCELERATION = 0, 73 RECEIVED_MOTION_DATA_ACCELERATION = 0,
74 RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY = 1, 74 RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY = 1,
75 RECEIVED_MOTION_DATA_ROTATION_RATE = 2, 75 RECEIVED_MOTION_DATA_ROTATION_RATE = 2,
76 RECEIVED_MOTION_DATA_MAX = 3, 76 RECEIVED_MOTION_DATA_MAX = 3,
77 }; 77 };
78 78
79 void CheckMotionBufferReadyToRead();
80 void SetMotionBufferReadyStatus(bool ready);
81 void ClearInternalMotionBuffers();
82
83 void SetOrientationBufferReadyStatus(bool ready);
84
79 // The Java provider of orientation info. 85 // The Java provider of orientation info.
80 base::android::ScopedJavaGlobalRef<jobject> device_orientation_; 86 base::android::ScopedJavaGlobalRef<jobject> device_orientation_;
81 int number_active_device_motion_sensors_; 87 int number_active_device_motion_sensors_;
82 int received_motion_data_[RECEIVED_MOTION_DATA_MAX]; 88 int received_motion_data_[RECEIVED_MOTION_DATA_MAX];
83 DeviceMotionHardwareBuffer* device_motion_buffer_; 89 DeviceMotionHardwareBuffer* device_motion_buffer_;
84 DeviceOrientationHardwareBuffer* device_orientation_buffer_; 90 DeviceOrientationHardwareBuffer* device_orientation_buffer_;
85 bool is_motion_buffer_ready_; 91 bool is_motion_buffer_ready_;
86 bool is_orientation_buffer_ready_; 92 bool is_orientation_buffer_ready_;
87 93
88 base::Lock motion_buffer_lock_; 94 base::Lock motion_buffer_lock_;
89 base::Lock orientation_buffer_lock_; 95 base::Lock orientation_buffer_lock_;
90 96
91 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); 97 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid);
92 }; 98 };
93 99
94 } // namespace content 100 } // namespace content
95 101
96 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ 102 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/device_orientation/data_fetcher_impl_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698