| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "device/bluetooth/bluetooth_adapter.h" | 14 #include "device/bluetooth/bluetooth_adapter.h" |
| 15 #include "device/bluetooth/bluetooth_device.h" | 15 #include "device/bluetooth/bluetooth_device.h" |
| 16 #include "device/bluetooth/bluetooth_gatt_connection.h" | 16 #include "device/bluetooth/bluetooth_gatt_connection.h" |
| 17 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 17 #include "device/bluetooth/bluetooth_remote_gatt_service.h" | 18 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
| 18 #include "device/bluetooth/public/interfaces/device.mojom.h" | 19 #include "device/bluetooth/public/interfaces/device.mojom.h" |
| 19 #include "mojo/public/cpp/bindings/strong_binding.h" | 20 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 20 | 21 |
| 21 namespace bluetooth { | 22 namespace bluetooth { |
| 22 | 23 |
| 23 // Implementation of Mojo Device located in | 24 // Implementation of Mojo Device located in |
| 24 // device/bluetooth/public/interfaces/device.mojom. | 25 // device/bluetooth/public/interfaces/device.mojom. |
| 25 // It handles requests to interact with Bluetooth Device. | 26 // It handles requests to interact with Bluetooth Device. |
| 26 // Uses the platform abstraction of device/bluetooth. | 27 // Uses the platform abstraction of device/bluetooth. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 // BluetoothAdapter::Observer overrides: | 44 // BluetoothAdapter::Observer overrides: |
| 44 void DeviceChanged(device::BluetoothAdapter* adapter, | 45 void DeviceChanged(device::BluetoothAdapter* adapter, |
| 45 device::BluetoothDevice* device) override; | 46 device::BluetoothDevice* device) override; |
| 46 void GattServicesDiscovered(device::BluetoothAdapter* adapter, | 47 void GattServicesDiscovered(device::BluetoothAdapter* adapter, |
| 47 device::BluetoothDevice* device) override; | 48 device::BluetoothDevice* device) override; |
| 48 | 49 |
| 49 // mojom::Device overrides: | 50 // mojom::Device overrides: |
| 50 void Disconnect() override; | 51 void Disconnect() override; |
| 51 void GetInfo(const GetInfoCallback& callback) override; | 52 void GetInfo(const GetInfoCallback& callback) override; |
| 52 void GetServices(const GetServicesCallback& callback) override; | 53 void GetServices(const GetServicesCallback& callback) override; |
| 54 void GetCharacteristics(const std::string& service_id, |
| 55 const GetCharacteristicsCallback& callback) override; |
| 53 | 56 |
| 54 private: | 57 private: |
| 55 Device(scoped_refptr<device::BluetoothAdapter> adapter, | 58 Device(scoped_refptr<device::BluetoothAdapter> adapter, |
| 56 std::unique_ptr<device::BluetoothGattConnection> connection); | 59 std::unique_ptr<device::BluetoothGattConnection> connection); |
| 57 | 60 |
| 58 void GetServicesImpl(const GetServicesCallback& callback); | 61 void GetServicesImpl(const GetServicesCallback& callback); |
| 59 | 62 |
| 60 mojom::ServiceInfoPtr ConstructServiceInfoStruct( | 63 mojom::ServiceInfoPtr ConstructServiceInfoStruct( |
| 61 const device::BluetoothRemoteGattService& service); | 64 const device::BluetoothRemoteGattService& service); |
| 62 | 65 |
| 66 void GetCharacteristicsImpl(const std::string& service_id, |
| 67 const GetCharacteristicsCallback& callback); |
| 68 |
| 63 const std::string& GetAddress(); | 69 const std::string& GetAddress(); |
| 64 | 70 |
| 65 // The current BluetoothAdapter. | 71 // The current BluetoothAdapter. |
| 66 scoped_refptr<device::BluetoothAdapter> adapter_; | 72 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 67 | 73 |
| 68 // The GATT connection to this device. | 74 // The GATT connection to this device. |
| 69 std::unique_ptr<device::BluetoothGattConnection> connection_; | 75 std::unique_ptr<device::BluetoothGattConnection> connection_; |
| 70 | 76 |
| 71 mojo::StrongBindingPtr<mojom::Device> binding_; | 77 mojo::StrongBindingPtr<mojom::Device> binding_; |
| 72 | 78 |
| 73 // The services request queue which holds callbacks that are waiting for | 79 // The services request queue which holds callbacks that are waiting for |
| 74 // services to be discovered for this device. | 80 // services to be discovered for this device. |
| 75 std::vector<base::Closure> pending_services_requests_; | 81 std::vector<base::Closure> pending_services_requests_; |
| 76 | 82 |
| 77 DISALLOW_COPY_AND_ASSIGN(Device); | 83 DISALLOW_COPY_AND_ASSIGN(Device); |
| 78 }; | 84 }; |
| 79 | 85 |
| 80 } // namespace bluetooth | 86 } // namespace bluetooth |
| 81 | 87 |
| 82 #endif // DEVICE_BLUETOOTH_DEVICE_H_ | 88 #endif // DEVICE_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |