Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1835)

Unified Diff: device/bluetooth/bluetooth_task_manager_win.h

Issue 2567903004: Replace ScopedVector/ScopedPtrHashMap with std::vector and std::unordered_map (Closed)
Patch Set: Mac bustage Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..1cd3f54b978ab4a4777476b5a90c96d0369d13bd 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();
// Properties common to Bluetooth Classic and LE devices.
std::string name;
// Properties specific to Bluetooth Classic devices.
@@ -65,9 +66,16 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin
// service must use service device path instead of resident device device
// path.
base::FilePath path;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ServiceRecordState);
};
- struct DEVICE_BLUETOOTH_EXPORT DeviceState {
+ using ServiceRecordStateList =
+ std::vector<std::unique_ptr<ServiceRecordState>>;
+
+ class DEVICE_BLUETOOTH_EXPORT DeviceState {
+ public:
DeviceState();
~DeviceState();
@@ -79,11 +87,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 +111,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 +137,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 +216,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);
// Called on BluetoothTaskRunner.
void StartPolling();
@@ -238,19 +249,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 +271,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 +279,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(

Powered by Google App Engine
This is Rietveld 408576698