Chromium Code Reviews| Index: device/bluetooth/bluetooth_task_manager_win.h |
| diff --git a/device/bluetooth/bluetooth_task_manager_win.h b/device/bluetooth/bluetooth_task_manager_win.h |
| index cf31f8474c7e5448d19867726f905d9ff2ef9f99..4d118945f2a91fa3d64bf6de5c92b2a418e5f4a5 100644 |
| --- a/device/bluetooth/bluetooth_task_manager_win.h |
| +++ b/device/bluetooth/bluetooth_task_manager_win.h |
| @@ -50,9 +50,10 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin |
| bool powered; |
| }; |
| - struct DEVICE_BLUETOOTH_EXPORT ServiceRecordState { |
| + class DEVICE_BLUETOOTH_EXPORT ServiceRecordState { |
| + public: |
| ServiceRecordState(); |
| - ~ServiceRecordState(); |
| + virtual ~ServiceRecordState(); |
|
Reilly Grant (use Gerrit)
2016/12/21 22:25:15
Perhaps declare this class final and skip the virt
dougt
2016/12/22 01:18:03
Acknowledged.
|
| // Properties common to Bluetooth Classic and LE devices. |
| std::string name; |
| // Properties specific to Bluetooth Classic devices. |
| @@ -67,7 +68,11 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin |
| base::FilePath path; |
| }; |
|
Reilly Grant (use Gerrit)
2016/12/21 22:25:15
Maybe DISALLOW_COPY_AND_ASSIGN(ServiceRecordState)
dougt
2016/12/22 01:18:03
Done.
|
| - struct DEVICE_BLUETOOTH_EXPORT DeviceState { |
| + using ServiceRecordStateList = |
| + std::vector<std::unique_ptr<ServiceRecordState>>; |
| + |
| + class DEVICE_BLUETOOTH_EXPORT DeviceState { |
| + public: |
| DeviceState(); |
| ~DeviceState(); |
| @@ -79,11 +84,14 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin |
| bool visible; |
| bool connected; |
| bool authenticated; |
| - ScopedVector<ServiceRecordState> service_record_states; |
| + ServiceRecordStateList service_record_states; |
| // Properties specific to Bluetooth Classic devices. |
| uint32_t bluetooth_class; |
| // Properties specific to Bluetooth LE devices. |
| base::FilePath path; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(DeviceState); |
| }; |
| class DEVICE_BLUETOOTH_EXPORT Observer { |
| @@ -100,7 +108,8 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin |
| // the associated state can change over time. For example, during a |
| // discovery session, the "friendly" name may initially be "unknown" before |
| // the actual name is retrieved in subsequent poll events. |
| - virtual void DevicesPolled(const ScopedVector<DeviceState>& devices) {} |
| + virtual void DevicesPolled( |
| + const std::vector<std::unique_ptr<DeviceState>>& devices) {} |
| }; |
| explicit BluetoothTaskManagerWin( |
| @@ -125,19 +134,17 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin |
| void PostStopDiscoveryTask(); |
| // Callbacks of asynchronous operations of GATT service. |
| - typedef base::Callback<void(HRESULT)> HResultCallback; |
| - typedef base::Callback< |
| - void(std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC>, uint16_t, HRESULT)> |
| - GetGattIncludedCharacteristicsCallback; |
| - typedef base::Callback< |
| - void(std::unique_ptr<BTH_LE_GATT_DESCRIPTOR>, uint16_t, HRESULT)> |
| - GetGattIncludedDescriptorsCallback; |
| - typedef base::Callback<void(std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE>, |
| - HRESULT)> |
| - ReadGattCharacteristicValueCallback; |
| - typedef base::Callback<void(std::unique_ptr<std::vector<uint8_t>>)> |
| - GattCharacteristicValueChangedCallback; |
| - typedef base::Callback<void(PVOID, HRESULT)> GattEventRegistrationCallback; |
| + using HResultCallback = base::Callback<void(HRESULT)>; |
| + using GetGattIncludedCharacteristicsCallback = base::Callback< |
| + void(std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC>, uint16_t, HRESULT)>; |
| + using GetGattIncludedDescriptorsCallback = base::Callback< |
| + void(std::unique_ptr<BTH_LE_GATT_DESCRIPTOR>, uint16_t, HRESULT)>; |
| + using ReadGattCharacteristicValueCallback = |
| + base::Callback<void(std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE>, |
| + HRESULT)>; |
| + using GattCharacteristicValueChangedCallback = |
| + base::Callback<void(std::unique_ptr<std::vector<uint8_t>>)>; |
| + using GattEventRegistrationCallback = base::Callback<void(PVOID, HRESULT)>; |
| // Get all included characteristics of a given service. The service is |
| // uniquely identified by its |uuid| and |attribute_handle| with service |
| @@ -206,7 +213,8 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin |
| void OnAdapterStateChanged(const AdapterState* state); |
| void OnDiscoveryStarted(bool success); |
| void OnDiscoveryStopped(); |
| - void OnDevicesPolled(const ScopedVector<DeviceState>* devices); |
| + void OnDevicesPolled( |
| + const std::vector<std::unique_ptr<DeviceState>>* devices); |
|
Reilly Grant (use Gerrit)
2016/12/21 22:25:15
Pass const& since this function DCHECKS that devic
dougt
2016/12/22 01:18:03
Done.
|
| // Called on BluetoothTaskRunner. |
| void StartPolling(); |
| @@ -238,19 +246,21 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin |
| // exposed by those devices. |
| bool SearchDevices(int timeout_multiplier, |
| bool search_cached_devices_only, |
| - ScopedVector<DeviceState>* device_list); |
| + std::vector<std::unique_ptr<DeviceState>>* device_list); |
| // Sends a device search API call to the adapter to look for Bluetooth Classic |
| // devices. |
| - bool SearchClassicDevices(int timeout_multiplier, |
| - bool search_cached_devices_only, |
| - ScopedVector<DeviceState>* device_list); |
| + bool SearchClassicDevices( |
| + int timeout_multiplier, |
| + bool search_cached_devices_only, |
| + std::vector<std::unique_ptr<DeviceState>>* device_list); |
| // Enumerate Bluetooth Low Energy devices. |
| - bool SearchLowEnergyDevices(ScopedVector<DeviceState>* device_list); |
| + bool SearchLowEnergyDevices( |
| + std::vector<std::unique_ptr<DeviceState>>* device_list); |
| // Discover services for the devices in |device_list|. |
| - bool DiscoverServices(ScopedVector<DeviceState>* device_list, |
| + bool DiscoverServices(std::vector<std::unique_ptr<DeviceState>>* device_list, |
| bool search_cached_services_only); |
| // Discover Bluetooth Classic services for the given |device_address|. |
| @@ -258,7 +268,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin |
| const std::string& device_address, |
| const GUID& protocol_uuid, |
| bool search_cached_services_only, |
| - ScopedVector<ServiceRecordState>* service_record_states); |
| + std::vector<std::unique_ptr<ServiceRecordState>>* service_record_states); |
| // Discover Bluetooth Classic services for the given |device_address|. |
| // Returns a Win32 error code. |
| @@ -266,18 +276,18 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin |
| const std::string& device_address, |
| const GUID& protocol_uuid, |
| bool search_cached_services_only, |
| - ScopedVector<ServiceRecordState>* service_record_states); |
| + std::vector<std::unique_ptr<ServiceRecordState>>* service_record_states); |
| // Discover Bluetooth Low Energy services for the given |device_path|. |
| bool DiscoverLowEnergyDeviceServices( |
| const base::FilePath& device_path, |
| - ScopedVector<ServiceRecordState>* service_record_states); |
| + std::vector<std::unique_ptr<ServiceRecordState>>* service_record_states); |
| // Search for device paths of the GATT services in |*service_record_states| |
| // from |device_address|. |
| bool SearchForGattServiceDevicePaths( |
| const std::string device_address, |
| - ScopedVector<ServiceRecordState>* service_record_states); |
| + std::vector<std::unique_ptr<ServiceRecordState>>* service_record_states); |
| // GATT service related functions. |
| void GetGattIncludedCharacteristics( |