OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_ |
| 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_ |
| 7 |
| 8 #include "device/generic_sensor/platform_sensor.h" |
| 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 |
| 12 namespace base { |
| 13 class SingleThreadTaskRunner; |
| 14 } |
| 15 |
| 16 namespace device { |
| 17 |
| 18 class PlatformSensorAndroid : public PlatformSensor { |
| 19 public: |
| 20 // Register C++ methods exposed to Java using JNI. |
| 21 static bool RegisterJNI(JNIEnv* env); |
| 22 |
| 23 PlatformSensorAndroid(mojom::SensorType type, |
| 24 mojo::ScopedSharedBufferMapping mapping, |
| 25 uint64_t buffer_size, |
| 26 PlatformSensorProvider* provider, |
| 27 const base::android::JavaRef<jobject>& java_sensor); |
| 28 |
| 29 mojom::ReportingMode GetReportingMode() override; |
| 30 PlatformSensorConfiguration GetDefaultConfiguration() override; |
| 31 |
| 32 void NotifyPlatformSensorReadingChanged( |
| 33 JNIEnv*, |
| 34 const base::android::JavaRef<jobject>& caller); |
| 35 void NotifyPlatformSensorError(JNIEnv*, |
| 36 const base::android::JavaRef<jobject>& caller); |
| 37 |
| 38 protected: |
| 39 ~PlatformSensorAndroid() override; |
| 40 bool StartSensor(const PlatformSensorConfiguration& configuration) override; |
| 41 void StopSensor() override; |
| 42 bool CheckSensorConfiguration( |
| 43 const PlatformSensorConfiguration& configuration) override; |
| 44 |
| 45 private: |
| 46 // Java object org.chromium.device.sensors.PlatformSensor |
| 47 base::android::ScopedJavaGlobalRef<jobject> j_object_; |
| 48 // Task runner that is used by mojo objects for the IPC. Android sensor |
| 49 // objects share separate handler thread that processes sensor |
| 50 // events. Notifications from Java side are forwarded to |task_runner_|. |
| 51 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 52 DISALLOW_COPY_AND_ASSIGN(PlatformSensorAndroid); |
| 53 }; |
| 54 |
| 55 } // namespace device |
| 56 |
| 57 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_ANDROID_H_ |
OLD | NEW |