| 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_characteristic_win.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_win.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 BLUETOOTH_GATT_EVENT_HANDLE event_handle, | 440 BLUETOOTH_GATT_EVENT_HANDLE event_handle, |
| 441 HRESULT hr) { | 441 HRESULT hr) { |
| 442 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 442 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 443 | 443 |
| 444 gatt_event_registeration_in_progress_ = false; | 444 gatt_event_registeration_in_progress_ = false; |
| 445 std::vector<std::pair<NotifySessionCallback, ErrorCallback>> callbacks; | 445 std::vector<std::pair<NotifySessionCallback, ErrorCallback>> callbacks; |
| 446 callbacks.swap(start_notify_session_callbacks_); | 446 callbacks.swap(start_notify_session_callbacks_); |
| 447 if (SUCCEEDED(hr)) { | 447 if (SUCCEEDED(hr)) { |
| 448 gatt_event_handle_ = event_handle; | 448 gatt_event_handle_ = event_handle; |
| 449 for (const auto& callback : callbacks) { | 449 for (const auto& callback : callbacks) { |
| 450 callback.first.Run(base::WrapUnique( | 450 callback.first.Run(base::MakeUnique<BluetoothGattNotifySession>( |
| 451 new BluetoothGattNotifySession(weak_ptr_factory_.GetWeakPtr()))); | 451 weak_ptr_factory_.GetWeakPtr())); |
| 452 } | 452 } |
| 453 } else { | 453 } else { |
| 454 for (const auto& callback : callbacks) | 454 for (const auto& callback : callbacks) |
| 455 callback.second.Run(HRESULTToGattErrorCode(hr)); | 455 callback.second.Run(HRESULTToGattErrorCode(hr)); |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 | 458 |
| 459 void BluetoothRemoteGattCharacteristicWin::ClearIncludedDescriptors() { | 459 void BluetoothRemoteGattCharacteristicWin::ClearIncludedDescriptors() { |
| 460 // Explicitly reset to null to ensure that calling GetDescriptor() on the | 460 // Explicitly reset to null to ensure that calling GetDescriptor() on the |
| 461 // removed descriptor in GattDescriptorRemoved() returns null. | 461 // removed descriptor in GattDescriptorRemoved() returns null. |
| 462 for (auto& entry : included_descriptors_) | 462 for (auto& entry : included_descriptors_) |
| 463 entry.second.reset(); | 463 entry.second.reset(); |
| 464 included_descriptors_.clear(); | 464 included_descriptors_.clear(); |
| 465 } | 465 } |
| 466 | 466 |
| 467 } // namespace device. | 467 } // namespace device. |
| OLD | NEW |