| 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 #include "device/bluetooth/bluetooth_remote_gatt_service_win.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_service_win.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "device/bluetooth/bluetooth_adapter_win.h" | 8 #include "device/bluetooth/bluetooth_adapter_win.h" |
| 9 #include "device/bluetooth/bluetooth_device_win.h" | 9 #include "device/bluetooth/bluetooth_device_win.h" |
| 10 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_win.h" | 10 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_win.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 task_manager_ = adapter_->GetWinBluetoothTaskManager(); | 43 task_manager_ = adapter_->GetWinBluetoothTaskManager(); |
| 44 DCHECK(task_manager_); | 44 DCHECK(task_manager_); |
| 45 service_identifier_ = device_->GetIdentifier() + "/" + service_uuid_.value() + | 45 service_identifier_ = device_->GetIdentifier() + "/" + service_uuid_.value() + |
| 46 "_" + std::to_string(service_attribute_handle_); | 46 "_" + std::to_string(service_attribute_handle_); |
| 47 Update(); | 47 Update(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 BluetoothRemoteGattServiceWin::~BluetoothRemoteGattServiceWin() { | 50 BluetoothRemoteGattServiceWin::~BluetoothRemoteGattServiceWin() { |
| 51 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 51 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 52 | 52 |
| 53 ClearIncludedCharacteristics(); |
| 54 |
| 53 adapter_->NotifyGattServiceRemoved(this); | 55 adapter_->NotifyGattServiceRemoved(this); |
| 54 } | 56 } |
| 55 | 57 |
| 56 std::string BluetoothRemoteGattServiceWin::GetIdentifier() const { | 58 std::string BluetoothRemoteGattServiceWin::GetIdentifier() const { |
| 57 return service_identifier_; | 59 return service_identifier_; |
| 58 } | 60 } |
| 59 | 61 |
| 60 BluetoothUUID BluetoothRemoteGattServiceWin::GetUUID() const { | 62 BluetoothUUID BluetoothRemoteGattServiceWin::GetUUID() const { |
| 61 return const_cast<BluetoothUUID&>(service_uuid_); | 63 return const_cast<BluetoothUUID&>(service_uuid_); |
| 62 } | 64 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 characteristics[i].AttributeHandle) { | 240 characteristics[i].AttributeHandle) { |
| 239 return true; | 241 return true; |
| 240 } | 242 } |
| 241 } | 243 } |
| 242 return false; | 244 return false; |
| 243 } | 245 } |
| 244 | 246 |
| 245 void BluetoothRemoteGattServiceWin::RemoveIncludedCharacteristic( | 247 void BluetoothRemoteGattServiceWin::RemoveIncludedCharacteristic( |
| 246 std::string identifier) { | 248 std::string identifier) { |
| 247 discovery_completed_included_charateristics_.erase(identifier); | 249 discovery_completed_included_charateristics_.erase(identifier); |
| 250 included_characteristics_[identifier].reset(); |
| 248 included_characteristics_.erase(identifier); | 251 included_characteristics_.erase(identifier); |
| 249 } | 252 } |
| 250 | 253 |
| 251 void BluetoothRemoteGattServiceWin::ClearIncludedCharacteristics() { | 254 void BluetoothRemoteGattServiceWin::ClearIncludedCharacteristics() { |
| 252 discovery_completed_included_charateristics_.clear(); | 255 discovery_completed_included_charateristics_.clear(); |
| 253 // Explicitly reset to null to ensure that calling GetCharacteristic() on the | 256 // Explicitly reset to null to ensure that calling GetCharacteristic() on the |
| 254 // removed characteristic in GattDescriptorRemoved() returns null. | 257 // removed characteristic in GattDescriptorRemoved() returns null. |
| 255 for (auto& entry : included_characteristics_) | 258 for (auto& entry : included_characteristics_) |
| 256 entry.second.reset(); | 259 entry.second.reset(); |
| 257 included_characteristics_.clear(); | 260 included_characteristics_.clear(); |
| 258 } | 261 } |
| 259 | 262 |
| 260 } // namespace device. | 263 } // namespace device. |
| OLD | NEW |