| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 13 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "device/bluetooth/bluetooth_adapter_android.h" | 16 #include "device/bluetooth/bluetooth_adapter_android.h" |
| 16 #include "device/bluetooth/bluetooth_device.h" | 17 #include "device/bluetooth/bluetooth_device.h" |
| 17 | 18 |
| 18 namespace device { | 19 namespace device { |
| 19 | 20 |
| 20 // BluetoothDeviceAndroid along with its owned Java class | 21 // BluetoothDeviceAndroid along with its owned Java class |
| 21 // org.chromium.device.bluetooth.ChromeBluetoothDevice implement | 22 // org.chromium.device.bluetooth.ChromeBluetoothDevice implement |
| 22 // BluetoothDevice. | 23 // BluetoothDevice. |
| 23 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceAndroid final | 24 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceAndroid final |
| 24 : public BluetoothDevice { | 25 : public BluetoothDevice { |
| 25 public: | 26 public: |
| 26 // Create a BluetoothDeviceAndroid instance and associated Java | 27 // Create a BluetoothDeviceAndroid instance and associated Java |
| 27 // ChromeBluetoothDevice using the provided |java_bluetooth_device_wrapper|. | 28 // ChromeBluetoothDevice using the provided |java_bluetooth_device_wrapper|. |
| 28 // | 29 // |
| 29 // The ChromeBluetoothDevice instance will hold a Java reference | 30 // The ChromeBluetoothDevice instance will hold a Java reference |
| 30 // to |bluetooth_device_wrapper|. | 31 // to |bluetooth_device_wrapper|. |
| 31 // | 32 // |
| 32 // TODO(scheib): Return a std::unique_ptr<>, but then adapter will need to | 33 // TODO(scheib): Return a std::unique_ptr<>, but then adapter will need to |
| 33 // handle | 34 // handle |
| 34 // this correctly. http://crbug.com/506416 | 35 // this correctly. http://crbug.com/506416 |
| 35 static BluetoothDeviceAndroid* Create( | 36 static BluetoothDeviceAndroid* Create( |
| 36 BluetoothAdapterAndroid* adapter, | 37 BluetoothAdapterAndroid* adapter, |
| 37 jobject bluetooth_device_wrapper); // Java Type: bluetoothDeviceWrapper | 38 const base::android::JavaRef<jobject>& |
| 39 bluetooth_device_wrapper); // Java Type: bluetoothDeviceWrapper |
| 38 | 40 |
| 39 ~BluetoothDeviceAndroid() override; | 41 ~BluetoothDeviceAndroid() override; |
| 40 | 42 |
| 41 // Register C++ methods exposed to Java using JNI. | 43 // Register C++ methods exposed to Java using JNI. |
| 42 static bool RegisterJNI(JNIEnv* env); | 44 static bool RegisterJNI(JNIEnv* env); |
| 43 | 45 |
| 44 // Returns the associated ChromeBluetoothDevice Java object. | 46 // Returns the associated ChromeBluetoothDevice Java object. |
| 45 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); | 47 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); |
| 46 | 48 |
| 47 // Get owning BluetoothAdapter cast to BluetoothAdapterAndroid. | 49 // Get owning BluetoothAdapter cast to BluetoothAdapterAndroid. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 base::android::ScopedJavaGlobalRef<jobject> j_device_; | 124 base::android::ScopedJavaGlobalRef<jobject> j_device_; |
| 123 | 125 |
| 124 bool gatt_connected_ = false; | 126 bool gatt_connected_ = false; |
| 125 | 127 |
| 126 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceAndroid); | 128 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceAndroid); |
| 127 }; | 129 }; |
| 128 | 130 |
| 129 } // namespace device | 131 } // namespace device |
| 130 | 132 |
| 131 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_ | 133 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_ANDROID_H_ |
| OLD | NEW |