OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_DEVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_DEVICE_H_ |
6 #define DEVICE_BLUETOOTH_DEVICE_H_ | 6 #define DEVICE_BLUETOOTH_DEVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "device/bluetooth/bluetooth_adapter.h" | 12 #include "device/bluetooth/bluetooth_adapter.h" |
13 #include "device/bluetooth/bluetooth_device.h" | 13 #include "device/bluetooth/bluetooth_device.h" |
| 14 #include "device/bluetooth/bluetooth_gatt_connection.h" |
| 15 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
14 #include "device/bluetooth/public/interfaces/device.mojom.h" | 16 #include "device/bluetooth/public/interfaces/device.mojom.h" |
15 | 17 |
16 namespace bluetooth { | 18 namespace bluetooth { |
17 | 19 |
18 // Implementation of Mojo Device located in | 20 // Implementation of Mojo Device located in |
19 // device/bluetooth/public/interfaces/device.mojom. | 21 // device/bluetooth/public/interfaces/device.mojom. |
20 // It handles requests to interact with Bluetooth Device. | 22 // It handles requests to interact with Bluetooth Device. |
21 // Uses the platform abstraction of device/bluetooth. | 23 // Uses the platform abstraction of device/bluetooth. |
22 class Device : public mojom::Device { | 24 class Device : public mojom::Device { |
23 public: | 25 public: |
24 Device(const std::string& address, | 26 Device(scoped_refptr<device::BluetoothAdapter> adapter, |
25 scoped_refptr<device::BluetoothAdapter> adapter); | 27 std::unique_ptr<device::BluetoothGattConnection> connection); |
26 ~Device() override; | 28 ~Device() override; |
27 | 29 |
28 // Creates a mojom::DeviceInfo using info from the given |device|. | 30 // Creates a mojom::DeviceInfo using info from the given |device|. |
29 static mojom::DeviceInfoPtr ConstructDeviceInfoStruct( | 31 static mojom::DeviceInfoPtr ConstructDeviceInfoStruct( |
30 const device::BluetoothDevice* device); | 32 const device::BluetoothDevice* device); |
31 | 33 |
32 // mojom::Device overrides: | 34 // mojom::Device overrides: |
33 void GetInfo(const GetInfoCallback& callback) override; | 35 void GetInfo(const GetInfoCallback& callback) override; |
| 36 void GetServices(const GetServicesCallback& callback) override; |
34 | 37 |
35 private: | 38 private: |
36 // The address of the Bluetooth device. | 39 mojom::ServiceInfoPtr ConstructServiceInfoStruct( |
37 std::string address_; | 40 const device::BluetoothRemoteGattService* service); |
38 | 41 |
39 // The current BluetoothAdapter. | 42 // The current BluetoothAdapter. |
40 scoped_refptr<device::BluetoothAdapter> adapter_; | 43 scoped_refptr<device::BluetoothAdapter> adapter_; |
41 | 44 |
| 45 // The GATT connection to this device. |
| 46 std::unique_ptr<device::BluetoothGattConnection> connection_; |
| 47 |
42 DISALLOW_COPY_AND_ASSIGN(Device); | 48 DISALLOW_COPY_AND_ASSIGN(Device); |
43 }; | 49 }; |
44 | 50 |
45 } // namespace bluetooth | 51 } // namespace bluetooth |
46 | 52 |
47 #endif // DEVICE_BLUETOOTH_DEVICE_H_ | 53 #endif // DEVICE_BLUETOOTH_DEVICE_H_ |
OLD | NEW |