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_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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 23 matching lines...) Expand all Loading... |
34 // | 34 // |
35 // TODO(scheib): Return a scoped_ptr<>, but then device will need to handle | 35 // TODO(scheib): Return a scoped_ptr<>, but then device will need to handle |
36 // this correctly. http://crbug.com/506416 | 36 // this correctly. http://crbug.com/506416 |
37 static BluetoothRemoteGattServiceAndroid* Create( | 37 static BluetoothRemoteGattServiceAndroid* Create( |
38 BluetoothAdapterAndroid* adapter, | 38 BluetoothAdapterAndroid* adapter, |
39 BluetoothDeviceAndroid* device, | 39 BluetoothDeviceAndroid* device, |
40 jobject bluetooth_remote_gatt_service_wrapper, // Java Type: | 40 jobject bluetooth_remote_gatt_service_wrapper, // Java Type: |
41 // BluetoothRemoteGattServiceWrapper | 41 // BluetoothRemoteGattServiceWrapper |
42 std::string instanceId); | 42 std::string instanceId); |
43 | 43 |
| 44 // Register C++ methods exposed to Java using JNI. |
| 45 static bool RegisterJNI(JNIEnv* env); |
| 46 |
44 // device::BluetoothGattService overrides. | 47 // device::BluetoothGattService overrides. |
45 std::string GetIdentifier() const override; | 48 std::string GetIdentifier() const override; |
46 device::BluetoothUUID GetUUID() const override; | 49 device::BluetoothUUID GetUUID() const override; |
47 bool IsLocal() const override; | 50 bool IsLocal() const override; |
48 bool IsPrimary() const override; | 51 bool IsPrimary() const override; |
49 device::BluetoothDevice* GetDevice() const override; | 52 device::BluetoothDevice* GetDevice() const override; |
50 std::vector<device::BluetoothGattCharacteristic*> GetCharacteristics() | 53 std::vector<device::BluetoothGattCharacteristic*> GetCharacteristics() |
51 const override; | 54 const override; |
52 std::vector<device::BluetoothGattService*> GetIncludedServices() | 55 std::vector<device::BluetoothGattService*> GetIncludedServices() |
53 const override; | 56 const override; |
54 device::BluetoothGattCharacteristic* GetCharacteristic( | 57 device::BluetoothGattCharacteristic* GetCharacteristic( |
55 const std::string& identifier) const override; | 58 const std::string& identifier) const override; |
56 bool AddCharacteristic( | 59 bool AddCharacteristic( |
57 device::BluetoothGattCharacteristic* characteristic) override; | 60 device::BluetoothGattCharacteristic* characteristic) override; |
58 bool AddIncludedService(device::BluetoothGattService* service) override; | 61 bool AddIncludedService(device::BluetoothGattService* service) override; |
59 void Register(const base::Closure& callback, | 62 void Register(const base::Closure& callback, |
60 const ErrorCallback& error_callback) override; | 63 const ErrorCallback& error_callback) override; |
61 void Unregister(const base::Closure& callback, | 64 void Unregister(const base::Closure& callback, |
62 const ErrorCallback& error_callback) override; | 65 const ErrorCallback& error_callback) override; |
63 | 66 |
64 private: | 67 private: |
65 friend class BluetoothDeviceAndroid; | 68 friend class BluetoothDeviceAndroid; |
66 | 69 |
67 BluetoothRemoteGattServiceAndroid(BluetoothAdapterAndroid* adapter, | 70 BluetoothRemoteGattServiceAndroid(BluetoothAdapterAndroid* adapter, |
68 BluetoothDeviceAndroid* device, | 71 BluetoothDeviceAndroid* device, |
69 std::string instanceId); | 72 std::string instanceId); |
70 ~BluetoothRemoteGattServiceAndroid() override; | 73 ~BluetoothRemoteGattServiceAndroid() override; |
71 | 74 |
| 75 // Java object org.chromium.device.bluetooth.ChromeBluetoothRemoteGattService. |
| 76 base::android::ScopedJavaGlobalRef<jobject> j_service_; |
| 77 |
72 // The adapter associated with this service. It's ok to store a raw pointer | 78 // The adapter associated with this service. It's ok to store a raw pointer |
73 // here since |adapter_| indirectly owns this instance. | 79 // here since |adapter_| indirectly owns this instance. |
74 BluetoothAdapterAndroid* adapter_; | 80 BluetoothAdapterAndroid* adapter_; |
75 | 81 |
76 // The device this GATT service belongs to. It's ok to store a raw pointer | 82 // The device this GATT service belongs to. It's ok to store a raw pointer |
77 // here since |device_| owns this instance. | 83 // here since |device_| owns this instance. |
78 BluetoothDeviceAndroid* device_; | 84 BluetoothDeviceAndroid* device_; |
79 | 85 |
80 // Instance ID, cached from Android object. | 86 // Instance ID, cached from Android object. |
81 std::string instanceId_; | 87 std::string instanceId_; |
82 | 88 |
83 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceAndroid); | 89 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceAndroid); |
84 }; | 90 }; |
85 | 91 |
86 } // namespace android | 92 } // namespace android |
87 | 93 |
88 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_ | 94 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_ANDROID_H_ |
OLD | NEW |