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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_service_android.h

Issue 2313413002: Pass JavaRef to Java methods in device/bluetooth. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
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_REMOTE_GATT_SERVICE_ANDROID_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/android/jni_android.h" 13 #include "base/android/jni_android.h"
14 #include "base/android/scoped_java_ref.h"
14 #include "base/containers/scoped_ptr_hash_map.h" 15 #include "base/containers/scoped_ptr_hash_map.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "device/bluetooth/bluetooth_remote_gatt_service.h" 17 #include "device/bluetooth/bluetooth_remote_gatt_service.h"
17 #include "device/bluetooth/bluetooth_uuid.h" 18 #include "device/bluetooth/bluetooth_uuid.h"
18 19
19 namespace device { 20 namespace device {
20 21
21 class BluetoothAdapterAndroid; 22 class BluetoothAdapterAndroid;
22 class BluetoothDeviceAndroid; 23 class BluetoothDeviceAndroid;
23 class BluetoothRemoteGattCharacteristicAndroid; 24 class BluetoothRemoteGattCharacteristicAndroid;
24 25
25 // BluetoothRemoteGattServiceAndroid along with its owned Java class 26 // BluetoothRemoteGattServiceAndroid along with its owned Java class
26 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattService implement 27 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattService implement
27 // BluetoothRemoteGattService. 28 // BluetoothRemoteGattService.
28 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceAndroid 29 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceAndroid
29 : public device::BluetoothRemoteGattService { 30 : public device::BluetoothRemoteGattService {
30 public: 31 public:
31 // Create a BluetoothRemoteGattServiceAndroid instance and associated Java 32 // Create a BluetoothRemoteGattServiceAndroid instance and associated Java
32 // ChromeBluetoothRemoteGattService using the provided 33 // ChromeBluetoothRemoteGattService using the provided
33 // |bluetooth_gatt_service_wrapper|. 34 // |bluetooth_gatt_service_wrapper|.
34 // 35 //
35 // The ChromeBluetoothRemoteGattService instance will hold a Java reference 36 // The ChromeBluetoothRemoteGattService instance will hold a Java reference
36 // to |bluetooth_gatt_service_wrapper|. 37 // to |bluetooth_gatt_service_wrapper|.
37 static std::unique_ptr<BluetoothRemoteGattServiceAndroid> Create( 38 static std::unique_ptr<BluetoothRemoteGattServiceAndroid> Create(
38 BluetoothAdapterAndroid* adapter, 39 BluetoothAdapterAndroid* adapter,
39 BluetoothDeviceAndroid* device, 40 BluetoothDeviceAndroid* device,
40 jobject /* BluetoothGattServiceWrapper */ bluetooth_gatt_service_wrapper, 41 const base::android::JavaRef<
42 jobject>& /* BluetoothGattServiceWrapper */ bluetooth_gatt_service_wra pper,
41 const std::string& instance_id, 43 const std::string& instance_id,
42 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device); 44 const base::android::JavaRef<
45 jobject>& /* ChromeBluetoothDevice */ chrome_bluetooth_device);
43 46
44 ~BluetoothRemoteGattServiceAndroid() override; 47 ~BluetoothRemoteGattServiceAndroid() override;
45 48
46 // Register C++ methods exposed to Java using JNI. 49 // Register C++ methods exposed to Java using JNI.
47 static bool RegisterJNI(JNIEnv* env); 50 static bool RegisterJNI(JNIEnv* env);
48 51
49 // Returns the associated ChromeBluetoothRemoteGattService Java object. 52 // Returns the associated ChromeBluetoothRemoteGattService Java object.
50 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); 53 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
51 54
52 // Returns a BluetoothRemoteGattService::GattErrorCode from a given 55 // Returns a BluetoothRemoteGattService::GattErrorCode from a given
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 std::string, 113 std::string,
111 std::unique_ptr<BluetoothRemoteGattCharacteristicAndroid>> 114 std::unique_ptr<BluetoothRemoteGattCharacteristicAndroid>>
112 characteristics_; 115 characteristics_;
113 116
114 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceAndroid); 117 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceAndroid);
115 }; 118 };
116 119
117 } // namespace device 120 } // namespace device
118 121
119 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_ 122 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698