| Index: device/bluetooth/bluetooth_device.cc
|
| diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc
|
| index d4e072bbc4b4b3a404de2931ea3d6bff6b4e2d18..9da1d6565a53033e8cddfcb87e5b207b9b7d5565 100644
|
| --- a/device/bluetooth/bluetooth_device.cc
|
| +++ b/device/bluetooth/bluetooth_device.cc
|
| @@ -69,12 +69,15 @@ void BluetoothDevice::DeviceUUIDs::UpdateDeviceUUIDs() {
|
| BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter)
|
| : adapter_(adapter),
|
| gatt_services_discovery_complete_(false),
|
| + gatt_services_shutting_down_(false),
|
| last_update_time_(base::Time()) {}
|
|
|
| BluetoothDevice::~BluetoothDevice() {
|
| for (BluetoothGattConnection* connection : gatt_connections_) {
|
| connection->InvalidateConnectionReference();
|
| }
|
| + gatt_services_shutting_down_ = true;
|
| + gatt_services_.clear();
|
| }
|
|
|
| BluetoothDevice::ConnectionInfo::ConnectionInfo()
|
| @@ -370,14 +373,21 @@ bool BluetoothDevice::IsGattServicesDiscoveryComplete() const {
|
| std::vector<BluetoothRemoteGattService*> BluetoothDevice::GetGattServices()
|
| const {
|
| std::vector<BluetoothRemoteGattService*> services;
|
| + if (gatt_services_shutting_down_)
|
| + return services;
|
| for (const auto& iter : gatt_services_)
|
| - services.push_back(iter.second);
|
| + services.push_back(iter.second.get());
|
| return services;
|
| }
|
|
|
| BluetoothRemoteGattService* BluetoothDevice::GetGattService(
|
| const std::string& identifier) const {
|
| - return gatt_services_.get(identifier);
|
| + if (gatt_services_shutting_down_)
|
| + return nullptr;
|
| + auto it = gatt_services_.find(identifier);
|
| + if (it == gatt_services_.end())
|
| + return nullptr;
|
| + return it->second.get();
|
| }
|
|
|
| // static
|
|
|