Chromium Code Reviews| Index: device/bluetooth/device.h |
| diff --git a/device/bluetooth/device.h b/device/bluetooth/device.h |
| index c82439e6c283ecb6e851e466061bedf060a18420..b6e29bff2f234b5ae7785907010337bef57d979b 100644 |
| --- a/device/bluetooth/device.h |
| +++ b/device/bluetooth/device.h |
| @@ -5,13 +5,18 @@ |
| #ifndef DEVICE_BLUETOOTH_DEVICE_H_ |
| #define DEVICE_BLUETOOTH_DEVICE_H_ |
| +#include <memory> |
| #include <string> |
| +#include <vector> |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| #include "device/bluetooth/bluetooth_adapter.h" |
| #include "device/bluetooth/bluetooth_device.h" |
| +#include "device/bluetooth/bluetooth_gatt_connection.h" |
| +#include "device/bluetooth/bluetooth_remote_gatt_service.h" |
| #include "device/bluetooth/public/interfaces/device.mojom.h" |
| +#include "mojo/public/cpp/bindings/strong_binding.h" |
| namespace bluetooth { |
| @@ -19,26 +24,55 @@ namespace bluetooth { |
| // device/bluetooth/public/interfaces/device.mojom. |
| // It handles requests to interact with Bluetooth Device. |
| // Uses the platform abstraction of device/bluetooth. |
| -class Device : public mojom::Device { |
| +// An instance of this class is constructed by Adapter and strongly bound |
|
ortuno
2016/11/17 03:54:45
An instance of this class is constructed by callin
mbrunson
2016/11/17 19:33:33
Done.
|
| +// to its MessagePipe. In the case where the BluetoothGattConnection dies, the |
| +// instance closes the binding which causes the instance to be deleted. |
| +class Device : public mojom::Device, public device::BluetoothAdapter::Observer { |
| public: |
| - Device(const std::string& address, |
| - scoped_refptr<device::BluetoothAdapter> adapter); |
| + Device(scoped_refptr<device::BluetoothAdapter> adapter, |
|
ortuno
2016/11/17 03:54:45
To indicate that this class should only be created
mbrunson
2016/11/17 19:33:33
Done.
|
| + std::unique_ptr<device::BluetoothGattConnection> connection); |
| ~Device() override; |
| + static void Create( |
| + scoped_refptr<device::BluetoothAdapter> adapter, |
| + std::unique_ptr<device::BluetoothGattConnection> connection, |
| + mojom::DeviceRequest request); |
| + |
| // Creates a mojom::DeviceInfo using info from the given |device|. |
| static mojom::DeviceInfoPtr ConstructDeviceInfoStruct( |
| const device::BluetoothDevice* device); |
| + // BluetoothAdapter::Observer overrides: |
| + void DeviceChanged(device::BluetoothAdapter* adapter, |
| + device::BluetoothDevice* device) override; |
| + void GattServicesDiscovered(device::BluetoothAdapter* adapter, |
| + device::BluetoothDevice* device) override; |
| + |
| // mojom::Device overrides: |
| + void Disconnect() override; |
| void GetInfo(const GetInfoCallback& callback) override; |
| + void GetServices(const GetServicesCallback& callback) override; |
| private: |
| - // The address of the Bluetooth device. |
| - std::string address_; |
| + void GetServicesImpl(const GetServicesCallback& callback); |
| + |
| + mojom::ServiceInfoPtr ConstructServiceInfoStruct( |
| + const device::BluetoothRemoteGattService& service); |
| + |
| + const std::string& GetAddress(); |
| // The current BluetoothAdapter. |
| scoped_refptr<device::BluetoothAdapter> adapter_; |
| + // The GATT connection to this device. |
| + std::unique_ptr<device::BluetoothGattConnection> connection_; |
| + |
| + mojo::StrongBindingPtr<mojom::Device> binding_; |
| + |
| + // The services request queue which holds callbacks that are waiting for |
| + // services to be discovered for this device. |
| + std::vector<base::Closure> pending_services_requests_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(Device); |
| }; |